remington_young 发表于 2015-9-6 14:06:05

Zookeeper连接重试设置

  开发HBase应用的时候需要设置连接超时时间,可以通过zookeeper.recovery.retry和zookeeper.recovery.retry.intervalmill设置
  
  在ZKUtil.java中:
  public static RecoverableZooKeeper connect(Configuration conf, String ensemble,
      Watcher watcher, final String identifier)
throws IOException {
    if(ensemble == null) {
      throw new IOException("Unable to determine ZooKeeper ensemble");
    }
    int timeout = conf.getInt(HConstants.ZK_SESSION_TIMEOUT,
      HConstants.DEFAULT_ZK_SESSION_TIMEOUT);
    if (LOG.isTraceEnabled()) {
      LOG.trace(identifier + " opening connection to ZooKeeper ensemble=" + ensemble);
    }
    int retry = conf.getInt("zookeeper.recovery.retry", 3);//zookeeper连接重试次数
    int retryIntervalMillis =
      conf.getInt("zookeeper.recovery.retry.intervalmill", 1000);//zookeeper连接重试间隔
    zkDumpConnectionTimeOut = conf.getInt("zookeeper.dump.connection.timeout",
      1000);
    return new RecoverableZooKeeper(ensemble, timeout, watcher,
      retry, retryIntervalMillis, identifier);
}
页: [1]
查看完整版本: Zookeeper连接重试设置