use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class SetACLBuilderImpl method pathInForeground.
private Stat pathInForeground(final String path) throws Exception {
OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("SetACLBuilderImpl-Foreground");
Stat resultStat = RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<Stat>() {
@Override
public Stat call() throws Exception {
return client.getZooKeeper().setACL(path, acling.getAclList(path), version);
}
});
trace.setPath(path).setStat(resultStat).commit();
return resultStat;
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class SetACLBuilderImpl method performBackgroundOperation.
@Override
public void performBackgroundOperation(final OperationAndData<String> operationAndData) throws Exception {
try {
final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("SetACLBuilderImpl-Background");
String path = operationAndData.getData();
client.getZooKeeper().setACL(path, acling.getAclList(path), version, new AsyncCallback.StatCallback() {
@SuppressWarnings({ "unchecked" })
@Override
public void processResult(int rc, String path, Object ctx, Stat stat) {
trace.setReturnCode(rc).setPath(path).setStat(stat).commit();
CuratorEvent event = new CuratorEventImpl(client, CuratorEventType.SET_ACL, rc, path, null, ctx, stat, null, null, null, null);
client.processBackgroundOperation(operationAndData, event);
}
}, backgrounding.getContext());
} catch (Throwable e) {
backgrounding.checkError(e);
}
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class ExistsBuilderImpl method performBackgroundOperation.
@Override
public void performBackgroundOperation(final OperationAndData<String> operationAndData) throws Exception {
try {
final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("ExistsBuilderImpl-Background");
AsyncCallback.StatCallback callback = new AsyncCallback.StatCallback() {
@Override
public void processResult(int rc, String path, Object ctx, Stat stat) {
trace.setReturnCode(rc).setPath(path).setWithWatcher(watching.getWatcher() != null).setStat(stat).commit();
CuratorEvent event = new CuratorEventImpl(client, CuratorEventType.EXISTS, rc, path, null, ctx, stat, null, null, null, null);
client.processBackgroundOperation(operationAndData, event);
}
};
if (watching.isWatched()) {
client.getZooKeeper().exists(operationAndData.getData(), true, callback, backgrounding.getContext());
} else {
client.getZooKeeper().exists(operationAndData.getData(), watching.getWatcher(), callback, backgrounding.getContext());
}
} catch (Throwable e) {
backgrounding.checkError(e);
}
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class FindAndDeleteProtectedNodeInBackground method 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()) {
// due to namespacing, don't let CreateBuilderImpl.findNode adjust the path
final String node = CreateBuilderImpl.findNode(strings, "/", protectedId);
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);
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class GetChildrenBuilderImpl method 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) {
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);
}
}
Aggregations