@Override public void onFailure(Throwable t) { if (!doRetry(t)) { result.setException(t); } }
@Override public void onSuccess(String result) { // Path deleted successfully. Operation done. resultFuture.set(result); }
/** * Creates a {@link ZKClient} that will add prefix namespace for every paths. * * @param zkClient The {@link ZKClient} for operations delegation. * @param namespace The prefix namespace to be prepended to paths. * @return A {@link ZKClient} that will add namespace to every path. */ public static ZKClient namespace(ZKClient zkClient, String namespace) { return new NamespaceZKClient(zkClient, namespace); }
@Override protected void shutDown() throws Exception { leaderElection.stopAndWait(); } }
@Override public OperationFuture<String> delete(String deletePath, int version) { SettableOperationFuture<String> result = SettableOperationFuture.create(deletePath, eventExecutor); getZooKeeper().delete(deletePath, version, Callbacks.VOID, result); return result; }
@Override public void onFailure(Throwable t) { to.setException(t); } });
/** * Creates an instance of {@link ZKClientService} with the settings of this builder. * @return A new instance of {@link ZKClientService}. */ public ZKClientService build() { return new DefaultZKClientService(connectStr, timeout, connectionWatcher, auths); }
/** * Creates a {@link ZKClient} that will retry interim failure (e.g. connection loss, session expiration) * based on the given {@link RetryStrategy}. * * @param client The {@link ZKClient} for operations delegation. * @param retryStrategy The {@link RetryStrategy} to be invoke when there is operation failure. * @return A {@link ZKClient}. */ public static ZKClient retryOnFailure(ZKClient client, RetryStrategy retryStrategy) { return new FailureRetryZKClient(client, retryStrategy); }
/** * Creates a {@link ZKClient} that will perform auto re-watch on all existing watches * when reconnection happens after session expiration. All {@link org.apache.zookeeper.Watcher Watchers} * set through the returned {@link ZKClient} would not receive any connection events. * * @param client The {@link ZKClient} for operations delegation. * @return A {@link ZKClient} that will do auto re-watch on all methods that accept a * {@link org.apache.zookeeper.Watcher} upon session expiration. */ public static ZKClient reWatchOnExpire(ZKClient client) { return new RewatchOnExpireZKClient(client); }
@Override public void onSuccess(String path) { // Propagate if creation was successful result.set(path); }
@Override public void onFailure(Throwable t) { if (!doRetry(t)) { result.setException(t); } }
/** * Creates an instance of {@link ZKClientService} with the settings of this builder. * @return A new instance of {@link ZKClientService}. */ public ZKClientService build() { return new DefaultZKClientService(connectStr, timeout, connectionWatcher, auths); }
/** * Creates a {@link ZKClient} that will retry interim failure (e.g. connection loss, session expiration) * based on the given {@link RetryStrategy}. * * @param client The {@link ZKClient} for operations delegation. * @param retryStrategy The {@link RetryStrategy} to be invoke when there is operation failure. * @return A {@link ZKClient}. */ public static ZKClient retryOnFailure(ZKClient client, RetryStrategy retryStrategy) { return new FailureRetryZKClient(client, retryStrategy); }
/** * Creates a {@link ZKClient} that will perform auto re-watch on all existing watches * when reconnection happens after session expiration. All {@link org.apache.zookeeper.Watcher Watchers} * set through the returned {@link ZKClient} would not receive any connection events. * * @param client The {@link ZKClient} for operations delegation. * @return A {@link ZKClient} that will do auto re-watch on all methods that accept a * {@link org.apache.zookeeper.Watcher} upon session expiration. */ public static ZKClient reWatchOnExpire(ZKClient client) { return new RewatchOnExpireZKClient(client); }
@Override public void onSuccess(String path) { // Propagate if creation was successful result.set(path); }
@Override public void onSuccess(String path) { // Propagate if creation was successful result.set(path); }
@Override public void onSuccess(String path) { // Propagate if creation was successful result.set(path); }
@Override public void onSuccess(String result) { // Create succeeded, just set the result to the resultFuture resultFuture.set(result); }
@Override public void onSuccess(String path) { // Propagate if creation was successful result.set(path); }
@Override public void onSuccess(String result) { // Create succeeded, just set the result to the resultFuture resultFuture.set(result); }