protected static ZooKeeper getZooKeeper(ZooKeeperConnectionInfo info) { return getZooKeeper(info.keepers, info.timeout, info.scheme, info.auth); }
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 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 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 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(); } }
while (true) { try { getZooKeeper(info).create(zPath, data, acls, mode); return true; } catch (KeeperException e) { getZooKeeper(info).setData(zPath, data, version); return true; } catch (KeeperException e2) {
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(); } }
while (true) { try { children = getZooKeeper(info).getChildren(zPath, false); break; } catch (KeeperException e) { while (true) { try { stat = getZooKeeper(info).exists(zPath, null); getZooKeeper(info).delete(zPath, -1); return; } catch (NoNodeException e) {
protected static ZooKeeper getZooKeeper(ZooKeeperConnectionInfo info) { return getZooKeeper(info.keepers, info.timeout, info.scheme, info.auth); }
while (true) { try { children = getZooKeeper(info).getChildren(source, false); break; } catch (KeeperException 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 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(); } }
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(); } }
while (true) { try { children = getZooKeeper(info).getChildren(source, false); break; } catch (KeeperException e) {