use of com.netflix.curator.RetryPolicy in project platformlayer by platformlayer.
the class ZookeeperContext method buildZk.
public CuratorFramework buildZk(List<String> dnsNames) throws OpsException {
String connectionString = Joiner.on(",").join(dnsNames);
Builder builder = CuratorFrameworkFactory.builder();
builder.connectString(connectionString);
TimeSpan retryInterval = TimeSpan.FIVE_SECONDS;
RetryPolicy retryPolicy = new RetryOneTime((int) retryInterval.getTotalMilliseconds());
builder.retryPolicy(retryPolicy);
CuratorFramework curatorFramework;
try {
curatorFramework = builder.build();
} catch (IOException e) {
throw new OpsException("Error building zookeeper connection", e);
}
return curatorFramework;
// TimeSpan sessionTimeout = TimeSpan.TEN_SECONDS;
//
// ZooKeeper zk = new ZooKeeper(connectionString, (int) sessionTimeout.getTotalMilliseconds(), this);
// return zk;
}
Aggregations