@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; } }
public void sync(String path, AsyncCallback.VoidCallback cb, Object ctx) throws KeeperException { checkZk().sync(path, cb, null); }
public void sync() { zk.sync(path, this, toString()); }
LOG.info("async wrote {}{}", root, i); if (issueSync) { client.sync(root + "0", null, null);
zk.sync(path, new AsyncCallback.VoidCallback() { @Override public void processResult(int rc, String path, Object ctx) {
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; }
CreateMode.PERSISTENT, (Create2Callback)this, results); zk.sync("/test", this, results); for(int i = 0; i < 100; i++) zk.delete("/test" + i, 0, this, results);
} 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;
try { final ZooKeeper zk = zkc.get(); zk.sync(nsRootPath, new AsyncCallback.VoidCallback() { @Override public void processResult(int syncRc, String syncPath, Object ctx) {
@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()); }
zk.sync("/", null, null); zk.setData("/obstest", "test2".getBytes(), -1); zk.getChildren("/", false);
try { final ZooKeeper zk = zooKeeperClient.get(); zk.sync(logMetadata.getLogSegmentsPath(), new AsyncCallback.VoidCallback() { @Override public void processResult(int syncRc, String path, Object syncCtx) {
followerZK.sync(nodePath, cb, null); cb.sync.await(CONNECTION_TIMEOUT, TimeUnit.MILLISECONDS);
@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); } }
@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 ); } }
@Override Void run() throws KeeperException, InterruptedException { zkClient.sync(pathForSync, cb, null); return null; } }.runWithRetries();
@Override public void sync(final String path, AsyncCallback.VoidCallback cb, Object ctx) { _zk.sync(path, cb, ctx); }
@Override Void run() throws KeeperException, InterruptedException { zkClient.sync(pathForSync, cb, null); return null; } }.runWithRetries();
@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); } }
@Override public void sync(String path, AsyncCallback.VoidCallback cb, Object ctx) { getZk().sync(path, cb, ctx); }