Java Code Examples for org.apache.zookeeper.AsyncCallback#Children2Callback
The following examples show how to use
org.apache.zookeeper.AsyncCallback#Children2Callback .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GetChildrenBuilderImpl.java From xian with Apache License 2.0 | 5 votes |
@Override public void performBackgroundOperation(final OperationAndData<String> operationAndData) throws Exception { try { final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("GetChildrenBuilderImpl-Background"); AsyncCallback.Children2Callback callback = new AsyncCallback.Children2Callback() { @Override public void processResult(int rc, String path, Object o, List<String> strings, Stat stat) { trace.setReturnCode(rc).setPath(path).setWithWatcher(watching.getWatcher() != null).setStat(stat).commit(); if ( strings == null ) { strings = Lists.newArrayList(); } CuratorEventImpl event = new CuratorEventImpl(client, CuratorEventType.CHILDREN, rc, path, null, o, stat, null, strings, null, null); client.processBackgroundOperation(operationAndData, event); } }; if ( watching.isWatched() ) { client.getZooKeeper().getChildren(operationAndData.getData(), true, callback, backgrounding.getContext()); } else { client.getZooKeeper().getChildren(operationAndData.getData(), watching.getWatcher(), callback, backgrounding.getContext()); } } catch ( Throwable e ) { backgrounding.checkError(e); } }
Example 2
Source File: GetChildrenBuilderImpl.java From curator with Apache License 2.0 | 5 votes |
@Override public void performBackgroundOperation(final OperationAndData<String> operationAndData) throws Exception { try { final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("GetChildrenBuilderImpl-Background"); AsyncCallback.Children2Callback callback = new AsyncCallback.Children2Callback() { @Override public void processResult(int rc, String path, Object o, List<String> strings, Stat stat) { watching.commitWatcher(rc, false); trace.setReturnCode(rc).setPath(path).setWithWatcher(watching.hasWatcher()).setStat(stat).commit(); if ( strings == null ) { strings = Lists.newArrayList(); } CuratorEventImpl event = new CuratorEventImpl(client, CuratorEventType.CHILDREN, rc, path, null, o, stat, null, strings, null, null, null); client.processBackgroundOperation(operationAndData, event); } }; if ( watching.isWatched() ) { client.getZooKeeper().getChildren(operationAndData.getData(), true, callback, backgrounding.getContext()); } else { client.getZooKeeper().getChildren(operationAndData.getData(), watching.getWatcher(operationAndData.getData()), callback, backgrounding.getContext()); } } catch ( Throwable e ) { backgrounding.checkError(e, watching); } }
Example 3
Source File: FindAndDeleteProtectedNodeInBackground.java From xian with Apache License 2.0 | 4 votes |
@Override public void performBackgroundOperation(final OperationAndData<Void> operationAndData) throws Exception { final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("FindAndDeleteProtectedNodeInBackground"); AsyncCallback.Children2Callback callback = new AsyncCallback.Children2Callback() { @Override public void processResult(int rc, String path, Object o, List<String> strings, Stat stat) { trace.setReturnCode(rc).setPath(path).setStat(stat).commit(); if ( debugInsertError.compareAndSet(true, false) ) { rc = KeeperException.Code.CONNECTIONLOSS.intValue(); } if ( rc == KeeperException.Code.OK.intValue() ) { final String node = CreateBuilderImpl.findNode(strings, "/", protectedId); // due to namespacing, don't let CreateBuilderImpl.findNode adjust the path if ( node != null ) { try { String deletePath = client.unfixForNamespace(ZKPaths.makePath(namespaceAdjustedParentPath, node)); client.delete().guaranteed().inBackground().forPath(deletePath); } catch ( Exception e ) { ThreadUtils.checkInterrupted(e); log.error("Could not start guaranteed delete for node: " + node); rc = KeeperException.Code.CONNECTIONLOSS.intValue(); } } } if ( rc != KeeperException.Code.OK.intValue() ) { CuratorEventImpl event = new CuratorEventImpl(client, CuratorEventType.CHILDREN, rc, path, null, o, stat, null, strings, null, null); client.processBackgroundOperation(operationAndData, event); } } }; client.getZooKeeper().getChildren(namespaceAdjustedParentPath, false, callback, null); }
Example 4
Source File: ZookeeperClient.java From ignite with Apache License 2.0 | 4 votes |
/** * @param path Path. * @param watcher Watcher. * @param cb Callback. */ void getChildrenAsync(String path, Watcher watcher, AsyncCallback.Children2Callback cb) { GetChildrenOperation op = new GetChildrenOperation(path, watcher, cb); zk.getChildren(path, watcher, new ChildrenCallbackWrapper(op), null); }
Example 5
Source File: ZookeeperClient.java From ignite with Apache License 2.0 | 4 votes |
/** * @param path Path. * @param watcher Watcher. * @param cb Callback. */ GetChildrenOperation(String path, Watcher watcher, AsyncCallback.Children2Callback cb) { this.path = path; this.watcher = watcher; this.cb = cb; }
Example 6
Source File: FindAndDeleteProtectedNodeInBackground.java From curator with Apache License 2.0 | 4 votes |
@Override public void performBackgroundOperation(final OperationAndData<Void> operationAndData) throws Exception { final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("FindAndDeleteProtectedNodeInBackground"); AsyncCallback.Children2Callback callback = new AsyncCallback.Children2Callback() { @Override public void processResult(int rc, String path, Object o, List<String> strings, Stat stat) { trace.setReturnCode(rc).setPath(path).setStat(stat).commit(); if ( debugInsertError.compareAndSet(true, false) ) { rc = KeeperException.Code.CONNECTIONLOSS.intValue(); } if ( rc == KeeperException.Code.OK.intValue() ) { final String node = CreateBuilderImpl.findNode(strings, "/", protectedId); // due to namespacing, don't let CreateBuilderImpl.findNode adjust the path if ( node != null ) { try { String deletePath = client.unfixForNamespace(ZKPaths.makePath(namespaceAdjustedParentPath, node)); client.delete().guaranteed().inBackground().forPath(deletePath); } catch ( Exception e ) { ThreadUtils.checkInterrupted(e); log.error("Could not start guaranteed delete for node: " + node); rc = KeeperException.Code.CONNECTIONLOSS.intValue(); } } } if ( rc != KeeperException.Code.OK.intValue() ) { CuratorEventImpl event = new CuratorEventImpl(client, CuratorEventType.CHILDREN, rc, path, null, o, stat, null, strings, null, null, null); client.processBackgroundOperation(operationAndData, event); } } }; client.getZooKeeper().getChildren(namespaceAdjustedParentPath, false, callback, null); }
Example 7
Source File: ZooKeeperConnection.java From util with Apache License 2.0 | 4 votes |
public void getChildren(final String path, final Watcher watcher, final AsyncCallback.Children2Callback cb, final Object ctx) { zooKeeper.getChildren(path, watcher, cb, ctx); }
Example 8
Source File: ZooKeeperConnection.java From util with Apache License 2.0 | 4 votes |
public void getChildren(final String path, final boolean watch, final AsyncCallback.Children2Callback cb, final Object ctx) { zooKeeper.getChildren(path, watch, cb, ctx); }
Example 9
Source File: ZooKeeperImpl.java From hbase-indexer with Apache License 2.0 | 4 votes |
@Override public void getChildren(String path, Watcher watcher, AsyncCallback.Children2Callback cb, Object ctx) { delegate.getChildren(path, watcher, cb, ctx); }
Example 10
Source File: ZooKeeperImpl.java From hbase-indexer with Apache License 2.0 | 4 votes |
@Override public void getChildren(String path, boolean watch, AsyncCallback.Children2Callback cb, Object ctx) { delegate.getChildren(path, watch, cb, ctx); }
Example 11
Source File: ZooKeeperItf.java From hbase-indexer with Apache License 2.0 | votes |
void getChildren(String path, Watcher watcher, AsyncCallback.Children2Callback cb, Object ctx);
Example 12
Source File: ZooKeeperItf.java From hbase-indexer with Apache License 2.0 | votes |
void getChildren(String path, boolean watch, AsyncCallback.Children2Callback cb, Object ctx);