本文整理了Java中org.apache.zookeeper.ZooKeeper.sync()
方法的一些代码示例,展示了ZooKeeper.sync()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZooKeeper.sync()
方法的具体详情如下:
包路径:org.apache.zookeeper.ZooKeeper
类名称:ZooKeeper
方法名:sync
[英]Asynchronous sync. Flushes channel between process and leader.
[中]异步同步。刷新流程和领导者之间的通道。
代码示例来源:origin: apache/zookeeper
@Override
public boolean exec() throws CliException {
String path = args[1];
try {
zk.sync(path, new AsyncCallback.VoidCallback() {
public void processResult(int rc, String path, Object ctx) {
out.println("Sync returned " + rc);
}
}, null);
} catch (IllegalArgumentException ex) {
throw new MalformedPathException(ex.getMessage());
}
return false;
}
}
代码示例来源:origin: apache/hbase
public void sync(String path, AsyncCallback.VoidCallback cb, Object ctx) throws KeeperException {
checkZk().sync(path, cb, null);
}
代码示例来源:origin: apache/zookeeper
public void sync() {
zk.sync(path, this, toString());
}
代码示例来源:origin: apache/zookeeper
LOG.info("async wrote {}{}", root, i);
if (issueSync) {
client.sync(root + "0", null, null);
代码示例来源:origin: twitter/distributedlog
zk.sync(path, new AsyncCallback.VoidCallback() {
@Override
public void processResult(int rc, String path, Object ctx) {
代码示例来源:origin: twitter/distributedlog
Future<Set<URI>> fetchSubNamespaces(final Watcher watcher) {
final Promise<Set<URI>> promise = new Promise<Set<URI>>();
try {
zkc.get().sync(this.zkSubnamespacesPath, new AsyncCallback.VoidCallback() {
@Override
public void processResult(int rc, String path, Object ctx) {
if (Code.OK.intValue() == rc) {
fetchSubNamespaces(watcher, promise);
} else {
promise.setException(KeeperException.create(Code.get(rc)));
}
}
}, null);
} catch (ZooKeeperClient.ZooKeeperConnectionException e) {
promise.setException(e);
} catch (InterruptedException e) {
promise.setException(e);
}
return promise;
}
代码示例来源:origin: apache/zookeeper
CreateMode.PERSISTENT, (Create2Callback)this, results);
zk.sync("/test", this, results);
for(int i = 0; i < 100; i++)
zk.delete("/test" + i, 0, this, results);
代码示例来源:origin: org.apache.zookeeper/zookeeper
} else if (cmd.equals("sync") && args.length >= 2) {
path = args[1];
zk.sync(path, new AsyncCallback.VoidCallback() { public void processResult(int rc, String path, Object ctx) { System.out.println("Sync returned " + rc); } }, null );
} else if (cmd.equals("addauth") && args.length >=2 ) {
byte[] b = null;
代码示例来源:origin: twitter/distributedlog
try {
final ZooKeeper zk = zkc.get();
zk.sync(nsRootPath, new AsyncCallback.VoidCallback() {
@Override
public void processResult(int syncRc, String syncPath, Object ctx) {
代码示例来源:origin: apache/zookeeper
@Test
public void testNoWatchesTriggeredForFailedMultiRequest() throws InterruptedException, KeeperException {
HasTriggeredWatcher watcher = new HasTriggeredWatcher();
zk.getChildren("/", watcher);
try {
multi(zk, Arrays.asList(
Op.create("/t", new byte[0], Ids.OPEN_ACL_UNSAFE, CreateMode.PERSISTENT),
Op.delete("/nonexisting", -1)
));
fail("expected previous multi op to fail!");
} catch (KeeperException.NoNodeException e) {
// expected
}
SyncCallback cb = new SyncCallback();
zk.sync("/", cb, null);
// by waiting for the callback we're assured that the event queue is flushed
cb.done.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
assertEquals(1, watcher.triggered.getCount());
}
代码示例来源:origin: apache/zookeeper
zk.sync("/", null, null);
zk.setData("/obstest", "test2".getBytes(), -1);
zk.getChildren("/", false);
代码示例来源:origin: twitter/distributedlog
try {
final ZooKeeper zk = zooKeeperClient.get();
zk.sync(logMetadata.getLogSegmentsPath(), new AsyncCallback.VoidCallback() {
@Override
public void processResult(int syncRc, String path, Object syncCtx) {
代码示例来源:origin: apache/zookeeper
followerZK.sync(nodePath, cb, null);
cb.sync.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
代码示例来源:origin: apache/accumulo
@Override
public void sync(final String path) throws KeeperException, InterruptedException {
final AtomicInteger rc = new AtomicInteger();
final CountDownLatch waiter = new CountDownLatch(1);
getZooKeeper().sync(path, (code, arg1, arg2) -> {
rc.set(code);
waiter.countDown();
}, null);
waiter.await();
Code code = Code.get(rc.get());
if (code != KeeperException.Code.OK) {
throw KeeperException.create(code);
}
}
代码示例来源:origin: org.apache.curator/curator-framework
@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, null);
client.processBackgroundOperation(operationAndData, event);
}
},
context
);
}
}
代码示例来源:origin: ch.cern.hadoop/hadoop-yarn-server-resourcemanager
@Override
Void run() throws KeeperException, InterruptedException {
zkClient.sync(pathForSync, cb, null);
return null;
}
}.runWithRetries();
代码示例来源:origin: com.linkedin.pegasus/d2
@Override
public void sync(final String path, AsyncCallback.VoidCallback cb, Object ctx)
{
_zk.sync(path, cb, ctx);
}
代码示例来源:origin: com.github.jiayuhan-it/hadoop-yarn-server-resourcemanager
@Override
Void run() throws KeeperException, InterruptedException {
zkClient.sync(pathForSync, cb, null);
return null;
}
}.runWithRetries();
代码示例来源:origin: org.apache.curator/curator-framework
@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, null);
client.processBackgroundOperation(operationAndData, event);
}
};
client.getZooKeeper().sync(adjustedPath, voidCallback, backgrounding.getContext());
}
catch ( Throwable e )
{
backgrounding.checkError(e, null);
}
}
代码示例来源:origin: org.pongasoft/org.linkedin.zookeeper-impl
@Override
public void sync(String path, AsyncCallback.VoidCallback cb, Object ctx)
{
getZk().sync(path, cb, ctx);
}
内容来源于网络,如有侵权,请联系作者删除!