本文整理汇总了Java中org.apache.curator.framework.api.CuratorEventType.CHILDREN属性的典型用法代码示例。如果您正苦于以下问题:Java CuratorEventType.CHILDREN属性的具体用法?Java CuratorEventType.CHILDREN怎么用?Java CuratorEventType.CHILDREN使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.curator.framework.api.CuratorEventType
的用法示例。
在下文中一共展示了CuratorEventType.CHILDREN属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performBackgroundOperation
@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);
}
}
示例2: eventReceived
@Override
public void eventReceived(CuratorFramework client, CuratorEvent event) throws Exception {
if (event.getType() == CuratorEventType.CHILDREN) {
if (event.getChildren().isEmpty()) {
client.getChildren().inBackground(event.getContext()).forPath(event.getPath());
} else {
String path = event.getPath() + "/" + event.getChildren().get(0);
LOG.info("Operations Node registered in ZK. Waiting for transports configration");
client.getData().inBackground(event.getContext()).forPath(path);
}
} else if (event.getType() == CuratorEventType.GET_DATA) {
if (event.getData() == null) {
client.getData().inBackground(event.getContext()).forPath(event.getPath());
} else {
OperationsNodeInfo nodeInfo =
OPERATIONS_NODE_INFO_CONVERTER.fromByteArray(event.getData());
boolean isTransportInitialized = !nodeInfo.getTransports().isEmpty();
if (isTransportInitialized) {
LOG.info("Operations Node updated tarnsports configuration in ZK");
((CountDownLatch) event.getContext()).countDown();
} else {
client.getData().inBackground(event.getContext()).forPath(event.getPath());
}
}
}
}
示例3: performBackgroundOperation
@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);
}