Search in sources :

Example 1 with Builder

use of com.netflix.curator.framework.CuratorFrameworkFactory.Builder 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;
}
Also used : TimeSpan(com.fathomdb.TimeSpan) CuratorFramework(com.netflix.curator.framework.CuratorFramework) OpsException(org.platformlayer.ops.OpsException) RetryOneTime(com.netflix.curator.retry.RetryOneTime) Builder(com.netflix.curator.framework.CuratorFrameworkFactory.Builder) IOException(java.io.IOException) RetryPolicy(com.netflix.curator.RetryPolicy)

Aggregations

TimeSpan (com.fathomdb.TimeSpan)1 RetryPolicy (com.netflix.curator.RetryPolicy)1 CuratorFramework (com.netflix.curator.framework.CuratorFramework)1 Builder (com.netflix.curator.framework.CuratorFrameworkFactory.Builder)1 RetryOneTime (com.netflix.curator.retry.RetryOneTime)1 IOException (java.io.IOException)1 OpsException (org.platformlayer.ops.OpsException)1