ZooKeeper.java 文件源码

java
阅读 38 收藏 0 点赞 0 评论 0

项目:bigstreams 作者:
/**
 * 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);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号