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


Java RequestHeader类代码示例

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


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

示例1: incrOutstandingRequests

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
protected void incrOutstandingRequests(RequestHeader h) {
    if (h.getXid() >= 0) {
        synchronized (this) {
            outstandingRequests++;
        }
        synchronized (this.factory) {        
            // check throttling
            if (zkServer.getInProcess() > outstandingLimit) {
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Throttling recv " + zkServer.getInProcess());
                }
                disableRecv();
                // following lines should not be needed since we are
                // already reading
                // } else {
                // enableRecv();
            }
        }
    }

}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:22,代码来源:NIOServerCnxn.java

示例2: close

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
/**
 * Close the connection, which includes; send session disconnect to the
 * server, shutdown the send/event threads.
 *
 * @throws IOException
 */
public void close() throws IOException {
    if (LOG.isDebugEnabled()) {
        LOG.debug("Closing client for session: 0x"
                  + Long.toHexString(getSessionId()));
    }

    try {
        RequestHeader h = new RequestHeader();
        h.setType(ZooDefs.OpCode.closeSession);

        submitRequest(h, null, null, null);
    } catch (InterruptedException e) {
        // ignore, close the send/event threads
    } finally {
        disconnect();
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:24,代码来源:ClientCnxn.java

示例3: sendPacket

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
public void sendPacket(Record request, Record response, AsyncCallback cb, int opCode)
throws IOException {
    // Generate Xid now because it will be sent immediately,
    // by call to sendThread.sendPacket() below.
    int xid = getXid();
    RequestHeader h = new RequestHeader();
    h.setXid(xid);
    h.setType(opCode);

    ReplyHeader r = new ReplyHeader();
    r.setXid(xid);

    Packet p = new Packet(h, r, request, response, null, false);
    p.cb = cb;
    sendThread.sendPacket(p);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:17,代码来源:ClientCnxn.java

示例4: testNonExistingOpCode

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
/**
 * 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) {
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:28,代码来源:ClientTest.java

示例5: create

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
/**
 * The asynchronous version of create.
 *
 * @see #create(String, byte[], List, CreateMode)
 */
public void create(final String path, byte data[], List<ACL> acl,
        CreateMode createMode, StringCallback cb, Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());
    EphemeralType.validateTTL(createMode, -1);

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(createMode.isContainer() ? ZooDefs.OpCode.createContainer : 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);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:27,代码来源:ZooKeeper.java

示例6: exists

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:29,代码来源:ZooKeeper.java

示例7: getData

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:29,代码来源:ZooKeeper.java

示例8: getConfig

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:26,代码来源:ZooKeeper.java

示例9: setData

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
/**
 * The asynchronous version of setData.
 *
 * @see #setData(String, byte[], int)
 */
public void setData(final String path, byte data[], int version,
        StatCallback cb, Object ctx)
{
    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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, null);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:24,代码来源:ZooKeeper.java

示例10: getACL

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的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

示例11: setACL

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的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

示例12: getChildren

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
/**
 * The asynchronous version of getChildren.
 *
 * @see #getChildren(String, Watcher)
 */
public void getChildren(final String path, Watcher watcher,
        ChildrenCallback 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 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();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, wcb);
}
 
开发者ID:didichuxing2,项目名称:https-github.com-apache-zookeeper,代码行数:29,代码来源:ZooKeeper.java

示例13: removeWatches

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的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

示例14: create

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
/**
 * The asynchronous version of create.
 *
 * @see #create(String, byte[], List, CreateMode, Stat)
 */
public void create(final String path, byte data[], List<ACL> acl,
        CreateMode createMode, Create2Callback cb, Object ctx)
{
    final String clientPath = path;
    PathUtils.validatePath(clientPath, createMode.isSequential());

    final String serverPath = prependChroot(clientPath);

    RequestHeader h = new RequestHeader();
    h.setType(createMode.isContainer() ? ZooDefs.OpCode.createContainer : ZooDefs.OpCode.create2);
    CreateRequest request = new CreateRequest();
    Create2Response response = new Create2Response();
    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);
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:26,代码来源:ZooKeeper.java

示例15: setACL

import org.apache.zookeeper.proto.RequestHeader; //导入依赖的package包/类
/**
 * The asynchronous version of setACL.
 *
 * @see #setACL(String, List, int)
 */
public void setACL(final String path, List<ACL> acl, int version,
        StatCallback cb, Object ctx)
{
    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);
    request.setAcl(acl);
    request.setVersion(version);
    SetACLResponse response = new SetACLResponse();
    cnxn.queuePacket(h, new ReplyHeader(), request, response, cb,
            clientPath, serverPath, ctx, null);
}
 
开发者ID:sereca,项目名称:SecureKeeper,代码行数:24,代码来源:ZooKeeper.java


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