当前位置: 首页>>代码示例>>Java>>正文


Java VoidCallback类代码示例

本文整理汇总了Java中org.apache.zookeeper.AsyncCallback.VoidCallback的典型用法代码示例。如果您正苦于以下问题:Java VoidCallback类的具体用法?Java VoidCallback怎么用?Java VoidCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VoidCallback类属于org.apache.zookeeper.AsyncCallback包,在下文中一共展示了VoidCallback类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: removeWatches

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
private void removeWatches(int opCode, String path, Watcher watcher,
        WatcherType watcherType, boolean local, VoidCallback cb, Object ctx) {
    PathUtils.validatePath(path);
    final String clientPath = path;
    final String serverPath = prependChroot(clientPath);
    WatchDeregistration wcb = new WatchDeregistration(clientPath, watcher,
            watcherType, local, watchManager);

    RequestHeader h = new RequestHeader();
    h.setType(opCode);
    Record request = getRemoveWatchesRequest(opCode, watcherType,
            serverPath);

    cnxn.queuePacket(h, new ReplyHeader(), request, null, cb, clientPath,
            serverPath, ctx, null, wcb);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:17,代码来源:ZooKeeper.java

示例2: testSync

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
@Test
public void testSync() throws Exception {
    complete = false;
    create2EmptyNode(zkClient, PARENT_PATH);
    VoidCallback onSync = new VoidCallback() {
        @Override
        public void processResult(int rc, String path, Object ctx) {
            complete = true;
            callComplete.countDown();
        }
    };
    zkClient.sync(PARENT_PATH, onSync, null);
    callComplete.await(30, TimeUnit.SECONDS);
    Assert.assertTrue(
        String.format("%s Sync completed", serverState),
        complete);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:18,代码来源:QuorumRequestPipelineTest.java

示例3: delete

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
/**
 * @see org.apache.zookeeper.ZooKeeper#delete(String path, int version , VoidCallback cb , Object ctx)
 */
public void delete(final String path, final int version, final VoidCallback cb, final Object ctx)
                                                                                                 throws InterruptedException,
                                                                                                 KeeperException {
    retryOperation(new ZooKeeperOperation() {

        public Object execute() throws KeeperException, InterruptedException {
            zookeeper.delete(path, version, cb, ctx);
            return null;
        }
    });
}
 
开发者ID:luoyaogui,项目名称:otter-G,代码行数:15,代码来源:ZooKeeperx.java

示例4: delete

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
/**
 * The asynchronous version of delete.
 *
 * @see #delete(String, int)
 */
public void delete(final String path, int version, VoidCallback cb,
        Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath;

    // maintain semantics even in chroot case
    // specifically - root cannot be deleted
    // I think this makes sense even in chroot case.
    if (clientPath.equals("/")) {
        // a bit of a hack, but delete(/) will never succeed and ensures
        // that the same semantics are maintained
        serverPath = clientPath;
    } else {
        serverPath = prependChroot(clientPath);
    }

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.delete);
    DeleteRequest request = new DeleteRequest();
    request.setPath(serverPath);
    request.setVersion(version);
    cnxn.queuePacket(h, new ReplyHeader(), request, null, cb, clientPath,
            serverPath, ctx, null);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:33,代码来源:ZooKeeper.java

示例5: sync

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
/**
 * Asynchronous sync. Flushes channel between process and leader.
 * @param path
 * @param cb a handler for the callback
 * @param ctx context to be provided to the callback
 * @throws IllegalArgumentException if an invalid path is specified
 */
public void sync(final String path, VoidCallback cb, Object ctx){
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.sync);
    SyncRequest request = new SyncRequest();
    SyncResponse response = new SyncResponse();
    request.setPath(serverPath);
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, null);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:22,代码来源:ZooKeeper.java

示例6: removeAllWatches

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
/**
 * The asynchronous version of removeAllWatches.
 *
 * @see #removeAllWatches
 */
public void removeAllWatches(String path, WatcherType watcherType,
        boolean local, VoidCallback cb, Object ctx) {

    removeWatches(ZooDefs.OpCode.removeWatches, path, null,
            watcherType, local, cb, ctx);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:12,代码来源:ZooKeeper.java

示例7: deleteRecursive

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
/**
 * Recursively delete the node with the given path. (async version).
 * 
 * <p>
 * Important: All versions, of all nodes, under the given node are deleted.
 * <p>
 * If there is an error with deleting one of the sub-nodes in the tree, 
 * this operation would abort and would be the responsibility of the app to handle the same.
 * <p>
 * 
 * @throws IllegalArgumentException if an invalid path is specified
 */
public void deleteRecursive(final String pathRoot, VoidCallback cb,
    Object ctx)
    throws InterruptedException, KeeperException
{
    PathUtils.validatePath(pathRoot);
  
    List<String> tree = this.listSubTreeBFS(pathRoot);
    LOG.debug("Deleting " + tree);
    LOG.debug("Deleting " + tree.size() + " subnodes ");
    for (int i = tree.size() - 1; i >= 0 ; --i) {
        //Delete the leaves first and eventually get rid of the root
        this.delete(tree.get(i), -1, cb, ctx); //Delete all versions of the node with -1.
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:27,代码来源:ZooKeeper.java

示例8: delete

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
/**
 * The Asynchronous version of delete. The request doesn't actually until
 * the asynchronous callback is called.
 *
 * @see #delete(String, int)
 */
public void delete(final String path, int version, VoidCallback cb,
        Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath;

    // maintain semantics even in chroot case
    // specifically - root cannot be deleted
    // I think this makes sense even in chroot case.
    if (clientPath.equals("/")) {
        // a bit of a hack, but delete(/) will never succeed and ensures
        // that the same semantics are maintained
        serverPath = clientPath;
    } else {
        serverPath = prependChroot(clientPath);
    }

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.delete);
    DeleteRequest request = new DeleteRequest();
    request.setPath(serverPath);
    request.setVersion(version);
    cnxn.queuePacket(h, new ReplyHeader(), request, null, cb, clientPath,
            serverPath, ctx, null);
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:34,代码来源:ZooKeeper.java

示例9: sync

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
@Override
public void sync(String path, VoidCallback cb, Object ctx) {
    executor.execute(() -> {
        if (getProgrammedFailStatus()) {
            cb.processResult(failReturnCode.intValue(), path, ctx);
            return;
        } else if (stopped) {
            cb.processResult(KeeperException.Code.ConnectionLoss, path, ctx);
            return;
        }

        cb.processResult(0, path, ctx);
    });

}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:16,代码来源:MockZooKeeper.java

示例10: delete

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
@Override
public void delete(final String path, int version, final VoidCallback cb, final Object ctx) {
    mutex.lock();
    if (executor.isShutdown()) {
        mutex.unlock();
        cb.processResult(KeeperException.Code.SESSIONEXPIRED.intValue(), path, ctx);
        return;
    }

    final Set<Watcher> toNotifyDelete = Sets.newHashSet();
    toNotifyDelete.addAll(watchers.get(path));

    final Set<Watcher> toNotifyParent = Sets.newHashSet();
    final String parent = path.substring(0, path.lastIndexOf("/"));
    if (!parent.isEmpty()) {
        toNotifyParent.addAll(watchers.get(parent));
    }

    executor.execute(() -> {
        mutex.lock();

        if (getProgrammedFailStatus()) {
            mutex.unlock();
            cb.processResult(failReturnCode.intValue(), path, ctx);
        } else if (stopped) {
            mutex.unlock();
            cb.processResult(KeeperException.Code.CONNECTIONLOSS.intValue(), path, ctx);
        } else if (!tree.containsKey(path)) {
            mutex.unlock();
            cb.processResult(KeeperException.Code.NONODE.intValue(), path, ctx);
        } else if (hasChildren(path)) {
            mutex.unlock();
            cb.processResult(KeeperException.Code.NOTEMPTY.intValue(), path, ctx);
        } else {
            if (version != -1) {
                int currentVersion = tree.get(path).second;
                if (version != currentVersion) {
                    cb.processResult(KeeperException.Code.BADVERSION.intValue(), path, ctx);
                    return;
                }
            }

            tree.remove(path);

            mutex.unlock();
            cb.processResult(0, path, ctx);

            toNotifyDelete.forEach(watcher -> watcher
                    .process(new WatchedEvent(EventType.NodeDeleted, KeeperState.SyncConnected, path)));
            toNotifyParent.forEach(watcher -> watcher
                    .process(new WatchedEvent(EventType.NodeChildrenChanged, KeeperState.SyncConnected, parent)));
        }
    });

    watchers.removeAll(path);
    mutex.unlock();
}
 
开发者ID:apache,项目名称:incubator-pulsar,代码行数:58,代码来源:MockZooKeeper.java

示例11: deleteRecursive

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
/**
 * Recursively delete the node with the given path. (async version).
 * 
 * <p>
 * Important: All versions, of all nodes, under the given node are deleted.
 * <p>
 * If there is an error with deleting one of the sub-nodes in the tree, 
 * this operation would abort and would be the responsibility of the app to handle the same.
 * <p>
 * @param zk the zookeeper handle
 * @param pathRoot the path to be deleted
 * @param cb call back method
 * @param ctx the context the callback method is called with
 * @throws IllegalArgumentException if an invalid path is specified
 */
public static void deleteRecursive(ZooKeeper zk, final String pathRoot, VoidCallback cb,
    Object ctx)
    throws InterruptedException, KeeperException
{
    PathUtils.validatePath(pathRoot);
  
    List<String> tree = listSubTreeBFS(zk, pathRoot);
    LOG.debug("Deleting " + tree);
    LOG.debug("Deleting " + tree.size() + " subnodes ");
    for (int i = tree.size() - 1; i >= 0 ; --i) {
        //Delete the leaves first and eventually get rid of the root
        zk.delete(tree.get(i), -1, cb, ctx); //Delete all versions of the node with -1.
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:30,代码来源:ZKUtil.java

示例12: deleteRecursive

import org.apache.zookeeper.AsyncCallback.VoidCallback; //导入依赖的package包/类
/**
 * Recursively delete the node with the given path. (async version).
 *
 * <p>
 * Important: All versions, of all nodes, under the given node are deleted.
 * <p>
 * If there is an error with deleting one of the sub-nodes in the tree,
 * this operation would abort and would be the responsibility of the app to handle the same.
 * <p>
 * @param zk the zookeeper handle
 * @param pathRoot the path to be deleted
 * @param cb call back method
 * @param ctx the context the callback method is called with
 * @throws IllegalArgumentException if an invalid path is specified
 */
public static void deleteRecursive(ZooKeeper zk, final String pathRoot, VoidCallback cb,
    Object ctx)
    throws InterruptedException, KeeperException
{
    PathUtils.validatePath(pathRoot);

    List<String> tree = listSubTreeBFS(zk, pathRoot);
    LOG.debug("Deleting " + tree);
    LOG.debug("Deleting " + tree.size() + " subnodes ");
    for (int i = tree.size() - 1; i >= 0 ; --i) {
        //Delete the leaves first and eventually get rid of the root
        zk.delete(tree.get(i), -1, cb, ctx); //Delete all versions of the node with -1.
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:30,代码来源:ZKUtil.java


注:本文中的org.apache.zookeeper.AsyncCallback.VoidCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。