Package com.netflix.curator.framework.CuratorFrameworkFactory

Examples of com.netflix.curator.framework.CuratorFrameworkFactory.Builder


  private static final Logger log = LoggerFactory.getLogger(ZookeeperContext.class);

  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;
View Full Code Here


  private final CuratorFramework client;

  public CuratorZookeeperClient(URL url) {
    super(url);
    try {
      Builder builder = CuratorFrameworkFactory.builder()
          .connectString(url.getBackupAddress())
              .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000)) 
              .connectionTimeoutMs(5000);
      String authority = url.getAuthority();
      if (authority != null && authority.length() > 0) {
        builder = builder.authorization("digest", authority.getBytes());
      }
      client = builder.build();
      client.getConnectionStateListenable().addListener(new ConnectionStateListener() {
        public void stateChanged(CuratorFramework client, ConnectionState state) {
          if (state == ConnectionState.LOST) {
            CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED);
          } else if (state == ConnectionState.CONNECTED) {
View Full Code Here

  private final CuratorFramework client;

  public CuratorZookeeperClient(URL url) {
    super(url);
    try {
      Builder builder = CuratorFrameworkFactory.builder()
          .connectString(url.getBackupAddress())
              .retryPolicy(new RetryNTimes(Integer.MAX_VALUE, 1000)) 
              .connectionTimeoutMs(5000);
      String authority = url.getAuthority();
      if (authority != null && authority.length() > 0) {
        builder = builder.authorization("digest", authority.getBytes());
      }
      client = builder.build();
      client.getConnectionStateListenable().addListener(new ConnectionStateListener() {
        public void stateChanged(CuratorFramework client, ConnectionState state) {
          if (state == ConnectionState.LOST) {
            CuratorZookeeperClient.this.stateChanged(StateListener.DISCONNECTED);
          } else if (state == ConnectionState.CONNECTED) {
View Full Code Here

TOP

Related Classes of com.netflix.curator.framework.CuratorFrameworkFactory.Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.