public List<OpResult> multi(final Iterable<Op> ops, boolean retryOnConnLoss) throws InterruptedException, KeeperException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(new ZkOperation() { @Override public List<OpResult> execute() throws KeeperException, InterruptedException { return keeper.multi(ops); } }); } else { return keeper.multi(ops); } }
public void delete(final String path, final int version, boolean retryOnConnLoss) throws InterruptedException, KeeperException { if (retryOnConnLoss) { zkCmdExecutor.retryOperation(new ZkOperation() { @Override public Stat execute() throws KeeperException, InterruptedException { keeper.delete(path, version); return null; } }); } else { keeper.delete(path, version); } }
/** * Returns true if path exists */ public Boolean exists(final String path, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(new ZkOperation() { @Override public Boolean execute() throws KeeperException, InterruptedException { return keeper.exists(path, null) != null; } }); } else { return keeper.exists(path, null) != null; } }
/** * Returns node's state */ public Stat setData(final String path, final byte data[], final int version, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(new ZkOperation() { @Override public Stat execute() throws KeeperException, InterruptedException { return keeper.setData(path, data, version); } }); } else { return keeper.setData(path, data, version); } }
/** * Returns node's state */ public Stat setData(final String path, final byte data[], final int version, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(() -> keeper.setData(path, data, version)); } else { return keeper.setData(path, data, version); } }
public List<OpResult> multi(final Iterable<Op> ops, boolean retryOnConnLoss) throws InterruptedException, KeeperException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(() -> keeper.multi(ops)); } else { return keeper.multi(ops); } }
/** * Returns true if path exists */ public Boolean exists(final String path, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(() -> keeper.exists(path, null) != null); } else { return keeper.exists(path, null) != null; } }
public void delete(final String path, final int version, boolean retryOnConnLoss) throws InterruptedException, KeeperException { if (retryOnConnLoss) { zkCmdExecutor.retryOperation(() -> { keeper.delete(path, version); return null; }); } else { keeper.delete(path, version); } }
/** * Set the ACL on a single node in ZooKeeper. This will replace all existing ACL on that node. * * @param path path to set ACL on e.g. /solr/conf/solrconfig.xml * @param acls a list of {@link ACL}s to be applied * @param retryOnConnLoss true if the command should be retried on connection loss */ public Stat setACL(String path, List<ACL> acls, boolean retryOnConnLoss) throws InterruptedException, KeeperException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(() -> keeper.setACL(path, acls, -1)); } else { return keeper.setACL(path, acls, -1); } }
/** * Returns children of the node at the path */ public List<String> getChildren(final String path, final Watcher watcher, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(new ZkOperation() { @Override public List<String> execute() throws KeeperException, InterruptedException { return keeper.getChildren(path, wrapWatcher(watcher)); } }); } else { return keeper.getChildren(path, wrapWatcher(watcher)); } }
/** * Returns node's data */ public byte[] getData(final String path, final Watcher watcher, final Stat stat, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(new ZkOperation() { @Override public byte[] execute() throws KeeperException, InterruptedException { return keeper.getData(path, wrapWatcher(watcher), stat); } }); } else { return keeper.getData(path, wrapWatcher(watcher), stat); } }
/** * Returns path of created node */ public String create(final String path, final byte[] data, final CreateMode createMode, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(new ZkOperation() { @Override public String execute() throws KeeperException, InterruptedException { return keeper.create(path, data, zkACLProvider.getACLsToAdd(path), createMode); } }); } else { List<ACL> acls = zkACLProvider.getACLsToAdd(path); return keeper.create(path, data, acls, createMode); } }
throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(new ZkOperation() { @Override public Stat execute() throws KeeperException, InterruptedException {
/** * Returns node's data */ public byte[] getData(final String path, final Watcher watcher, final Stat stat, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(() -> keeper.getData(path, wrapWatcher(watcher), stat)); } else { return keeper.getData(path, wrapWatcher(watcher), stat); } }
/** * Returns children of the node at the path */ public List<String> getChildren(final String path, final Watcher watcher, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(() -> keeper.getChildren(path, wrapWatcher(watcher))); } else { return keeper.getChildren(path, wrapWatcher(watcher)); } }
/** * Returns path of created node */ public String create(final String path, final byte[] data, final CreateMode createMode, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(() -> keeper.create(path, data, zkACLProvider.getACLsToAdd(path), createMode)); } else { List<ACL> acls = zkACLProvider.getACLsToAdd(path); return keeper.create(path, data, acls, createMode); } }
final CreateMode finalMode = mode; final byte[] finalBytes = bytes; zkCmdExecutor.retryOperation(new ZkOperation() { @Override public Object execute() throws KeeperException, InterruptedException {
/** * Return the stat of the node of the given path. Return null if no such a * node exists. * <p> * If the watch is non-null and the call is successful (no exception is thrown), * a watch will be left on the node with the given path. The watch will be * triggered by a successful operation that creates/delete the node or sets * the data on the node. * * @param path the node path * @param watcher explicit watcher * @return the stat of the node of the given path; return null if no such a * node exists. * @throws KeeperException If the server signals an error * @throws InterruptedException If the server transaction is interrupted. * @throws IllegalArgumentException if an invalid path is specified */ public Stat exists(final String path, final Watcher watcher, boolean retryOnConnLoss) throws KeeperException, InterruptedException { if (retryOnConnLoss) { return zkCmdExecutor.retryOperation(() -> keeper.exists(path, wrapWatcher(watcher))); } else { return keeper.exists(path, wrapWatcher(watcher)); } }
final CreateMode finalMode = mode; final byte[] finalBytes = bytes; zkCmdExecutor.retryOperation(() -> { keeper.create(currentPath, finalBytes, zkACLProvider.getACLsToAdd(currentPath), finalMode); return null;