Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@anjanashankar9
Created December 20, 2019 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anjanashankar9/91b5aeb273dc42dda5dc7e17a9327cf1 to your computer and use it in GitHub Desktop.
Save anjanashankar9/91b5aeb273dc42dda5dc7e17a9327cf1 to your computer and use it in GitHub Desktop.
public static CuratorFramework createConnection(String zookeeperConnectionString) {
//First retry will wait for 1 second,
//the second will wait up to 2 seconds,
//the third will wait upto 4 seconds.
RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
CuratorFramework client = CuratorFrameworkFactory.builder()
.connectString(zookeeperConnectionString)
.retryPolicy(retryPolicy)
.namespace("session_service")
.canBeReadOnly(true)
.zookeeperFactory(new DefaultZookeeperFactory())
.build();
client.start();
return client;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment