Java Code Examples for org.apache.zookeeper.AsyncCallback#VoidCallback

The following examples show how to use org.apache.zookeeper.AsyncCallback#VoidCallback . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ContentionStrategy.java    From opensharding-spi-impl with Apache License 2.0 5 votes vote down vote up
@Override
public final void deleteOnlyCurrent(final String key, final AsyncCallback.VoidCallback callback, final Object ctx) throws KeeperException, InterruptedException {
    getProvider().executeContention(new LeaderElection() {
        
        @Override
        public void action() throws KeeperException, InterruptedException {
            getProvider().delete(getProvider().getRealPath(key), callback, ctx);
        }
    });
}
 
Example 2
Source File: UsualClient.java    From opensharding-spi-impl with Apache License 2.0 5 votes vote down vote up
@Override
public void deleteOnlyCurrent(final String key, final AsyncCallback.VoidCallback callback, final Object ctx) throws KeeperException, InterruptedException {
    if (getRootNode().equals(key)) {
        deleteNamespace();
        return;
    }
    execStrategy.deleteOnlyCurrent(key, callback, ctx);
}
 
Example 3
Source File: RemoveWatchesBuilderImpl.java    From curator with Apache License 2.0 5 votes vote down vote up
@Override
public void performBackgroundOperation(final OperationAndData<String> operationAndData)
        throws Exception
{
    try
    {
        final TimeTrace   trace = client.getZookeeperClient().startTracer("RemoteWatches-Background");

        AsyncCallback.VoidCallback callback = new AsyncCallback.VoidCallback()
        {
            @Override
            public void processResult(int rc, String path, Object ctx)
            {
                trace.commit();
                CuratorEvent event = new CuratorEventImpl(client, CuratorEventType.REMOVE_WATCHES, rc, path, null, ctx, null, null, null, null, null, null);
                client.processBackgroundOperation(operationAndData, event);
            }
        };

        ZooKeeper zkClient = client.getZooKeeper();
        NamespaceWatcher namespaceWatcher = makeNamespaceWatcher(operationAndData.getData());
        if(namespaceWatcher == null)
        {
            zkClient.removeAllWatches(operationAndData.getData(), watcherType, local, callback, operationAndData.getContext());
        }
        else
        {
            zkClient.removeWatches(operationAndData.getData(), namespaceWatcher, watcherType, local, callback, operationAndData.getContext());
        }
    }
    catch ( Throwable e )
    {
        backgrounding.checkError(e, null);
    }
}
 
Example 4
Source File: BkHelper.java    From tutorials with MIT License 5 votes vote down vote up
public static void collectLedgers(BookKeeper bk, long ledgerId, AsyncCallback.VoidCallback cb, Map<Long, LedgerMetadata> ledgers) {
    try {
        bk.getLedgerManager()
          .readLedgerMetadata(ledgerId)
          .thenAccept((v) -> {
              LOG.debug("Got ledger metadata");
              ledgers.put(ledgerId, v.getValue());
          })
          .thenAccept((v) -> {
              cb.processResult(BKException.Code.OK, null, null);
          });
    } catch (Exception ex) {
        throw new RuntimeException(ex);
    }
}
 
Example 5
Source File: CacheClient.java    From opensharding-spi-impl with Apache License 2.0 4 votes vote down vote up
@Override
public void deleteOnlyCurrent(final String key, final AsyncCallback.VoidCallback callback, final Object ctx) throws KeeperException, InterruptedException {
    super.deleteOnlyCurrent(key, callback, ctx);
    pathTree.delete(PathUtil.getRealPath(getRootNode(), key));
}
 
Example 6
Source File: BaseZookeeperProvider.java    From opensharding-spi-impl with Apache License 2.0 4 votes vote down vote up
@Override
public final void delete(final String key, final AsyncCallback.VoidCallback callback, final Object ctx) {
    holder.getZooKeeper().delete(key, ZookeeperConstants.VERSION, callback, ctx);
}
 
Example 7
Source File: UsualStrategy.java    From opensharding-spi-impl with Apache License 2.0 4 votes vote down vote up
@Override
public void deleteOnlyCurrent(final String key, final AsyncCallback.VoidCallback callback, final Object ctx) throws KeeperException, InterruptedException {
    getProvider().delete(getProvider().getRealPath(key), callback, ctx);
}
 
Example 8
Source File: RecoverableZooKeeper.java    From hbase with Apache License 2.0 4 votes vote down vote up
public void sync(String path, AsyncCallback.VoidCallback cb, Object ctx) throws KeeperException {
  checkZk().sync(path, cb, ctx);
}
 
Example 9
Source File: ZooKeeperConnection.java    From util with Apache License 2.0 4 votes vote down vote up
public void delete(final String path, final int version, final AsyncCallback.VoidCallback cb, final Object ctx) {
    zooKeeper.delete(path, version, cb, ctx);
}
 
Example 10
Source File: ZooKeeperConnection.java    From util with Apache License 2.0 4 votes vote down vote up
public void sync(final String path, final AsyncCallback.VoidCallback cb, final Object ctx) {
    zooKeeper.sync(path, cb, ctx);
}
 
Example 11
Source File: ZooKeeperImpl.java    From hbase-indexer with Apache License 2.0 4 votes vote down vote up
@Override
public void delete(String path, int version, AsyncCallback.VoidCallback cb, Object ctx) {
    delegate.delete(path, version, cb, ctx);
}
 
Example 12
Source File: ZooKeeperImpl.java    From hbase-indexer with Apache License 2.0 4 votes vote down vote up
@Override
public void sync(String path, AsyncCallback.VoidCallback cb, Object ctx) {
    delegate.sync(path, cb, ctx);
}
 
Example 13
Source File: IZookeeperAction.java    From opensharding-spi-impl with Apache License 2.0 2 votes vote down vote up
/**
 * Only delete target node..
 *
 * @param key key
 * @param callback callback
 * @param ctx context
 * @throws KeeperException zookeeper exception
 * @throws InterruptedException interrupted exception
 */
void deleteOnlyCurrent(String key, AsyncCallback.VoidCallback callback, Object ctx) throws KeeperException, InterruptedException;
 
Example 14
Source File: IZookeeperProvider.java    From opensharding-spi-impl with Apache License 2.0 2 votes vote down vote up
/**
 * Only delete target node.
 *
 * @param key key
 * @param callback callback
 * @param ctx ctx
 * @throws KeeperException zookeeper exception
 * @throws InterruptedException interrupted exception
 */
void delete(String key, AsyncCallback.VoidCallback callback, Object ctx) throws KeeperException, InterruptedException;
 
Example 15
Source File: ZooKeeperItf.java    From hbase-indexer with Apache License 2.0 votes vote down vote up
void delete(String path, int version, AsyncCallback.VoidCallback cb, Object ctx); 
Example 16
Source File: ZooKeeperItf.java    From hbase-indexer with Apache License 2.0 votes vote down vote up
void sync(String path, AsyncCallback.VoidCallback cb, Object ctx);