Java 类org.apache.zookeeper.proto.GetDataResponse 实例源码

项目:https-github.com-apache-zookeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of getData.
 *
 * @see #getData(String, Watcher, Stat)
 */
public void getData(final String path, Watcher watcher,
        DataCallback cb, Object ctx)
{
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of getConfig.
 *
 * @see #getConfig(Watcher, Stat)
 */
public void getConfig(Watcher watcher,
        DataCallback cb, Object ctx)
{
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
           configZnode, configZnode, ctx, wcb);
}
项目:bigstreams    文件:ZooKeeper.java   
/**
 * The Asynchronous version of getData. The request doesn't actually until
 * the asynchronous callback is called.
 *
 * @see #getData(String, Watcher, Stat)
 */
public void getData(final String path, Watcher watcher,
        DataCallback cb, Object ctx)
{
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:zookeeper-src-learning    文件:ZooKeeper.java   
/**
 * The asynchronous version of getData.
 *
 * @see #getData(String, Watcher, Stat)
 */
public void getData(final String path, Watcher watcher,
        DataCallback cb, Object ctx)
{
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of getData.
 *
 * @see #getData(String, Watcher, Stat)
 */
public void getData(final String path, Watcher watcher,
        DataCallback cb, Object ctx)
{
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of getConfig.
 *
 * @see #getConfig(Watcher, Stat)
 */
public void getConfig(Watcher watcher,
        DataCallback cb, Object ctx)
{
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
           configZnode, configZnode, ctx, wcb);
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of getData.
 *
 * @see #getData(String, Watcher, Stat)
 */
public void getData(final String path, Watcher watcher,
        DataCallback cb, Object ctx)
{
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of getConfig.
 *
 * @see #getConfig(Watcher, Stat)
 */
public void getConfig(Watcher watcher,
        DataCallback cb, Object ctx)
{
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
           configZnode, configZnode, ctx, wcb);
}
项目:zookeeper.dsc    文件:ZooKeeper.java   
/**
 * The Asynchronous version of getData. The request doesn't actually until
 * the asynchronous callback is called.
 *
 * @see #getData(String, Watcher, Stat)
 */
public void getData(final String path, Watcher watcher,
        DataCallback cb, Object ctx)
{
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeperAdmin.java   
/**
 * The Asynchronous version of reconfig.
 *
 * @see #reconfigure
 *
 **/
public void reconfigure(String joiningServers, String leavingServers,
                        String newMembers, long fromConfig, DataCallback cb, Object ctx) {
    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.reconfig);
    ReconfigRequest request = new ReconfigRequest(joiningServers, leavingServers, newMembers, fromConfig);
    GetDataResponse response = new GetDataResponse();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
           ZooDefs.CONFIG_NODE, ZooDefs.CONFIG_NODE, ctx, null);
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeper.java   
/**
 * 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();
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeper.java   
/**
 * 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();
}
项目:bigstreams    文件:ZooKeeper.java   
/**
 * 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();
}
项目:zookeeper-src-learning    文件:ZooKeeper.java   
/**
 * 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();
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * 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();
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * 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();
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * The Asynchronous version of reconfig. 
 *
 * @see #reconfig
 *      
 **/
public void reconfig(String joiningServers, String leavingServers,
    String newMembers, long fromConfig, DataCallback cb, Object ctx)
{
    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.reconfig);       
    ReconfigRequest request = new ReconfigRequest(joiningServers, leavingServers, newMembers, fromConfig);
    GetDataResponse response = new GetDataResponse();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
           ZooDefs.CONFIG_NODE, ZooDefs.CONFIG_NODE, ctx, null);
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * 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();
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * 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();
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * The Asynchronous version of reconfig. 
 *
 * @see #reconfig
 *      
 **/
public void reconfig(String joiningServers, String leavingServers,
    String newMembers, long fromConfig, DataCallback cb, Object ctx)
{
    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.reconfig);       
    ReconfigRequest request = new ReconfigRequest(joiningServers, leavingServers, newMembers, fromConfig);
    GetDataResponse response = new GetDataResponse();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
           ZooDefs.CONFIG_NODE, ZooDefs.CONFIG_NODE, ctx, null);
}
项目:zookeeper.dsc    文件:ZooKeeper.java   
/**
 * 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();
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeperAdmin.java   
/**
 * 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();
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * 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[] reconfig(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();
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * 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[] reconfig(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();
}
项目:zookeeper-lite    文件:IGetDataResponse.java   
public IGetDataResponse() {
    this(new GetDataResponse());
}
项目:zookeeper-lite    文件:IGetDataResponse.java   
public IGetDataResponse(byte[] data, Stat stat) {
    this(new GetDataResponse(data, stat));
}
项目:zookeeper-lite    文件:IGetDataResponse.java   
public IGetDataResponse(GetDataResponse record) {
    super(record);
}