use of org.apache.zookeeper.ZooKeeper in project bookkeeper by apache.
the class ZooKeeperClient method getData.
@Override
public void getData(final String path, final boolean watch, final DataCallback cb, final Object context) {
final Runnable proc = new ZkRetryRunnable(operationRetryPolicy, rateLimiter, getStats) {
final DataCallback dataCb = new DataCallback() {
@Override
public void processResult(int rc, String path, Object ctx, byte[] data, Stat stat) {
ZooWorker worker = (ZooWorker) ctx;
if (allowRetry(worker, rc)) {
backOffAndRetry(that, worker.nextRetryWaitTime());
} else {
cb.processResult(rc, path, context, data, stat);
}
}
};
@Override
void zkRun() {
ZooKeeper zkHandle = zk.get();
if (null == zkHandle) {
ZooKeeperClient.super.getData(path, watch, dataCb, worker);
} else {
zkHandle.getData(path, watch, dataCb, worker);
}
}
@Override
public String toString() {
return String.format("getData (%s, watcher = %s)", path, watch);
}
};
// execute it immediately
proc.run();
}
use of org.apache.zookeeper.ZooKeeper in project bookkeeper by apache.
the class ZooKeeperClient method addAuthInfo.
@Override
public void addAuthInfo(String scheme, byte[] auth) {
ZooKeeper zkHandle = zk.get();
if (null == zkHandle) {
super.addAuthInfo(scheme, auth);
return;
}
zkHandle.addAuthInfo(scheme, auth);
}
use of org.apache.zookeeper.ZooKeeper in project bookkeeper by apache.
the class ZooKeeperClient method getChildren.
@Override
public void getChildren(final String path, final Watcher watcher, final ChildrenCallback cb, final Object context) {
final Runnable proc = new ZkRetryRunnable(operationRetryPolicy, rateLimiter, getChildrenStats) {
final ChildrenCallback childCb = new ChildrenCallback() {
@Override
public void processResult(int rc, String path, Object ctx, List<String> children) {
ZooWorker worker = (ZooWorker) ctx;
if (allowRetry(worker, rc)) {
backOffAndRetry(that, worker.nextRetryWaitTime());
} else {
cb.processResult(rc, path, context, children);
}
}
};
@Override
void zkRun() {
ZooKeeper zkHandle = zk.get();
if (null == zkHandle) {
ZooKeeperClient.super.getChildren(path, watcher, childCb, worker);
} else {
zkHandle.getChildren(path, watcher, childCb, worker);
}
}
@Override
public String toString() {
return String.format("getChildren (%s, watcher = %s)", path, watcher);
}
};
// execute it immediately
proc.run();
}
use of org.apache.zookeeper.ZooKeeper in project bookkeeper by apache.
the class ZooKeeperClient method getChildren.
@Override
public void getChildren(final String path, final boolean watch, final ChildrenCallback cb, final Object context) {
final Runnable proc = new ZkRetryRunnable(operationRetryPolicy, rateLimiter, getChildrenStats) {
final ChildrenCallback childCb = new ChildrenCallback() {
@Override
public void processResult(int rc, String path, Object ctx, List<String> children) {
ZooWorker worker = (ZooWorker) ctx;
if (allowRetry(worker, rc)) {
backOffAndRetry(that, worker.nextRetryWaitTime());
} else {
cb.processResult(rc, path, context, children);
}
}
};
@Override
void zkRun() {
ZooKeeper zkHandle = zk.get();
if (null == zkHandle) {
ZooKeeperClient.super.getChildren(path, watch, childCb, worker);
} else {
zkHandle.getChildren(path, watch, childCb, worker);
}
}
@Override
public String toString() {
return String.format("getChildren (%s, watcher = %s)", path, watch);
}
};
// execute it immediately
proc.run();
}
use of org.apache.zookeeper.ZooKeeper in project bookkeeper by apache.
the class ZooKeeperClient method sync.
@Override
public void sync(final String path, final VoidCallback cb, final Object context) {
final Runnable proc = new ZkRetryRunnable(operationRetryPolicy, rateLimiter, syncStats) {
final VoidCallback vCb = new VoidCallback() {
@Override
public void processResult(int rc, String path, Object ctx) {
ZooWorker worker = (ZooWorker) ctx;
if (allowRetry(worker, rc)) {
backOffAndRetry(that, worker.nextRetryWaitTime());
} else {
cb.processResult(rc, path, context);
}
}
};
@Override
public String toString() {
return String.format("sync (%s)", path);
}
@Override
void zkRun() {
ZooKeeper zkHandle = zk.get();
if (null == zkHandle) {
ZooKeeperClient.super.sync(path, vCb, worker);
} else {
zkHandle.sync(path, vCb, worker);
}
}
};
// execute it immediately
proc.run();
}
Aggregations