Created
December 20, 2019 09:05
-
-
Save anjanashankar9/91b5aeb273dc42dda5dc7e17a9327cf1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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