use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class SetDataBuilderImpl method pathInForeground.
private Stat pathInForeground(final String path, final byte[] data) throws Exception {
OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("SetDataBuilderImpl-Foreground");
Stat resultStat = RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<Stat>() {
@Override
public Stat call() throws Exception {
return client.getZooKeeper().setData(path, data, version);
}
});
trace.setRequestBytesLength(data).setPath(path).setStat(resultStat).commit();
return resultStat;
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class ConnectionState method process.
@Override
public void process(WatchedEvent event) {
if (LOG_EVENTS) {
log.debug("ConnectState watcher: " + event);
}
final boolean eventTypeNone = event.getType() == Watcher.Event.EventType.None;
if (eventTypeNone) {
boolean wasConnected = isConnected.get();
boolean newIsConnected = checkState(event.getState(), wasConnected);
if (newIsConnected != wasConnected) {
isConnected.set(newIsConnected);
connectionStartMs = System.currentTimeMillis();
}
}
// only wait during tests
if (debugWaitOnExpiredEvent && event.getState() == Event.KeeperState.Expired) {
waitOnExpiredEvent();
}
for (Watcher parentWatcher : parentWatchers) {
OperationTrace trace = new OperationTrace("connection-state-parent-process", tracer.get(), getSessionId());
parentWatcher.process(event);
trace.commit();
}
if (eventTypeNone)
handleState(event.getState());
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class BackgroundSyncImpl method performBackgroundOperation.
@Override
public void performBackgroundOperation(final OperationAndData<String> operationAndData) throws Exception {
final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("BackgroundSyncImpl");
final String data = operationAndData.getData();
client.getZooKeeper().sync(data, new AsyncCallback.VoidCallback() {
@Override
public void processResult(int rc, String path, Object ctx) {
trace.setReturnCode(rc).setRequestBytesLength(data).commit();
CuratorEventImpl event = new CuratorEventImpl(client, CuratorEventType.SYNC, rc, path, null, ctx, null, null, null, null, null);
client.processBackgroundOperation(operationAndData, event);
}
}, context);
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class CreateBuilderImpl method performBackgroundOperation.
@Override
public void performBackgroundOperation(final OperationAndData<PathAndBytes> operationAndData) throws Exception {
try {
final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("CreateBuilderImpl-Background");
final byte[] data = operationAndData.getData().getData();
client.getZooKeeper().create(operationAndData.getData().getPath(), data, acling.getAclList(operationAndData.getData().getPath()), createMode, new AsyncCallback.StringCallback() {
@Override
public void processResult(int rc, String path, Object ctx, String name) {
trace.setReturnCode(rc).setRequestBytesLength(data).setPath(path).commit();
if ((rc == KeeperException.Code.NONODE.intValue()) && createParentsIfNeeded) {
backgroundCreateParentsThenNode(client, operationAndData, operationAndData.getData().getPath(), backgrounding, createParentsAsContainers);
} else {
sendBackgroundResponse(rc, path, ctx, name, operationAndData);
}
}
}, backgrounding.getContext());
} catch (Throwable e) {
backgrounding.checkError(e);
}
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class CreateBuilderImpl method findProtectedNodeInForeground.
private String findProtectedNodeInForeground(final String path) throws Exception {
OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("CreateBuilderImpl-findProtectedNodeInForeground");
String returnPath = RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<String>() {
@Override
public String call() throws Exception {
String foundNode = null;
try {
final ZKPaths.PathAndNode pathAndNode = ZKPaths.getPathAndNode(path);
List<String> children = client.getZooKeeper().getChildren(pathAndNode.getPath(), false);
foundNode = findNode(children, pathAndNode.getPath(), protectedId);
} catch (KeeperException.NoNodeException ignore) {
// ignore
}
return foundNode;
}
});
trace.setPath(path).commit();
return returnPath;
}
Aggregations