Search in sources :

Example 1 with MockPacket

use of org.apache.zookeeper.MockPacket in project zookeeper by apache.

the class WatchLeakTest method createWatchesMessage.

/**
     * Create a watches message with a single watch on /
     *
     * @return a message that attempts to set 1 watch on /
     */
private ByteBuffer createWatchesMessage() {
    List<String> dataWatches = new ArrayList<String>(1);
    dataWatches.add("/");
    List<String> existWatches = Collections.emptyList();
    List<String> childWatches = Collections.emptyList();
    SetWatches sw = new SetWatches(1L, dataWatches, existWatches, childWatches);
    RequestHeader h = new RequestHeader();
    h.setType(ZooDefs.OpCode.setWatches);
    h.setXid(-8);
    MockPacket p = new MockPacket(h, new ReplyHeader(), sw, null, null);
    return p.createAndReturnBB();
}
Also used : ReplyHeader(org.apache.zookeeper.proto.ReplyHeader) SetWatches(org.apache.zookeeper.proto.SetWatches) ArrayList(java.util.ArrayList) RequestHeader(org.apache.zookeeper.proto.RequestHeader) MockPacket(org.apache.zookeeper.MockPacket)

Example 2 with MockPacket

use of org.apache.zookeeper.MockPacket in project zookeeper by apache.

the class WatchLeakTest method createConnRequest.

/**
     * Create a connection request
     *
     * @return a serialized connection request
     */
private ByteBuffer createConnRequest() {
    Random r = new Random(SESSION_ID ^ superSecret);
    byte[] p = new byte[16];
    r.nextBytes(p);
    ConnectRequest conReq = new ConnectRequest(0, 1L, 30000, SESSION_ID, p);
    MockPacket packet = new MockPacket(null, null, conReq, null, null, false);
    return packet.createAndReturnBB();
}
Also used : ConnectRequest(org.apache.zookeeper.proto.ConnectRequest) Random(java.util.Random) MockPacket(org.apache.zookeeper.MockPacket)

Aggregations

MockPacket (org.apache.zookeeper.MockPacket)2 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 ConnectRequest (org.apache.zookeeper.proto.ConnectRequest)1 ReplyHeader (org.apache.zookeeper.proto.ReplyHeader)1 RequestHeader (org.apache.zookeeper.proto.RequestHeader)1 SetWatches (org.apache.zookeeper.proto.SetWatches)1