public static boolean isLockHeld(ZooKeeperConnectionInfo info, LockID lid) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { List<String> children = getZooKeeper(info).getChildren(lid.path, false); if (children.size() == 0) { return false; } Collections.sort(children); String lockNode = children.get(0); if (!lid.node.equals(lockNode)) return false; Stat stat = getZooKeeper(info).exists(lid.path + "/" + lid.node, false); return stat != null && stat.getEphemeralOwner() == lid.eid; } catch (KeeperException ex) { final Code c = ex.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); } } retry.waitForNextAttempt(); } }
public static byte[] getData(ZooKeeperConnectionInfo info, String zPath, Stat stat) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).getData(zPath, false, stat); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
public static String putEphemeralData(ZooKeeperConnectionInfo info, String zPath, byte[] data) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).create(zPath, data, ZooUtil.PUBLIC, CreateMode.EPHEMERAL); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
public static Stat getStatus(ZooKeeperConnectionInfo info, String zPath) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).exists(zPath, false); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
public static String putPersistentSequential(ZooKeeperConnectionInfo info, String zPath, byte[] data) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).create(zPath, data, ZooUtil.PUBLIC, CreateMode.PERSISTENT_SEQUENTIAL); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
public static String putEphemeralSequential(ZooKeeperConnectionInfo info, String zPath, byte[] data) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).create(zPath, data, ZooUtil.PUBLIC, CreateMode.EPHEMERAL_SEQUENTIAL); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
} else if (code2 == Code.CONNECTIONLOSS || code2 == Code.OPERATIONTIMEOUT || code2 == Code.SESSIONEXPIRED) { retryOrThrow(retry, e2); break; } else { retryOrThrow(retry, e); } else {
public static List<ACL> getACL(ZooKeeperConnectionInfo info, String zPath, Stat stat) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).getACL(zPath, stat); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e;
if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e;
public static boolean isLockHeld(ZooKeeperConnectionInfo info, LockID lid) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { List<String> children = getZooKeeper(info).getChildren(lid.path, false); if (children.size() == 0) { return false; } Collections.sort(children); String lockNode = children.get(0); if (!lid.node.equals(lockNode)) return false; Stat stat = getZooKeeper(info).exists(lid.path + "/" + lid.node, false); return stat != null && stat.getEphemeralOwner() == lid.eid; } catch (KeeperException ex) { final Code c = ex.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, ex); } } retry.waitForNextAttempt(); } }
public static byte[] getData(ZooKeeperConnectionInfo info, String zPath, Stat stat) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).getData(zPath, false, stat); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
public static Stat getStatus(ZooKeeperConnectionInfo info, String zPath) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).exists(zPath, false); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
public static String putEphemeralData(ZooKeeperConnectionInfo info, String zPath, byte[] data) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).create(zPath, data, ZooUtil.PUBLIC, CreateMode.EPHEMERAL); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
public static String putPersistentSequential(ZooKeeperConnectionInfo info, String zPath, byte[] data) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).create(zPath, data, ZooUtil.PUBLIC, CreateMode.PERSISTENT_SEQUENTIAL); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
public static String putEphemeralSequential(ZooKeeperConnectionInfo info, String zPath, byte[] data) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).create(zPath, data, ZooUtil.PUBLIC, CreateMode.EPHEMERAL_SEQUENTIAL); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
} else if (code2 == Code.CONNECTIONLOSS || code2 == Code.OPERATIONTIMEOUT || code2 == Code.SESSIONEXPIRED) { retryOrThrow(retry, e2); break; } else { retryOrThrow(retry, e); } else {
public static List<ACL> getACL(ZooKeeperConnectionInfo info, String zPath, Stat stat) throws KeeperException, InterruptedException { final Retry retry = RETRY_FACTORY.createRetry(); while (true) { try { return getZooKeeper(info).getACL(zPath, stat); } catch (KeeperException e) { final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; } } retry.waitForNextAttempt(); } }
final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e; final Code c = e.code(); if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e;
if (c == Code.CONNECTIONLOSS || c == Code.OPERATIONTIMEOUT || c == Code.SESSIONEXPIRED) { retryOrThrow(retry, e); } else { throw e;