@Override public OperationFuture<NodeData> getData(String path, Watcher watcher) { if (watcher == null) { return super.getData(path, null); } final RewatchOnExpireWatcher wrappedWatcher = new RewatchOnExpireWatcher(this, ActionType.DATA, path, watcher); OperationFuture<NodeData> result = super.getData(path, wrappedWatcher); Futures.addCallback(result, new FutureCallback<NodeData>() { @Override public void onSuccess(NodeData result) { wrappedWatcher.setLastResult(result); } @Override public void onFailure(Throwable t) { // No-op } }); return result; } }
@Override public OperationFuture<Stat> exists(String path, Watcher watcher) { if (watcher == null) { return super.exists(path, null); } final RewatchOnExpireWatcher wrappedWatcher = new RewatchOnExpireWatcher(this, ActionType.EXISTS, path, watcher); OperationFuture<Stat> result = super.exists(path, wrappedWatcher); Futures.addCallback(result, new FutureCallback<Stat>() { @Override public void onSuccess(Stat result) { wrappedWatcher.setLastResult(result); } @Override public void onFailure(Throwable t) { // No-op } }); return result; }
@Override public OperationFuture<NodeData> getData(String path, Watcher watcher) { if (watcher == null) { return super.getData(path, null); } final RewatchOnExpireWatcher wrappedWatcher = new RewatchOnExpireWatcher(this, ActionType.DATA, path, watcher); OperationFuture<NodeData> result = super.getData(path, wrappedWatcher); Futures.addCallback(result, new FutureCallback<NodeData>() { @Override public void onSuccess(NodeData result) { wrappedWatcher.setLastResult(result); } @Override public void onFailure(Throwable t) { // No-op } }); return result; } }
@Override public OperationFuture<NodeChildren> getChildren(String path, Watcher watcher) { if (watcher == null) { return super.getChildren(path, null); } final RewatchOnExpireWatcher wrappedWatcher = new RewatchOnExpireWatcher(this, ActionType.CHILDREN, path, watcher); OperationFuture<NodeChildren> result = super.getChildren(path, wrappedWatcher); Futures.addCallback(result, new FutureCallback<NodeChildren>() { @Override public void onSuccess(NodeChildren result) { wrappedWatcher.setLastResult(result); } @Override public void onFailure(Throwable t) { // No-op } }); return result; }
@Override public OperationFuture<Stat> exists(String path, Watcher watcher) { if (watcher == null) { return super.exists(path, null); } final RewatchOnExpireWatcher wrappedWatcher = new RewatchOnExpireWatcher(this, ActionType.EXISTS, path, watcher); OperationFuture<Stat> result = super.exists(path, wrappedWatcher); Futures.addCallback(result, new FutureCallback<Stat>() { @Override public void onSuccess(Stat result) { wrappedWatcher.setLastResult(result); } @Override public void onFailure(Throwable t) { // No-op } }); return result; }
@Override public OperationFuture<NodeChildren> getChildren(String path, Watcher watcher) { if (watcher == null) { return super.getChildren(path, null); } final RewatchOnExpireWatcher wrappedWatcher = new RewatchOnExpireWatcher(this, ActionType.CHILDREN, path, watcher); OperationFuture<NodeChildren> result = super.getChildren(path, wrappedWatcher); Futures.addCallback(result, new FutureCallback<NodeChildren>() { @Override public void onSuccess(NodeChildren result) { wrappedWatcher.setLastResult(result); } @Override public void onFailure(Throwable t) { // No-op } }); return result; }