public static CuratorFramework newCurator ( String zookeepers , int timeout , String secret ) { final ExponentialBackoffRetry retry = new ExponentialBackoffRetry ( 1000 , 10 ) ; if ( secret . isEmpty ( ) ) { return CuratorFrameworkFactory . newClient ( zookeepers , timeout , timeout , retry ) ; } else { return CuratorFrameworkFactory . builder ( ) . connectString ( zookeepers ) . connectionTimeoutMs ( timeout ) . sessionTimeoutMs ( timeout ) . retryPolicy ( retry ) . authorization ( "digest" , ( "fluo:" + secret ) . getBytes ( StandardCharsets . UTF_8 ) ) . aclProvider ( new ACLProvider ( ) { @ Override public List < ACL > getDefaultAcl ( ) { return CREATOR_ALL_ACL ; } @ Override public List < ACL > getAclForPath ( String path ) { switch ( path ) { case ZookeeperPath . ORACLE_GC_TIMESTAMP : // The garbage collection iterator running in Accumulo tservers needs to read this // value w/o authenticating. return PUBLICLY_READABLE_ACL ; default : return CREATOR_ALL_ACL ; } } } ) . build ( ) ; } }
Creates a curator built using the given zookeeper connection string and timeout