Java Code Examples for org.apache.zookeeper.KeeperException.Code#CONNECTIONLOSS

The following examples show how to use org.apache.zookeeper.KeeperException.Code#CONNECTIONLOSS . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ZooKeeperClient.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
public <T> T execute(ZKExecutor<T> executor) throws KeeperException, InterruptedException {
  final long timestmap = System.currentTimeMillis();
  int sessionTimeout = getSessionTimeout();
  if (sessionTimeout == 0) {
    sessionTimeout = internalSessionTimeout;
  }
  while (true) {
    Tracer trace = Trace.trace("remote call - zookeeper", Trace.param("method", executor._name),
        Trace.param("toString", executor.toString()));
    try {
      return executor.execute();
    } catch (KeeperException e) {
      if (e.code() == Code.CONNECTIONLOSS && timestmap + sessionTimeout >= System.currentTimeMillis()) {
        LOG.warn("Connection loss");
        ZkUtils.pause(this);
        continue;
      }
      throw e;
    } finally {
      trace.done();
    }
  }
}
 
Example 2
Source File: ActiveStandbyElector.java    From hadoop with Apache License 2.0 4 votes vote down vote up
private static boolean shouldRetry(Code code) {
  return code == Code.CONNECTIONLOSS || code == Code.OPERATIONTIMEOUT;
}
 
Example 3
Source File: ActiveStandbyElector.java    From big-c with Apache License 2.0 4 votes vote down vote up
private static boolean shouldRetry(Code code) {
  return code == Code.CONNECTIONLOSS || code == Code.OPERATIONTIMEOUT;
}