List of usage examples for org.apache.zookeeper KeeperException code
Code code
To view the source code for org.apache.zookeeper KeeperException code.
Click Source Link
From source file:com.ery.estorm.zk.RecoverableZooKeeper.java
License:Apache License
private String createSequential(String path, byte[] data, List<ACL> acl, CreateMode createMode) throws KeeperException, InterruptedException, IOException { RetryCounter retryCounter = retryCounterFactory.create(); boolean first = true; String newPath = path + this.identifier; while (true) { try {// w w w . j a v a 2 s .c o m if (!first) { // Check if we succeeded on a previous attempt String previousResult = findPreviousSequentialNode(newPath); if (previousResult != null) { return previousResult; } } first = false; return zk.create(newPath, data, acl, createMode); } catch (KeeperException e) { switch (e.code()) { case CONNECTIONLOSS: case SESSIONEXPIRED: reconnectAfterExpiration(); case OPERATIONTIMEOUT: retryOrThrow(retryCounter, e, "create"); break; default: throw e; } } retryCounter.sleepUntilNextRetry(); retryCounter.useRetry(); } }
From source file:com.ery.estorm.zk.RecoverableZooKeeper.java
License:Apache License
/** * Run multiple operations in a transactional manner. Retry before throwing * exception//from w ww.ja v a2s . c om * * @throws IOException */ public List<OpResult> multi(Iterable<Op> ops) throws KeeperException, InterruptedException, IOException { TraceScope traceScope = null; try { traceScope = Trace.startSpan("RecoverableZookeeper.multi"); RetryCounter retryCounter = retryCounterFactory.create(); Iterable<Op> multiOps = prepareZKMulti(ops); while (true) { try { return zk.multi(multiOps); } catch (KeeperException e) { switch (e.code()) { case CONNECTIONLOSS: case SESSIONEXPIRED: reconnectAfterExpiration(); case OPERATIONTIMEOUT: retryOrThrow(retryCounter, e, "multi"); break; default: throw e; } } retryCounter.sleepUntilNextRetry(); retryCounter.useRetry(); } } finally { if (traceScope != null) traceScope.close(); } }
From source file:com.facebook.zookeeper.RecoveringZooKeeper.java
License:Apache License
@Override public void delete(String path, int version) throws InterruptedException, KeeperException { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { try {/*from ww w . j a v a 2s . c om*/ zk.delete(path, version); return; } catch (KeeperException e) { switch (e.code()) { case NONODE: return; // Delete was successful case CONNECTIONLOSS: case OPERATIONTIMEOUT: LOG.warn("Possibly transient ZooKeeper exception: " + e); if (!retryCounter.shouldRetry()) { LOG.error("ZooKeeper delete failed after " + retryCounter.getMaxRetries() + " retries"); throw e; } break; default: throw e; } } LOG.info("Retrying ZooKeeper after sleeping..."); retryCounter.sleepUntilNextRetry(); retryCounter.useRetry(); } }
From source file:com.facebook.zookeeper.RecoveringZooKeeper.java
License:Apache License
@Override public Stat exists(String path, Watcher watcher) throws KeeperException, InterruptedException { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { try {/*from www. j a va 2 s . c o m*/ return zk.exists(path, watcher); } catch (KeeperException e) { switch (e.code()) { case CONNECTIONLOSS: case OPERATIONTIMEOUT: LOG.warn("Possibly transient ZooKeeper exception: " + e); if (!retryCounter.shouldRetry()) { LOG.error("ZooKeeper exists failed after " + retryCounter.getMaxRetries() + " retries"); throw e; } break; default: throw e; } } LOG.info("Retrying ZooKeeper after sleeping..."); retryCounter.sleepUntilNextRetry(); retryCounter.useRetry(); } }
From source file:com.facebook.zookeeper.RecoveringZooKeeper.java
License:Apache License
@Override public Stat exists(String path, boolean watch) throws KeeperException, InterruptedException { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { try {/* www .j a v a2 s .c o m*/ return zk.exists(path, watch); } catch (KeeperException e) { switch (e.code()) { case CONNECTIONLOSS: case OPERATIONTIMEOUT: LOG.warn("Possibly transient ZooKeeper exception: " + e); if (!retryCounter.shouldRetry()) { LOG.error("ZooKeeper exists failed after " + retryCounter.getMaxRetries() + " retries"); throw e; } break; default: throw e; } } LOG.info("Retrying ZooKeeper after sleeping..."); retryCounter.sleepUntilNextRetry(); retryCounter.useRetry(); } }
From source file:com.facebook.zookeeper.RecoveringZooKeeper.java
License:Apache License
@Override public byte[] getData(String path, Watcher watcher, Stat stat) throws KeeperException, InterruptedException { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { try {/*from w w w . jav a 2 s .com*/ return zk.getData(path, watcher, stat); } catch (KeeperException e) { switch (e.code()) { case CONNECTIONLOSS: case OPERATIONTIMEOUT: LOG.warn("Possibly transient ZooKeeper exception: " + e); if (!retryCounter.shouldRetry()) { LOG.error("ZooKeeper getData failed after " + retryCounter.getMaxRetries() + " retries"); throw e; } break; default: throw e; } } LOG.info("Retrying ZooKeeper after sleeping..."); retryCounter.sleepUntilNextRetry(); retryCounter.useRetry(); } }
From source file:com.facebook.zookeeper.RecoveringZooKeeper.java
License:Apache License
@Override public byte[] getData(String path, boolean watch, Stat stat) throws KeeperException, InterruptedException { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { try {/*from w ww. j a v a2 s. c o m*/ return zk.getData(path, watch, stat); } catch (KeeperException e) { switch (e.code()) { case CONNECTIONLOSS: case OPERATIONTIMEOUT: LOG.warn("Possibly transient ZooKeeper exception: " + e); if (!retryCounter.shouldRetry()) { LOG.error("ZooKeeper getData failed after " + retryCounter.getMaxRetries() + " retries"); throw e; } break; default: throw e; } } LOG.info("Retrying ZooKeeper after sleeping..."); retryCounter.sleepUntilNextRetry(); retryCounter.useRetry(); } }
From source file:com.facebook.zookeeper.RecoveringZooKeeper.java
License:Apache License
@Override public Stat setData(String path, byte[] data, int version) throws KeeperException, InterruptedException { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { try {//from w ww .ja va2 s.com return zk.setData(path, data, version); } catch (KeeperException e) { switch (e.code()) { case CONNECTIONLOSS: case OPERATIONTIMEOUT: LOG.warn("Possibly transient ZooKeeper exception: " + e); if (!retryCounter.shouldRetry()) { LOG.error("ZooKeeper setData failed after " + retryCounter.getMaxRetries() + " retries"); throw e; } break; default: throw e; } } LOG.info("Retrying ZooKeeper after sleeping..."); retryCounter.sleepUntilNextRetry(); retryCounter.useRetry(); } }
From source file:com.facebook.zookeeper.RecoveringZooKeeper.java
License:Apache License
@Override public List<String> getChildren(String path, Watcher watcher) throws KeeperException, InterruptedException { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { try {/*w ww .j av a 2 s . c om*/ return zk.getChildren(path, watcher); } catch (KeeperException e) { switch (e.code()) { case CONNECTIONLOSS: case OPERATIONTIMEOUT: LOG.warn("Possibly transient ZooKeeper exception: " + e); if (!retryCounter.shouldRetry()) { LOG.error( "ZooKeeper getChildren failed after " + retryCounter.getMaxRetries() + " retries"); throw e; } break; default: throw e; } } LOG.info("Retrying ZooKeeper after sleeping..."); retryCounter.sleepUntilNextRetry(); retryCounter.useRetry(); } }
From source file:com.facebook.zookeeper.RecoveringZooKeeper.java
License:Apache License
@Override public List<String> getChildren(String path, boolean watch) throws KeeperException, InterruptedException { RetryCounter retryCounter = retryCounterFactory.create(); while (true) { try {// www. j a v a 2s .c om return zk.getChildren(path, watch); } catch (KeeperException e) { switch (e.code()) { case CONNECTIONLOSS: case OPERATIONTIMEOUT: LOG.warn("Possibly transient ZooKeeper exception: " + e); if (!retryCounter.shouldRetry()) { LOG.error( "ZooKeeper getChildren failed after " + retryCounter.getMaxRetries() + " retries"); throw e; } break; default: throw e; } } LOG.info("Retrying ZooKeeper after sleeping..."); retryCounter.sleepUntilNextRetry(); retryCounter.useRetry(); } }