Example usage for org.apache.zookeeper ZooKeeper removeWatches

List of usage examples for org.apache.zookeeper ZooKeeper removeWatches

Introduction

In this page you can find the example usage for org.apache.zookeeper ZooKeeper removeWatches.

Prototype

public void removeWatches(String path, Watcher watcher, WatcherType watcherType, boolean local, VoidCallback cb,
        Object ctx) 

Source Link

Document

The asynchronous version of removeWatches.

Usage

From source file:org.apache.bookkeeper.zookeeper.ZooKeeperClient.java

License:Apache License

@Override
public void removeWatches(String path, Watcher watcher, WatcherType watcherType, boolean local, VoidCallback cb,
        Object ctx) {//from w  ww  .java 2s  .com
    ZooKeeper zkHandle = zk.get();
    if (null == zkHandle) {
        ZooKeeperClient.super.removeWatches(path, watcher, watcherType, local, cb, ctx);
    } else {
        zkHandle.removeWatches(path, watcher, watcherType, local, cb, ctx);
    }
}

From source file:org.apache.curator.framework.imps.RemoveWatchesBuilderImpl.java

License:Apache License

@Override
public void performBackgroundOperation(final OperationAndData<String> operationAndData) throws Exception {
    try {//from   w  w w .j  a va2  s .c  o  m
        final TimeTrace trace = client.getZookeeperClient().startTracer("RemoteWatches-Background");

        AsyncCallback.VoidCallback callback = new AsyncCallback.VoidCallback() {
            @Override
            public void processResult(int rc, String path, Object ctx) {
                trace.commit();
                CuratorEvent event = new CuratorEventImpl(client, CuratorEventType.REMOVE_WATCHES, rc, path,
                        null, ctx, null, null, null, null, null, null);
                client.processBackgroundOperation(operationAndData, event);
            }
        };

        ZooKeeper zkClient = client.getZooKeeper();
        NamespaceWatcher namespaceWatcher = makeNamespaceWatcher(operationAndData.getData());
        if (namespaceWatcher == null) {
            zkClient.removeAllWatches(operationAndData.getData(), watcherType, local, callback,
                    operationAndData.getContext());
        } else {
            zkClient.removeWatches(operationAndData.getData(), namespaceWatcher, watcherType, local, callback,
                    operationAndData.getContext());
        }
    } catch (Throwable e) {
        backgrounding.checkError(e, null);
    }
}