in curator-framework/src/main/java/org/apache/curator/framework/imps/FindAndDeleteProtectedNodeInBackground.java [70:119]
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);
}