@Test(expected = SessionExpiredException.class) public void testMutateNodeCreationFails() throws Exception { final String path = "/foo"; final byte[] value = {0}; final List<ACL> acls = Collections.emptyList(); Mutator mutator = currentValue -> new byte[] {1}; zk.create(path, value, acls, CreateMode.PERSISTENT); EasyMock.expectLastCall().andThrow(new SessionExpiredException()).once(); EasyMock.expect(retry.canRetry()).andReturn(false); EasyMock.expect(retry.retriesCompleted()).andReturn(1L).once(); EasyMock.replay(zk, zrw, retryFactory, retry); zrw.mutate(path, value, acls, mutator); }
public byte[] mutate(String zPath, byte[] createValue, List<ACL> acl, Mutator mutator) throws Exception { if (createValue != null) { while (true) { final Retry retry = getRetryFactory().createRetry(); try { getZooKeeper().create(zPath, createValue, acl, CreateMode.PERSISTENT); return createValue; } catch (KeeperException ex) { final Code code = ex.code(); if (code == Code.NODEEXISTS) { break; } else if (code == Code.OPERATIONTIMEOUT || code == Code.CONNECTIONLOSS || code == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); } else { throw ex; } } retry.waitForNextAttempt(); } } do { final Retry retry = getRetryFactory().createRetry(); Stat stat = new Stat(); byte[] data = getData(zPath, stat); data = mutator.mutate(data); if (data == null) return data; try { getZooKeeper().setData(zPath, data, stat.getVersion()); return data; } catch (KeeperException ex) { final Code code = ex.code(); if (code == Code.BADVERSION) { } else if (code == Code.OPERATIONTIMEOUT || code == Code.CONNECTIONLOSS || code == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); retry.waitForNextAttempt(); } else { throw ex; } } } while (true); }
ZooReaderWriter extends ZooReader { public byte[] mutate(String zPath, byte[] createValue, List<ACL> acl, Mutator mutator) throws Exception { if (createValue != null) { while (true) { final Retry retry = getRetryFactory().createRetry(); try { getZooKeeper().create(zPath, createValue, acl, CreateMode.PERSISTENT); return createValue; } catch (KeeperException ex) { final Code code = ex.code(); if (code == Code.NODEEXISTS) { break; } else if (code == Code.OPERATIONTIMEOUT || code == Code.CONNECTIONLOSS || code == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); } else { throw ex; } } retry.waitForNextAttempt(); } } do { final Retry retry = getRetryFactory().createRetry(); Stat stat = new Stat(); byte[] data = getData(zPath, stat); data = mutator.mutate(data); if (data == null) return data; try { getZooKeeper().setData(zPath, data, stat.getVersion()); return data; } catch (KeeperException ex) { final Code code = ex.code(); if (code == Code.BADVERSION) { } else if (code == Code.OPERATIONTIMEOUT || code == Code.CONNECTIONLOSS || code == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); retry.waitForNextAttempt(); } else { throw ex; } } } while (true); } }
ZooReaderWriter extends ZooReader { public byte[] mutate(String zPath, byte[] createValue, List<ACL> acl, Mutator mutator) throws Exception { if (createValue != null) { while (true) { final Retry retry = getRetryFactory().createRetry(); try { getZooKeeper().create(zPath, createValue, acl, CreateMode.PERSISTENT); return createValue; } catch (KeeperException ex) { final Code code = ex.code(); if (code == Code.NODEEXISTS) { break; } else if (code == Code.OPERATIONTIMEOUT || code == Code.CONNECTIONLOSS || code == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); } else { throw ex; } } retry.waitForNextAttempt(); } } do { final Retry retry = getRetryFactory().createRetry(); Stat stat = new Stat(); byte[] data = getData(zPath, stat); data = mutator.mutate(data); if (data == null) return data; try { getZooKeeper().setData(zPath, data, stat.getVersion()); return data; } catch (KeeperException ex) { final Code code = ex.code(); if (code == Code.BADVERSION) { } else if (code == Code.OPERATIONTIMEOUT || code == Code.CONNECTIONLOSS || code == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); retry.waitForNextAttempt(); } else { throw ex; } } } while (true); } ZooReaderWriter(AccumuloConfiguration conf);  ZooReaderWriter(String keepers, int timeoutInMillis, String secret); }
ZooReaderWriter extends ZooReader { public byte[] mutate(String zPath, byte[] createValue, List<ACL> acl, Mutator mutator) throws Exception { if (createValue != null) { while (true) { final Retry retry = getRetryFactory().createRetry(); try { getZooKeeper().create(zPath, createValue, acl, CreateMode.PERSISTENT); return createValue; } catch (KeeperException ex) { final Code code = ex.code(); if (code == Code.NODEEXISTS) { break; } else if (code == Code.OPERATIONTIMEOUT || code == Code.CONNECTIONLOSS || code == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); } else { throw ex; } } retry.waitForNextAttempt(); } } do { final Retry retry = getRetryFactory().createRetry(); Stat stat = new Stat(); byte[] data = getData(zPath, stat); data = mutator.mutate(data); if (data == null) return data; try { getZooKeeper().setData(zPath, data, stat.getVersion()); return data; } catch (KeeperException ex) { final Code code = ex.code(); if (code == Code.BADVERSION) { } else if (code == Code.OPERATIONTIMEOUT || code == Code.CONNECTIONLOSS || code == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); retry.waitForNextAttempt(); } else { throw ex; } } } while (true); } ZooReaderWriter(AccumuloConfiguration conf);  ZooReaderWriter(String keepers, int timeoutInMillis, String secret); @Override ZooKeeper getZooKeeper(); List<ACL> getACL(String zPath, Stat stat); void recursiveDelete(String zPath, NodeMissingPolicy policy); boolean putPersistentData(String zPath, byte[] data, NodeExistsPolicy policy); boolean putPrivatePersistentData(String zPath, byte[] data, NodeExistsPolicy policy); boolean putPersistentData(String zPath, byte[] data, NodeExistsPolicy policy,
      List<ACL> acls); String putPersistentSequential(String zPath, byte[] data); String putEphemeralData(String zPath, byte[] data); String putEphemeralSequential(String zPath, byte[] data); void recursiveCopyPersistent(String source, String destination, NodeExistsPolicy policy); void delete(String path, int version); byte[] mutate(String zPath, byte[] createValue, List<ACL> acl, Mutator mutator); boolean isLockHeld(ZooUtil.LockID lockID); void mkdirs(String path); }
ZooReaderWriter extends ZooReader { public byte[] mutate(String zPath, byte[] createValue, List<ACL> acl, Mutator mutator) throws Exception { if (createValue != null) { while (true) { final Retry retry = getRetryFactory().createRetry(); try { getZooKeeper().create(zPath, createValue, acl, CreateMode.PERSISTENT); return createValue; } catch (KeeperException ex) { final Code code = ex.code(); if (code == Code.NODEEXISTS) { break; } else if (code == Code.OPERATIONTIMEOUT || code == Code.CONNECTIONLOSS || code == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); } else { throw ex; } } retry.waitForNextAttempt(); } } do { final Retry retry = getRetryFactory().createRetry(); Stat stat = new Stat(); byte[] data = getData(zPath, stat); data = mutator.mutate(data); if (data == null) return data; try { getZooKeeper().setData(zPath, data, stat.getVersion()); return data; } catch (KeeperException ex) { final Code code = ex.code(); if (code == Code.BADVERSION) { } else if (code == Code.OPERATIONTIMEOUT || code == Code.CONNECTIONLOSS || code == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); retry.waitForNextAttempt(); } else { throw ex; } } } while (true); } ZooReaderWriter(AccumuloConfiguration conf);  ZooReaderWriter(String keepers, int timeoutInMillis, String secret); @Override ZooKeeper getZooKeeper(); List<ACL> getACL(String zPath, Stat stat); void recursiveDelete(String zPath, NodeMissingPolicy policy); boolean putPersistentData(String zPath, byte[] data, NodeExistsPolicy policy); boolean putPrivatePersistentData(String zPath, byte[] data, NodeExistsPolicy policy); boolean putPersistentData(String zPath, byte[] data, NodeExistsPolicy policy,
      List<ACL> acls); String putPersistentSequential(String zPath, byte[] data); String putEphemeralData(String zPath, byte[] data); String putEphemeralSequential(String zPath, byte[] data); void recursiveCopyPersistent(String source, String destination, NodeExistsPolicy policy); void delete(String path, int version); byte[] mutate(String zPath, byte[] createValue, List<ACL> acl, Mutator mutator); boolean isLockHeld(ZooUtil.LockID lockID); void mkdirs(String path);  }