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


Java ReplyHeader.getErr方法代码示例

本文整理汇总了Java中org.apache.zookeeper.proto.ReplyHeader.getErr方法的典型用法代码示例。如果您正苦于以下问题:Java ReplyHeader.getErr方法的具体用法?Java ReplyHeader.getErr怎么用?Java ReplyHeader.getErr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.zookeeper.proto.ReplyHeader的用法示例。


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

示例1: getACL

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Return the ACL and stat of the node of the given path.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 *
 * @param path
 *                the given path for the node
 * @param stat
 *                the stat of the node will be copied to this parameter if
 *                not null.
 * @return the ACL array of the given node.
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public List<ACL> getACL(final String path, Stat stat)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.getACL);
    GetACLRequest request = new GetACLRequest();
    request.setPath(serverPath);
    GetACLResponse response = new GetACLResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    if (stat != null) {
        DataTree.copyStat(response.getStat(), stat);
    }
    return response.getAcl();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:40,代码来源:ZooKeeper.java

示例2: setACL

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Set the ACL for the node of the given path if such a node exists and the
 * given aclVersion matches the acl version of the node. Return the stat of the
 * node.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 * <p>
 * A KeeperException with error code KeeperException.BadVersion will be
 * thrown if the given aclVersion does not match the node's aclVersion.
 *
 * @param path the given path for the node
 * @param acl the given acl for the node
 * @param aclVersion the given acl version of the node
 * @return the stat of the node.
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws org.apache.zookeeper.KeeperException.InvalidACLException If the acl is invalide.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public Stat setACL(final String path, List<ACL> acl, int aclVersion)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);
    validateACL(acl);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.setACL);
    SetACLRequest request = new SetACLRequest();
    request.setPath(serverPath);
    request.setAcl(acl);
    request.setVersion(aclVersion);
    SetACLResponse response = new SetACLResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    return response.getStat();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:44,代码来源:ZooKeeper.java

示例3: removeWatches

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
private void removeWatches(int opCode, String path, Watcher watcher,
        WatcherType watcherType, boolean local)
        throws InterruptedException, KeeperException {
    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);

    ReplyHeader r = cnxn.submitRequest(h, request, null, null, wcb);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:21,代码来源:ZooKeeper.java

示例4: getACL

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Return the ACL and stat of the node of the given path.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 *
 * @param path
 *                the given path for the node
 * @param stat
 *                the stat of the node will be copied to this parameter.
 * @return the ACL array of the given node.
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public List<ACL> getACL(final String path, Stat stat)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.getACL);
    GetACLRequest request = new GetACLRequest();
    request.setPath(serverPath);
    GetACLResponse response = new GetACLResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    DataTree.copyStat(response.getStat(), stat);
    return response.getAcl();
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:37,代码来源:ZooKeeper.java

示例5: setACL

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Set the ACL for the node of the given path if such a node exists and the
 * given version matches the version of the node. Return the stat of the
 * node.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 * <p>
 * A KeeperException with error code KeeperException.BadVersion will be
 * thrown if the given version does not match the node's version.
 *
 * @param path
 * @param acl
 * @param version
 * @return the stat of the node.
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws org.apache.zookeeper.KeeperException.InvalidACLException If the acl is invalide.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public Stat setACL(final String path, List<ACL> acl, int version)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.setACL);
    SetACLRequest request = new SetACLRequest();
    request.setPath(serverPath);
    if (acl != null && acl.size() == 0) {
        throw new KeeperException.InvalidACLException();
    }
    request.setAcl(acl);
    request.setVersion(version);
    SetACLResponse response = new SetACLResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    return response.getStat();
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:46,代码来源:ZooKeeper.java

示例6: setACL

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Set the ACL for the node of the given path if such a node exists and the
 * given version matches the version of the node. Return the stat of the
 * node.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 * <p>
 * A KeeperException with error code KeeperException.BadVersion will be
 * thrown if the given version does not match the node's version.
 *
 * @param path
 * @param acl
 * @param version
 * @return the stat of the node.
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws org.apache.zookeeper.KeeperException.InvalidACLException If the acl is invalide.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public Stat setACL(final String path, List<ACL> acl, int version)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.setACL);
    SetACLRequest request = new SetACLRequest();
    request.setPath(serverPath);
    if (acl != null && acl.size() == 0) {
        throw new KeeperException.InvalidACLException(clientPath);
    }
    request.setAcl(acl);
    request.setVersion(version);
    SetACLResponse response = new SetACLResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    return response.getStat();
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:46,代码来源:ZooKeeper.java

示例7: create

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * same as {@link #create(String, byte[], List, CreateMode, Stat)} but
 * allows for specifying a TTL when mode is {@link CreateMode#PERSISTENT_WITH_TTL}
 * or {@link CreateMode#PERSISTENT_SEQUENTIAL_WITH_TTL}. If the znode has not been modified
 * within the given TTL, it will be deleted once it has no children. The TTL unit is
 * milliseconds and must be greater than 0 and less than or equal to
 * {@link EphemeralType#MAX_TTL}.
 */
public String create(final String path, byte data[], List<ACL> acl,
        CreateMode createMode, Stat stat, long ttl)
        throws KeeperException, InterruptedException {
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());
    EphemeralType.validateTTL(createMode, ttl);
    validateACL(acl);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    setCreateHeader(createMode, h);
    Create2Response response = new Create2Response();
    Record record = makeCreateRecord(createMode, serverPath, data, acl, ttl);
    ReplyHeader r = cnxn.submitRequest(h, record, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    if (stat != null) {
        DataTree.copyStat(response.getStat(), stat);
    }
    if (cnxn.chrootPath == null) {
        return response.getPath();
    } else {
        return response.getPath().substring(cnxn.chrootPath.length());
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:37,代码来源:ZooKeeper.java

示例8: delete

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Delete the node with the given path. The call will succeed if such a node
 * exists, and the given version matches the node's version (if the given
 * version is -1, it matches any node's versions).
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if the nodes does not exist.
 * <p>
 * A KeeperException with error code KeeperException.BadVersion will be
 * thrown if the given version does not match the node's version.
 * <p>
 * A KeeperException with error code KeeperException.NotEmpty will be thrown
 * if the node has children.
 * <p>
 * This operation, if successful, will trigger all the watches on the node
 * of the given path left by exists API calls, and the watches on the parent
 * node left by getChildren API calls.
 *
 * @param path
 *                the path of the node to be deleted.
 * @param version
 *                the expected node version.
 * @throws InterruptedException IF the server transaction is interrupted
 * @throws KeeperException If the server signals an error with a non-zero
 *   return code.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public void delete(final String path, int version)
    throws InterruptedException, KeeperException
{
    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);
    ReplyHeader r = cnxn.submitRequest(h, request, null, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:58,代码来源:ZooKeeper.java

示例9: exists

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Return the stat of the node of the given path. Return null if no such a
 * node exists.
 * <p>
 * If the watch is non-null and the call is successful (no exception is thrown),
 * a watch will be left on the node with the given path. The watch will be
 * triggered by a successful operation that creates/delete the node or sets
 * the data on the node.
 *
 * @param path the node path
 * @param watcher explicit watcher
 * @return the stat of the node of the given path; return null if no such a
 *         node exists.
 * @throws KeeperException If the server signals an error
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public Stat exists(final String path, Watcher watcher)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    // the watch contains the un-chroot path
    WatchRegistration wcb = null;
    if (watcher != null) {
        wcb = new ExistsWatchRegistration(watcher, clientPath);
    }

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.exists);
    ExistsRequest request = new ExistsRequest();
    request.setPath(serverPath);
    request.setWatch(watcher != null);
    SetDataResponse response = new SetDataResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, wcb);
    if (r.getErr() != 0) {
        if (r.getErr() == KeeperException.Code.NONODE.intValue()) {
            return null;
        }
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }

    return response.getStat().getCzxid() == -1 ? null : response.getStat();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:49,代码来源:ZooKeeper.java

示例10: getData

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Return the data and the stat of the node of the given path.
 * <p>
 * If the watch is non-null and the call is successful (no exception is
 * thrown), a watch will be left on the node with the given path. The watch
 * will be triggered by a successful operation that sets data on the node, or
 * deletes the node.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 *
 * @param path the given path
 * @param watcher explicit watcher
 * @param stat the stat of the node
 * @return the data of the node
 * @throws KeeperException If the server signals an error with a non-zero error code
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public byte[] getData(final String path, Watcher watcher, Stat stat)
    throws KeeperException, InterruptedException
 {
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    // the watch contains the un-chroot path
    WatchRegistration wcb = null;
    if (watcher != null) {
        wcb = new DataWatchRegistration(watcher, clientPath);
    }

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.getData);
    GetDataRequest request = new GetDataRequest();
    request.setPath(serverPath);
    request.setWatch(watcher != null);
    GetDataResponse response = new GetDataResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, wcb);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    if (stat != null) {
        DataTree.copyStat(response.getStat(), stat);
    }
    return response.getData();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:50,代码来源:ZooKeeper.java

示例11: getConfig

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Return the last committed configuration (as known to the server to which the client is connected)
 * and the stat of the configuration.
 * <p>
 * If the watch is non-null and the call is successful (no exception is
 * thrown), a watch will be left on the configuration node (ZooDefs.CONFIG_NODE). The watch
 * will be triggered by a successful reconfig operation
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if the configuration node doesn't exists.
 *
 * @param watcher explicit watcher
 * @param stat the stat of the configuration node ZooDefs.CONFIG_NODE
 * @return configuration data stored in ZooDefs.CONFIG_NODE
 * @throws KeeperException If the server signals an error with a non-zero error code
 * @throws InterruptedException If the server transaction is interrupted.
 */
public byte[] getConfig(Watcher watcher, Stat stat)
    throws KeeperException, InterruptedException
 {
    final String configZnode = ZooDefs.CONFIG_NODE;
 
    // the watch contains the un-chroot path
    WatchRegistration wcb = null;
    if (watcher != null) {
        wcb = new DataWatchRegistration(watcher, configZnode);
    }

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.getData);
    GetDataRequest request = new GetDataRequest();
    request.setPath(configZnode);
    request.setWatch(watcher != null);
    GetDataResponse response = new GetDataResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, wcb);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
               configZnode);
    }
    if (stat != null) {
        DataTree.copyStat(response.getStat(), stat);
    }
    return response.getData();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:45,代码来源:ZooKeeper.java

示例12: getChildren

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Return the list of the children of the node of the given path.
 * <p>
 * If the watch is non-null and the call is successful (no exception is thrown),
 * a watch will be left on the node with the given path. The watch willbe
 * triggered by a successful operation that deletes the node of the given
 * path or creates/delete a child under the node.
 * <p>
 * The list of children returned is not sorted and no guarantee is provided
 * as to its natural or lexical order.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 *
 * @param path
 * @param watcher explicit watcher
 * @return an unordered array of children of the node with the given path
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public List<String> getChildren(final String path, Watcher watcher)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    // the watch contains the un-chroot path
    WatchRegistration wcb = null;
    if (watcher != null) {
        wcb = new ChildWatchRegistration(watcher, clientPath);
    }

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.getChildren);
    GetChildrenRequest request = new GetChildrenRequest();
    request.setPath(serverPath);
    request.setWatch(watcher != null);
    GetChildrenResponse response = new GetChildrenResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, wcb);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    return response.getChildren();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:49,代码来源:ZooKeeper.java

示例13: getChildren

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * For the given znode path return the stat and children list.
 * <p>
 * If the watch is non-null and the call is successful (no exception is thrown),
 * a watch will be left on the node with the given path. The watch willbe
 * triggered by a successful operation that deletes the node of the given
 * path or creates/delete a child under the node.
 * <p>
 * The list of children returned is not sorted and no guarantee is provided
 * as to its natural or lexical order.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 *
 * @since 3.3.0
 * 
 * @param path
 * @param watcher explicit watcher
 * @param stat stat of the znode designated by path
 * @return an unordered array of children of the node with the given path
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public List<String> getChildren(final String path, Watcher watcher,
        Stat stat)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    // the watch contains the un-chroot path
    WatchRegistration wcb = null;
    if (watcher != null) {
        wcb = new ChildWatchRegistration(watcher, clientPath);
    }

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.getChildren2);
    GetChildren2Request request = new GetChildren2Request();
    request.setPath(serverPath);
    request.setWatch(watcher != null);
    GetChildren2Response response = new GetChildren2Response();
    ReplyHeader r = cnxn.submitRequest(h, request, response, wcb);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    if (stat != null) {
        DataTree.copyStat(response.getStat(), stat);
    }
    return response.getChildren();
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:56,代码来源:ZooKeeper.java

示例14: reconfigure

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Reconfigure - add/remove servers. Return the new configuration.
 * @param joiningServers
 *                a comma separated list of servers being added (incremental reconfiguration)
 * @param leavingServers
 *                a comma separated list of servers being removed (incremental reconfiguration)
 * @param newMembers
 *                a comma separated list of new membership (non-incremental reconfiguration)
 * @param fromConfig
 *                version of the current configuration
 *                (optional - causes reconfiguration to throw an exception if configuration is no longer current)
 * @param stat the stat of /zookeeper/config znode will be copied to this
 *             parameter if not null.
 * @return new configuration
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 */
public byte[] reconfigure(String joiningServers, String leavingServers,
                          String newMembers, long fromConfig, Stat stat) throws KeeperException, InterruptedException {
    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.reconfig);
    ReconfigRequest request = new ReconfigRequest(joiningServers, leavingServers, newMembers, fromConfig);
    GetDataResponse response = new GetDataResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()), "");
    }
    if (stat != null) {
        DataTree.copyStat(response.getStat(), stat);
    }
    return response.getData();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:33,代码来源:ZooKeeperAdmin.java

示例15: setData

import org.apache.zookeeper.proto.ReplyHeader; //导入方法依赖的package包/类
/**
 * Set the data for the node of the given path if such a node exists and the
 * given version matches the version of the node (if the given version is
 * -1, it matches any node's versions). Return the stat of the node.
 * <p>
 * This operation, if successful, will trigger all the watches on the node
 * of the given path left by getData calls.
 * <p>
 * A KeeperException with error code KeeperException.NoNode will be thrown
 * if no node with the given path exists.
 * <p>
 * A KeeperException with error code KeeperException.BadVersion will be
 * thrown if the given version does not match the node's version.
 * <p>
 * The maximum allowable size of the data array is 1 MB (1,048,576 bytes).
 * Arrays larger than this will cause a KeeperException to be thrown.
 *
 * @param path
 *                the path of the node
 * @param data
 *                the data to set
 * @param version
 *                the expected matching version
 * @return the state of the node
 * @throws InterruptedException If the server transaction is interrupted.
 * @throws KeeperException If the server signals an error with a non-zero error code.
 * @throws IllegalArgumentException if an invalid path is specified
 */
public Stat setData(final String path, byte data[], int version)
    throws KeeperException, InterruptedException
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.setData);
    SetDataRequest request = new SetDataRequest();
    request.setPath(serverPath);
    request.setData(data);
    request.setVersion(version);
    SetDataResponse response = new SetDataResponse();
    ReplyHeader r = cnxn.submitRequest(h, request, response, null);
    if (r.getErr() != 0) {
        throw KeeperException.create(KeeperException.Code.get(r.getErr()),
                clientPath);
    }
    return response.getStat();
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:51,代码来源:ZooKeeper.java


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