List of usage examples for org.apache.zookeeper ZooKeeper removeWatches
public void removeWatches(String path, Watcher watcher, WatcherType watcherType, boolean local) throws InterruptedException, KeeperException
From source file:org.apache.bookkeeper.zookeeper.ZooKeeperClient.java
License:Apache License
@Override public void removeWatches(String path, Watcher watcher, WatcherType watcherType, boolean local) throws InterruptedException, KeeperException { ZooKeeper zkHandle = zk.get(); if (null == zkHandle) { ZooKeeperClient.super.removeWatches(path, watcher, watcherType, local); } else {/* ww w. ja v a 2 s . c o m*/ zkHandle.removeWatches(path, watcher, watcherType, local); } }
From source file:org.apache.curator.framework.imps.RemoveWatchesBuilderImpl.java
License:Apache License
private void pathInForeground(final String path) throws Exception { NamespaceWatcher namespaceWatcher = makeNamespaceWatcher(path); //For the local case we don't want to use the normal retry loop and we don't want to block until a connection is available. //We just execute the removeWatch, and if it fails, ZK will just remove local watches. if (local) {/*from www.jav a 2 s .c o m*/ ZooKeeper zkClient = client.getZooKeeper(); if (namespaceWatcher != null) { zkClient.removeWatches(path, namespaceWatcher, watcherType, local); } else { zkClient.removeAllWatches(path, watcherType, local); } } else { final NamespaceWatcher finalNamespaceWatcher = namespaceWatcher; RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<Void>() { @Override public Void call() throws Exception { try { ZooKeeper zkClient = client.getZookeeperClient().getZooKeeper(); if (finalNamespaceWatcher != null) { zkClient.removeWatches(path, finalNamespaceWatcher, watcherType, false); } else { zkClient.removeAllWatches(path, watcherType, false); } } catch (Exception e) { if (RetryLoop.isRetryException(e) && guaranteed) { //Setup the guaranteed handler client.getFailedRemoveWatcherManager() .addFailedOperation(new FailedRemoveWatchManager.FailedRemoveWatchDetails(path, finalNamespaceWatcher)); throw e; } else if (e instanceof KeeperException.NoWatcherException && quietly) { // ignore } else { //Rethrow throw e; } } return null; } }); } }