use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class SyncBuilderImpl method performBackgroundOperation.
@Override
public void performBackgroundOperation(final OperationAndData<String> operationAndData) throws Exception {
try {
final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("SyncBuilderImpl-Background");
final String path = operationAndData.getData();
String adjustedPath = client.fixForNamespace(path);
AsyncCallback.VoidCallback voidCallback = new AsyncCallback.VoidCallback() {
@Override
public void processResult(int rc, String path, Object ctx) {
trace.setReturnCode(rc).setPath(path).commit();
CuratorEvent event = new CuratorEventImpl(client, CuratorEventType.SYNC, rc, path, path, ctx, null, null, null, null, null);
client.processBackgroundOperation(operationAndData, event);
}
};
client.getZooKeeper().sync(adjustedPath, voidCallback, backgrounding.getContext());
} catch (Throwable e) {
backgrounding.checkError(e);
}
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class ExistsBuilderImpl method pathInForegroundStandard.
private Stat pathInForegroundStandard(final String path) throws Exception {
OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("ExistsBuilderImpl-Foreground");
Stat returnStat = RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<Stat>() {
@Override
public Stat call() throws Exception {
Stat returnStat;
if (watching.isWatched()) {
returnStat = client.getZooKeeper().exists(path, true);
} else {
returnStat = client.getZooKeeper().exists(path, watching.getWatcher());
}
return returnStat;
}
});
trace.setPath(path).setWithWatcher(watching.getWatcher() != null).setStat(returnStat).commit();
return returnStat;
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class ExistsBuilderImpl method pathInForeground.
private Stat pathInForeground(final String path) throws Exception {
if (createParentContainersIfNeeded) {
final String parent = ZKPaths.getPathAndNode(path).getPath();
if (!parent.equals(ZKPaths.PATH_SEPARATOR)) {
OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("ExistsBuilderImpl-Foreground-CreateParents");
RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<Void>() {
@Override
public Void call() throws Exception {
try {
ZKPaths.mkdirs(client.getZooKeeper(), parent, true, client.getAclProvider(), true);
} catch (KeeperException.NodeExistsException e) {
// ignore
} catch (KeeperException.NoNodeException e) {
// ignore
}
return null;
}
});
trace.setPath(path).commit();
}
}
return pathInForegroundStandard(path);
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class GetChildrenBuilderImpl method pathInForeground.
private List<String> pathInForeground(final String path) throws Exception {
OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("GetChildrenBuilderImpl-Foreground");
List<String> children = RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<List<String>>() {
@Override
public List<String> call() throws Exception {
List<String> children;
if (watching.isWatched()) {
children = client.getZooKeeper().getChildren(path, true, responseStat);
} else {
children = client.getZooKeeper().getChildren(path, watching.getWatcher(), responseStat);
}
return children;
}
});
trace.setPath(path).setWithWatcher(watching.getWatcher() != null).setStat(responseStat).commit();
return children;
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class SetDataBuilderImpl method performBackgroundOperation.
@Override
public void performBackgroundOperation(final OperationAndData<PathAndBytes> operationAndData) throws Exception {
try {
final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("SetDataBuilderImpl-Background");
final byte[] data = operationAndData.getData().getData();
client.getZooKeeper().setData(operationAndData.getData().getPath(), data, version, new AsyncCallback.StatCallback() {
@SuppressWarnings({ "unchecked" })
@Override
public void processResult(int rc, String path, Object ctx, Stat stat) {
trace.setReturnCode(rc).setRequestBytesLength(data).setPath(path).setStat(stat).commit();
CuratorEvent event = new CuratorEventImpl(client, CuratorEventType.SET_DATA, rc, path, null, ctx, stat, null, null, null, null);
client.processBackgroundOperation(operationAndData, event);
}
}, backgrounding.getContext());
} catch (Throwable e) {
backgrounding.checkError(e);
}
}
Aggregations