public final class ZKOperations extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ZKOperations.Callback<T>
Represents a ZK operation updates callback.
|
static interface |
ZKOperations.ChildrenCallback
Interface for defining callback method to receive children nodes updates.
|
static interface |
ZKOperations.DataCallback
Interface for defining callback method to receive node data updates.
|
Modifier and Type | Method and Description |
---|---|
static OperationFuture<String> |
createDeleteIfExists(ZKClient zkClient,
String path,
byte[] data,
org.apache.zookeeper.CreateMode createMode,
boolean createParent,
org.apache.zookeeper.data.ACL... acls)
Creates a ZK node of the given path.
|
static <V> OperationFuture<V> |
ignoreError(OperationFuture<V> future,
Class<? extends org.apache.zookeeper.KeeperException> exceptionType,
V errorResult)
Returns a new
OperationFuture that the result will be the same as the given future, except that when
the source future is having an exception matching the giving exception type, the errorResult will be set
in to the returned OperationFuture . |
static OperationFuture<String> |
recursiveDelete(ZKClient zkClient,
String path)
Deletes the given path recursively.
|
static Cancellable |
watchChildren(ZKClient zkClient,
String path,
ZKOperations.ChildrenCallback callback) |
static Cancellable |
watchData(ZKClient zkClient,
String path,
ZKOperations.DataCallback callback)
Watch for data changes of the given path.
|
static com.google.common.util.concurrent.ListenableFuture<String> |
watchDeleted(ZKClient zkClient,
String path) |
static void |
watchDeleted(ZKClient zkClient,
String path,
com.google.common.util.concurrent.SettableFuture<String> completion) |
public static Cancellable watchData(ZKClient zkClient, String path, ZKOperations.DataCallback callback)
zkClient
- The ZKClient
for the operationpath
- Path to watchcallback
- Callback to be invoked when data changes is detected.Cancellable
to cancel the watch.public static com.google.common.util.concurrent.ListenableFuture<String> watchDeleted(ZKClient zkClient, String path)
public static void watchDeleted(ZKClient zkClient, String path, com.google.common.util.concurrent.SettableFuture<String> completion)
public static Cancellable watchChildren(ZKClient zkClient, String path, ZKOperations.ChildrenCallback callback)
public static <V> OperationFuture<V> ignoreError(OperationFuture<V> future, Class<? extends org.apache.zookeeper.KeeperException> exceptionType, V errorResult)
OperationFuture
that the result will be the same as the given future, except that when
the source future is having an exception matching the giving exception type, the errorResult will be set
in to the returned OperationFuture
.V
- Type of the result.future
- The source future.exceptionType
- Type of KeeperException
to be ignored.errorResult
- Object to be set into the resulting future on a matching exception.OperationFuture
.public static OperationFuture<String> recursiveDelete(ZKClient zkClient, String path)
KeeperException
during the deletion other than
KeeperException.NotEmptyException
or KeeperException.NoNodeException
,
the exception would be reflected in the result future and deletion process will stop,
leaving the given path with intermediate state.path
- The path to delete.OperationFuture
that will be completed when the given path is deleted or bailed due to
exception.public static OperationFuture<String> createDeleteIfExists(ZKClient zkClient, String path, @Nullable byte[] data, org.apache.zookeeper.CreateMode createMode, boolean createParent, org.apache.zookeeper.data.ACL... acls)
Copyright © 2013-2016 The Apache Software Foundation. All rights reserved.