Package org.apache.curator.retry

Examples of org.apache.curator.retry.ExponentialBackoffRetry


    }
    this.zkCluster = new MiniZooKeeperCluster();
    this.zkPort = this.zkCluster.startup(zkDataDir);
    this.zkClient =
        CuratorFrameworkFactory.builder().connectString("localhost:" + zkPort)
            .retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
    this.zkClient.start();
  }
View Full Code Here


   * Open a ZooKeeper connection for the JobState.
   */
  public static CuratorFramework zkOpen(String zkHosts, int zkSessionTimeoutMs)
    throws IOException {
    //do we need to add a connection status listener?  What will that do?
    ExponentialBackoffRetry retryPolicy = new ExponentialBackoffRetry(1000, 3);
    CuratorFramework zk = CuratorFrameworkFactory.newClient(zkHosts, zkSessionTimeoutMs,
      CuratorFrameworkFactory.builder().getConnectionTimeoutMs(), retryPolicy);
    zk.start();
    return zk;
  }
View Full Code Here

    List<String> serverHosts;
    Random randomizer = new Random();
    String serverNode;
    CuratorFramework zooKeeperClient =
        CuratorFrameworkFactory.builder().connectString(zooKeeperEnsemble)
            .retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
    zooKeeperClient.start();
    try {
      serverHosts = zooKeeperClient.getChildren().forPath("/" + zooKeeperNamespace);
      // Remove the znodes we've already tried from this list
      serverHosts.removeAll(connParams.getRejectedHostZnodePaths());
View Full Code Here

      synchronized (this) {
        if (zkSession == null || zkSession.getState() == CuratorFrameworkState.STOPPED) {
          zkSession =
              CuratorFrameworkFactory.builder().connectString(zkConnectString)
                  .connectionTimeoutMs(connectTimeoutMillis).aclProvider(aclDefaultProvider)
                  .retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
          zkSession.start();
        }
      }
    }
    return zkSession;
View Full Code Here

    setUpZooKeeperAuth(hiveConf);
    // Create a CuratorFramework instance to be used as the ZooKeeper client
    // Use the zooKeeperAclProvider to create appropriate ACLs
    zooKeeperClient =
        CuratorFrameworkFactory.builder().connectString(zooKeeperEnsemble)
            .aclProvider(zooKeeperAclProvider).retryPolicy(new ExponentialBackoffRetry(1000, 3))
            .build();
    zooKeeperClient.start();
    // Create the parent znodes recursively; ignore if the parent already exists.
    try {
      zooKeeperClient.create().creatingParentsIfNeeded().withMode(CreateMode.PERSISTENT)
View Full Code Here

    HiveConf hiveConf = new HiveConf();
    String zooKeeperEnsemble = ZooKeeperHiveHelper.getQuorumServers(hiveConf);
    String rootNamespace = hiveConf.getVar(HiveConf.ConfVars.HIVE_SERVER2_ZOOKEEPER_NAMESPACE);
    CuratorFramework zooKeeperClient =
        CuratorFrameworkFactory.builder().connectString(zooKeeperEnsemble)
            .retryPolicy(new ExponentialBackoffRetry(1000, 3)).build();
    zooKeeperClient.start();
    List<String> znodePaths =
        zooKeeperClient.getChildren().forPath(
            ZooKeeperHiveHelper.ZOOKEEPER_PATH_SEPARATOR + rootNamespace);
    // Now for each path that is for the given versionNumber, delete the znode from ZooKeeper
View Full Code Here

     *
     * @see #getMaxRetries()
     * @see #getBackOffBaseTime()
     */
    public RetryPolicy getRetryPolicy() {
        return new ExponentialBackoffRetry((int) backOffBaseTime.toMilliseconds(), maxRetries);
    }
View Full Code Here

            log.error("Unable to register mbean for " + getClass().getSimpleName(), exc);
        }

        this.locks = new ConcurrentHashMap<Integer, Lock>();
        this.client = null;
        RetryPolicy policy = new ExponentialBackoffRetry((int)ZK_RETRY_INTERVAL, ZK_MAX_RETRIES);

        this.client = CuratorFrameworkFactory.
                builder().namespace(ZK_NAMESPACE)
                .connectString(zookeeperCluster)
                .sessionTimeoutMs((int) ZK_SESSION_TIMEOUT_MS)
View Full Code Here

    private int maxRetries = 3;

    @Override
    public RetryPolicy build()
    {
        return new ExponentialBackoffRetry((int)baseSleepTime.toMillis(), maxRetries);
    }
View Full Code Here

    public static CuratorFramework makeCustomChrootClient(String zkHosts, String chroot) {
        CuratorFramework framework = CuratorFrameworkFactory.builder()
                .sessionTimeoutMs(zkSessionTimeout)
                .connectionTimeoutMs(zkConnectionTimeout)
                .connectString(zkHosts + "/" + chroot)
                .retryPolicy(new ExponentialBackoffRetry(baseZkRetryTimeMs, zkRetryMaxAttempts))
                .defaultData(null)
                .build();
        framework.start();
        return framework;
    }
View Full Code Here

TOP

Related Classes of org.apache.curator.retry.ExponentialBackoffRetry

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.