Search in sources :

Example 1 with RequestHeader

use of org.apache.zookeeper_voltpatches.proto.RequestHeader in project voltdb by VoltDB.

the class RequestHeader method equals.

@Override
public boolean equals(Object peer_) {
    if (!(peer_ instanceof RequestHeader)) {
        return false;
    }
    if (peer_ == this) {
        return true;
    }
    RequestHeader peer = (RequestHeader) peer_;
    boolean ret = false;
    ret = (xid == peer.xid);
    if (!ret)
        return ret;
    ret = (type == peer.type);
    if (!ret)
        return ret;
    return ret;
}
Also used : RequestHeader(org.apache.zookeeper_voltpatches.proto.RequestHeader)

Example 2 with RequestHeader

use of org.apache.zookeeper_voltpatches.proto.RequestHeader in project voltdb by VoltDB.

the class ZooKeeper method getChildren.

/**
     * The Asynchronous version of getChildren. The request doesn't actually
     * until the asynchronous callback is called.
     *
     * @since 3.3.0
     *
     * @see #getChildren(String, Watcher, Stat)
     */
public void getChildren(final String path, Watcher watcher, Children2Callback cb, Object ctx) {
    verbotenThreadCheck();
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb, clientPath, serverPath, ctx, wcb);
}
Also used : GetChildren2Response(org.apache.zookeeper_voltpatches.proto.GetChildren2Response) ReplyHeader(org.apache.zookeeper_voltpatches.proto.ReplyHeader) GetChildren2Request(org.apache.zookeeper_voltpatches.proto.GetChildren2Request) RequestHeader(org.apache.zookeeper_voltpatches.proto.RequestHeader)

Example 3 with RequestHeader

use of org.apache.zookeeper_voltpatches.proto.RequestHeader in project voltdb by VoltDB.

the class ZooKeeper method create.

/**
     * The Asynchronous version of create. The request doesn't actually until
     * the asynchronous callback is called.
     *
     * @see #create(String, byte[], List, CreateMode)
     */
public void create(final String path, byte[] data, List<ACL> acl, CreateMode createMode, StringCallback cb, Object ctx) {
    verbotenThreadCheck();
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());
    final String serverPath = prependChroot(clientPath);
    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.create);
    CreateRequest request = new CreateRequest();
    CreateResponse response = new CreateResponse();
    ReplyHeader r = new ReplyHeader();
    request.setData(data);
    request.setFlags(createMode.toFlag());
    request.setPath(serverPath);
    request.setAcl(acl);
    cnxn.queuePacket(h, r, request, response, cb, clientPath, serverPath, ctx, null);
}
Also used : ReplyHeader(org.apache.zookeeper_voltpatches.proto.ReplyHeader) CreateRequest(org.apache.zookeeper_voltpatches.proto.CreateRequest) CreateResponse(org.apache.zookeeper_voltpatches.proto.CreateResponse) RequestHeader(org.apache.zookeeper_voltpatches.proto.RequestHeader)

Example 4 with RequestHeader

use of org.apache.zookeeper_voltpatches.proto.RequestHeader in project voltdb by VoltDB.

the class ZooKeeper method getData.

/**
     * 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) {
    verbotenThreadCheck();
    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);
}
Also used : ReplyHeader(org.apache.zookeeper_voltpatches.proto.ReplyHeader) RequestHeader(org.apache.zookeeper_voltpatches.proto.RequestHeader) GetDataResponse(org.apache.zookeeper_voltpatches.proto.GetDataResponse) GetDataRequest(org.apache.zookeeper_voltpatches.proto.GetDataRequest)

Example 5 with RequestHeader

use of org.apache.zookeeper_voltpatches.proto.RequestHeader in project voltdb by VoltDB.

the class ZooKeeper method getChildren.

/**
     * 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 {
    verbotenThreadCheck();
    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();
}
Also used : GetChildren2Response(org.apache.zookeeper_voltpatches.proto.GetChildren2Response) ReplyHeader(org.apache.zookeeper_voltpatches.proto.ReplyHeader) GetChildren2Request(org.apache.zookeeper_voltpatches.proto.GetChildren2Request) RequestHeader(org.apache.zookeeper_voltpatches.proto.RequestHeader)

Aggregations

RequestHeader (org.apache.zookeeper_voltpatches.proto.RequestHeader)24 ReplyHeader (org.apache.zookeeper_voltpatches.proto.ReplyHeader)20 SetDataResponse (org.apache.zookeeper_voltpatches.proto.SetDataResponse)4 AuthPacket (org.apache.zookeeper_voltpatches.proto.AuthPacket)2 CreateRequest (org.apache.zookeeper_voltpatches.proto.CreateRequest)2 CreateResponse (org.apache.zookeeper_voltpatches.proto.CreateResponse)2 DeleteRequest (org.apache.zookeeper_voltpatches.proto.DeleteRequest)2 ExistsRequest (org.apache.zookeeper_voltpatches.proto.ExistsRequest)2 GetACLRequest (org.apache.zookeeper_voltpatches.proto.GetACLRequest)2 GetACLResponse (org.apache.zookeeper_voltpatches.proto.GetACLResponse)2 GetChildren2Request (org.apache.zookeeper_voltpatches.proto.GetChildren2Request)2 GetChildren2Response (org.apache.zookeeper_voltpatches.proto.GetChildren2Response)2 GetChildrenRequest (org.apache.zookeeper_voltpatches.proto.GetChildrenRequest)2 GetChildrenResponse (org.apache.zookeeper_voltpatches.proto.GetChildrenResponse)2 GetDataRequest (org.apache.zookeeper_voltpatches.proto.GetDataRequest)2 GetDataResponse (org.apache.zookeeper_voltpatches.proto.GetDataResponse)2 SetACLRequest (org.apache.zookeeper_voltpatches.proto.SetACLRequest)2 SetACLResponse (org.apache.zookeeper_voltpatches.proto.SetACLResponse)2 SetDataRequest (org.apache.zookeeper_voltpatches.proto.SetDataRequest)2 InputStream (java.io.InputStream)1