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

项目:fuck_zookeeper    文件:ClientTest.java   
/**
 * We create a perfectly valid 'exists' request, except that the opcode is wrong.
 * @return
 * @throws Exception
 */
@Test
public void testNonExistingOpCode() throws Exception  {
    TestableZooKeeper zk = createClient();

    final String path = "/m1";

    RequestHeader h = new RequestHeader();
    h.setType(888);  // This code does not exists
    ExistsRequest request = new ExistsRequest();
    request.setPath(path);
    request.setWatch(false);
    ExistsResponse response = new ExistsResponse();
    ReplyHeader r = zk.submitRequest(h, request, response, null);

    Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue());

    try {
        zk.exists("/m1", false);
        fail("The connection should have been closed");
    } catch (KeeperException.ConnectionLossException expected) {
    }
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of exists.
 *
 * @see #exists(String, Watcher)
 */
public void exists(final String path, Watcher watcher,
        StatCallback 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 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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:ZooKeeper    文件:ClientTest.java   
/**
 * We create a perfectly valid 'exists' request, except that the opcode is wrong.
 * @return
 * @throws Exception
 */
@Test
public void testNonExistingOpCode() throws Exception  {
    TestableZooKeeper zk = createClient();

    final String path = "/m1";

    RequestHeader h = new RequestHeader();
    h.setType(888);  // This code does not exists
    ExistsRequest request = new ExistsRequest();
    request.setPath(path);
    request.setWatch(false);
    ExistsResponse response = new ExistsResponse();
    ReplyHeader r = zk.submitRequest(h, request, response, null);

    Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue());

    try {
        zk.exists("/m1", false);
        fail("The connection should have been closed");
    } catch (KeeperException.ConnectionLossException expected) {
    }
}
项目:StreamProcessingInfrastructure    文件:ClientTest.java   
/**
 * We create a perfectly valid 'exists' request, except that the opcode is wrong.
 * @return
 * @throws Exception
 */
@Test
public void testNonExistingOpCode() throws Exception  {
    TestableZooKeeper zk = createClient();

    final String path = "/m1";

    RequestHeader h = new RequestHeader();
    h.setType(888);  // This code does not exists
    ExistsRequest request = new ExistsRequest();
    request.setPath(path);
    request.setWatch(false);
    ExistsResponse response = new ExistsResponse();
    ReplyHeader r = zk.submitRequest(h, request, response, null);

    Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue());

    try {
        zk.exists("/m1", false);
        fail("The connection should have been closed");
    } catch (KeeperException.ConnectionLossException expected) {
    }
}
项目:bigstreams    文件:ZooKeeper.java   
/**
 * The Asynchronous version of exists. The request doesn't actually until
 * the asynchronous callback is called.
 *
 * @see #exists(String, boolean)
 */
public void exists(final String path, Watcher watcher,
        StatCallback 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 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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:zookeeper-src-learning    文件:ZooKeeper.java   
/**
 * The asynchronous version of exists.
 *
 * @see #exists(String, Watcher)
 */
public void exists(final String path, Watcher watcher,
        StatCallback 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 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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:zookeeper    文件:ClientTest.java   
/**
 * We create a perfectly valid 'exists' request, except that the opcode is wrong.
 * @return
 * @throws Exception
 */
@Test
public void testNonExistingOpCode() throws Exception  {
    TestableZooKeeper zk = createClient();

    final String path = "/m1";

    RequestHeader h = new RequestHeader();
    h.setType(888);  // This code does not exists
    ExistsRequest request = new ExistsRequest();
    request.setPath(path);
    request.setWatch(false);
    ExistsResponse response = new ExistsResponse();
    ReplyHeader r = zk.submitRequest(h, request, response, null);

    Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue());

    try {
        zk.exists("/m1", false);
        fail("The connection should have been closed");
    } catch (KeeperException.ConnectionLossException expected) {
    }
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of exists.
 *
 * @see #exists(String, Watcher)
 */
public void exists(final String path, Watcher watcher,
        StatCallback 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 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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:SecureKeeper    文件:ClientTest.java   
/**
 * We create a perfectly valid 'exists' request, except that the opcode is wrong.
 * @return
 * @throws Exception
 */
@Test
public void testNonExistingOpCode() throws Exception  {
    TestableZooKeeper zk = createClient();

    final String path = "/m1";

    RequestHeader h = new RequestHeader();
    h.setType(888);  // This code does not exists
    ExistsRequest request = new ExistsRequest();
    request.setPath(path);
    request.setWatch(false);
    ExistsResponse response = new ExistsResponse();
    ReplyHeader r = zk.submitRequest(h, request, response, null);

    Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue());
    zk.testableWaitForShutdown(CONNECTION_TIMEOUT);
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * The asynchronous version of exists.
 *
 * @see #exists(String, Watcher)
 */
public void exists(final String path, Watcher watcher,
        StatCallback 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 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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:SecureKeeper    文件:ClientTest.java   
/**
 * We create a perfectly valid 'exists' request, except that the opcode is wrong.
 * @return
 * @throws Exception
 */
@Test
public void testNonExistingOpCode() throws Exception  {
    TestableZooKeeper zk = createClient();

    final String path = "/m1";

    RequestHeader h = new RequestHeader();
    h.setType(888);  // This code does not exists
    ExistsRequest request = new ExistsRequest();
    request.setPath(path);
    request.setWatch(false);
    ExistsResponse response = new ExistsResponse();
    ReplyHeader r = zk.submitRequest(h, request, response, null);

    Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue());
    zk.testableWaitForShutdown(CONNECTION_TIMEOUT);
}
项目:StreamBench    文件:ClientTest.java   
/**
 * We create a perfectly valid 'exists' request, except that the opcode is wrong.
 * @return
 * @throws Exception
 */
@Test
public void testNonExistingOpCode() throws Exception  {
    TestableZooKeeper zk = createClient();

    final String path = "/m1";

    RequestHeader h = new RequestHeader();
    h.setType(888);  // This code does not exists
    ExistsRequest request = new ExistsRequest();
    request.setPath(path);
    request.setWatch(false);
    ExistsResponse response = new ExistsResponse();
    ReplyHeader r = zk.submitRequest(h, request, response, null);

    Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue());

    try {
        zk.exists("/m1", false);
        fail("The connection should have been closed");
    } catch (KeeperException.ConnectionLossException expected) {
    }
}
项目:zookeeper.dsc    文件:ZooKeeper.java   
/**
 * The Asynchronous version of exists. The request doesn't actually until
 * the asynchronous callback is called.
 *
 * @see #exists(String, boolean)
 */
public void exists(final String path, Watcher watcher,
        StatCallback 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 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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
项目:https-github.com-apache-zookeeper    文件:ZooKeeper.java   
/**
 * 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();
}
项目:https-github.com-apache-zookeeper    文件:ClientTest.java   
/**
 * We create a perfectly valid 'exists' request, except that the opcode is wrong.
 * @return
 * @throws Exception
 */
@Test
public void testNonExistingOpCode() throws Exception  {
    final CountDownLatch clientDisconnected = new CountDownLatch(1);
    Watcher watcher = new Watcher() {
        @Override
        public synchronized void process(WatchedEvent event) {
            if (event.getState() == KeeperState.Disconnected) {
                clientDisconnected.countDown();
            }
        }
    };
    TestableZooKeeper zk = new TestableZooKeeper(hostPort, CONNECTION_TIMEOUT, watcher);

    final String path = "/m1";

    RequestHeader h = new RequestHeader();
    h.setType(888);  // This code does not exists
    ExistsRequest request = new ExistsRequest();
    request.setPath(path);
    request.setWatch(false);
    ExistsResponse response = new ExistsResponse();

    ReplyHeader r = zk.submitRequest(h, request, response, null);

    Assert.assertEquals(r.getErr(), Code.UNIMPLEMENTED.intValue());

    // Sending a nonexisting opcode should cause the server to disconnect
    Assert.assertTrue("failed to disconnect",
            clientDisconnected.await(5000, TimeUnit.MILLISECONDS));
}
项目:bigstreams    文件:ZooKeeper.java   
/**
 * 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();
}
项目:zookeeper-src-learning    文件:ZooKeeper.java   
/**
 * 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();
}
项目:incubator-pulsar    文件:ClientCnxnAspect.java   
private EventType checkType(Record response) {

        if (response == null) {
            return EventType.other;
        } else if (response instanceof ConnectRequest) {
            return EventType.write;
        } else if (response instanceof CreateRequest) {
            return EventType.write;
        } else if (response instanceof DeleteRequest) {
            return EventType.write;
        } else if (response instanceof SetDataRequest) {
            return EventType.write;
        } else if (response instanceof SetACLRequest) {
            return EventType.write;
        } else if (response instanceof SetMaxChildrenRequest) {
            return EventType.write;
        } else if (response instanceof SetSASLRequest) {
            return EventType.write;
        } else if (response instanceof SetWatches) {
            return EventType.write;
        } else if (response instanceof SyncRequest) {
            return EventType.write;
        } else if (response instanceof ExistsRequest) {
            return EventType.read;
        } else if (response instanceof GetDataRequest) {
            return EventType.read;
        } else if (response instanceof GetMaxChildrenRequest) {
            return EventType.read;
        } else if (response instanceof GetACLRequest) {
            return EventType.read;
        } else if (response instanceof GetChildrenRequest) {
            return EventType.read;
        } else if (response instanceof GetChildren2Request) {
            return EventType.read;
        } else if (response instanceof GetSASLRequest) {
            return EventType.read;
        } else {
            return EventType.other;
        }
    }
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * 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();
}
项目:SecureKeeper    文件:ZooKeeper.java   
/**
 * 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();
}
项目:zookeeper.dsc    文件:ZooKeeper.java   
/**
 * 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();
}
项目:zookeeper-lite    文件:IExistsRequest.java   
public IExistsRequest() {
    this(new ExistsRequest());
}
项目:zookeeper-lite    文件:IExistsRequest.java   
public IExistsRequest(String path, boolean watch) {
    this(new ExistsRequest(path, watch));
}
项目:zookeeper-lite    文件:IExistsRequest.java   
public IExistsRequest(ExistsRequest record) {
    super(record);
}