當前位置: 首頁>>代碼示例>>Java>>正文


Java AsyncCallback.Children2Callback方法代碼示例

本文整理匯總了Java中org.apache.zookeeper.AsyncCallback.Children2Callback方法的典型用法代碼示例。如果您正苦於以下問題:Java AsyncCallback.Children2Callback方法的具體用法?Java AsyncCallback.Children2Callback怎麽用?Java AsyncCallback.Children2Callback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.zookeeper.AsyncCallback的用法示例。


在下文中一共展示了AsyncCallback.Children2Callback方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: performBackgroundOperation

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
@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);
    }
}
 
開發者ID:apache,項目名稱:curator,代碼行數:36,代碼來源:GetChildrenBuilderImpl.java

示例2: performBackgroundOperation

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
@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);
}
 
開發者ID:apache,項目名稱:curator,代碼行數:45,代碼來源:FindAndDeleteProtectedNodeInBackground.java

示例3: getChildren

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
@Override
public void getChildren(String path, Watcher watcher, AsyncCallback.Children2Callback cb, Object ctx) {
    delegate.getChildren(path, watcher, cb, ctx);
}
 
開發者ID:NGDATA,項目名稱:hbase-indexer,代碼行數:5,代碼來源:ZooKeeperImpl.java

示例4: getChildren

import org.apache.zookeeper.AsyncCallback; //導入方法依賴的package包/類
void getChildren(String path, Watcher watcher, AsyncCallback.Children2Callback cb, Object ctx); 
開發者ID:NGDATA,項目名稱:hbase-indexer,代碼行數:2,代碼來源:ZooKeeperItf.java


注:本文中的org.apache.zookeeper.AsyncCallback.Children2Callback方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。