use of org.apache.curator.drivers.OperationTrace in project fabric8 by jboss-fuse.
the class CuratorZookeeperClient method blockUntilConnectedOrTimedOut.
/**
* This method blocks until the connection to ZK succeeds. Use with caution. The block
* will timeout after the connection timeout (as passed to the constructor) has elapsed
*
* @return true if the connection succeeded, false if not
* @throws InterruptedException interrupted while waiting
*/
public boolean blockUntilConnectedOrTimedOut() throws InterruptedException {
Preconditions.checkState(started.get(), "Client is not started");
log.debug("blockUntilConnectedOrTimedOut() start");
OperationTrace trace = startAdvancedTracer("blockUntilConnectedOrTimedOut");
internalBlockUntilConnectedOrTimedOut();
trace.commit();
boolean localIsConnected = state.isConnected();
log.debug("blockUntilConnectedOrTimedOut() end. isConnected: " + localIsConnected);
return localIsConnected;
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class DeleteBuilderImpl method performBackgroundOperation.
@Override
public void performBackgroundOperation(final OperationAndData<String> operationAndData) throws Exception {
try {
final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("DeleteBuilderImpl-Background");
client.getZooKeeper().delete(operationAndData.getData(), version, new AsyncCallback.VoidCallback() {
@Override
public void processResult(int rc, String path, Object ctx) {
trace.setReturnCode(rc).setPath(path).commit();
if ((rc == KeeperException.Code.NOTEMPTY.intValue()) && deletingChildrenIfNeeded) {
backgroundDeleteChildrenThenNode(operationAndData);
} else {
CuratorEvent event = new CuratorEventImpl(client, CuratorEventType.DELETE, rc, path, null, ctx, null, 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 DeleteBuilderImpl method pathInForeground.
private void pathInForeground(final String path, String unfixedPath) throws Exception {
OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("DeleteBuilderImpl-Foreground");
try {
RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<Void>() {
@Override
public Void call() throws Exception {
try {
client.getZooKeeper().delete(path, version);
} catch (KeeperException.NotEmptyException e) {
if (deletingChildrenIfNeeded) {
ZKPaths.deleteChildren(client.getZooKeeper(), path, true);
} else {
throw e;
}
}
return null;
}
});
} catch (Exception e) {
ThreadUtils.checkInterrupted(e);
// Only retry a guaranteed delete if it's a retryable error
if ((RetryLoop.isRetryException(e) || (e instanceof InterruptedException)) && guaranteed) {
client.getFailedDeleteManager().addFailedDelete(unfixedPath);
}
throw e;
}
trace.setPath(path).commit();
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class GetACLBuilderImpl method performBackgroundOperation.
@Override
public void performBackgroundOperation(final OperationAndData<String> operationAndData) throws Exception {
try {
final OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("GetACLBuilderImpl-Background");
AsyncCallback.ACLCallback callback = new AsyncCallback.ACLCallback() {
@Override
public void processResult(int rc, String path, Object ctx, List<ACL> acl, Stat stat) {
trace.setReturnCode(rc).setPath(path).setStat(stat).commit();
CuratorEventImpl event = new CuratorEventImpl(client, CuratorEventType.GET_ACL, rc, path, null, ctx, stat, null, null, null, acl);
client.processBackgroundOperation(operationAndData, event);
}
};
client.getZooKeeper().getACL(operationAndData.getData(), responseStat, callback, backgrounding.getContext());
} catch (Throwable e) {
backgrounding.checkError(e);
}
}
use of org.apache.curator.drivers.OperationTrace in project xian by happyyangyuan.
the class GetACLBuilderImpl method pathInForeground.
private List<ACL> pathInForeground(final String path) throws Exception {
OperationTrace trace = client.getZookeeperClient().startAdvancedTracer("GetACLBuilderImpl-Foreground");
List<ACL> result = RetryLoop.callWithRetry(client.getZookeeperClient(), new Callable<List<ACL>>() {
@Override
public List<ACL> call() throws Exception {
return client.getZooKeeper().getACL(path, responseStat);
}
});
trace.setPath(path).setStat(responseStat).commit();
return result;
}
Aggregations