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


Java RequestHeader.setXid方法代码示例

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


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

示例1: 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

示例2: 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:blentle,项目名称:zookeeper-src-learning,代码行数:17,代码来源:ClientCnxn.java

示例3: createWatchesMessage

import org.apache.zookeeper.proto.RequestHeader; //导入方法依赖的package包/类
/**
 * Create a watches message with a single watch on /
 * 
 * @return
 */
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();
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:19,代码来源:WatchLeakTest.java

示例4: createWatchesMessage

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

示例5: queuePacket

import org.apache.zookeeper.proto.RequestHeader; //导入方法依赖的package包/类
Packet queuePacket(RequestHeader h, ReplyHeader r, Record request,
        Record response, AsyncCallback cb, String clientPath,
        String serverPath, Object ctx, WatchRegistration watchRegistration)
{
    Packet packet = null;
    synchronized (outgoingQueue) {
        if (h.getType() != OpCode.ping && h.getType() != OpCode.auth) {
            h.setXid(getXid());
        }
        packet = new Packet(h, r, request, response, watchRegistration);
        packet.cb = cb;
        packet.ctx = ctx;
        packet.clientPath = clientPath;
        packet.serverPath = serverPath;
        if (!state.isAlive() || closing) {
            conLossPacket(packet);
        } else {
            // If the client is asking to close the session then
            // mark as closing
            if (h.getType() == OpCode.closeSession) {
                closing = true;
            }
            outgoingQueue.add(packet);
        }
    }
    sendThread.getClientCnxnSocket().wakeupCnxn();
    return packet;
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:29,代码来源:ClientCnxn.java

示例6: primeConnection

import org.apache.zookeeper.proto.RequestHeader; //导入方法依赖的package包/类
void primeConnection() throws IOException {
    LOG.info("Socket connection established to "
             + clientCnxnSocket.getRemoteSocketAddress()
             + ", initiating session");
    isFirstConnect = false;
    long sessId = (seenRwServerBefore) ? sessionId : 0;
    ConnectRequest conReq = new ConnectRequest(0, lastZxid,
            sessionTimeout, sessId, sessionPasswd);
    synchronized (outgoingQueue) {
        // We add backwards since we are pushing into the front
        // Only send if there's a pending watch
        // TODO: here we have the only remaining use of zooKeeper in
        // this class. It's to be eliminated!
        if (!disableAutoWatchReset) {
            List<String> dataWatches = zooKeeper.getDataWatches();
            List<String> existWatches = zooKeeper.getExistWatches();
            List<String> childWatches = zooKeeper.getChildWatches();
            if (!dataWatches.isEmpty()
                        || !existWatches.isEmpty() || !childWatches.isEmpty()) {

                Iterator<String> dataWatchesIter = prependChroot(dataWatches).iterator();
                Iterator<String> existWatchesIter = prependChroot(existWatches).iterator();
                Iterator<String> childWatchesIter = prependChroot(childWatches).iterator();
                long setWatchesLastZxid = lastZxid;

                while (dataWatchesIter.hasNext()
                               || existWatchesIter.hasNext() || childWatchesIter.hasNext()) {
                    List<String> dataWatchesBatch = new ArrayList<String>();
                    List<String> existWatchesBatch = new ArrayList<String>();
                    List<String> childWatchesBatch = new ArrayList<String>();
                    int batchLength = 0;

                    // Note, we may exceed our max length by a bit when we add the last
                    // watch in the batch. This isn't ideal, but it makes the code simpler.
                    while (batchLength < SET_WATCHES_MAX_LENGTH) {
                        final String watch;
                        if (dataWatchesIter.hasNext()) {
                            watch = dataWatchesIter.next();
                            dataWatchesBatch.add(watch);
                        } else if (existWatchesIter.hasNext()) {
                            watch = existWatchesIter.next();
                            existWatchesBatch.add(watch);
                        } else if (childWatchesIter.hasNext()) {
                            watch = childWatchesIter.next();
                            childWatchesBatch.add(watch);
                        } else {
                            break;
                        }
                        batchLength += watch.length();
                    }

                    SetWatches sw = new SetWatches(setWatchesLastZxid,
                            dataWatchesBatch,
                            existWatchesBatch,
                            childWatchesBatch);
                    RequestHeader h = new RequestHeader();
                    h.setType(ZooDefs.OpCode.setWatches);
                    h.setXid(-8);
                    Packet packet = new Packet(h, new ReplyHeader(), sw, null, null);
                    outgoingQueue.addFirst(packet);
                }
            }
        }

        for (AuthData id : authInfo) {
            outgoingQueue.addFirst(new Packet(new RequestHeader(-4,
                    OpCode.auth), null, new AuthPacket(0, id.scheme,
                    id.data), null, null));
        }
        outgoingQueue.addFirst(new Packet(null, null, conReq,
                    null, null, readOnly));
    }
    clientCnxnSocket.enableReadWriteOnly();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session establishment request sent on "
                + clientCnxnSocket.getRemoteSocketAddress());
    }
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:79,代码来源:ClientCnxn.java

示例7: primeConnection

import org.apache.zookeeper.proto.RequestHeader; //导入方法依赖的package包/类
void primeConnection() throws IOException {
    LOG.info("Socket connection established to "
             + clientCnxnSocket.getRemoteSocketAddress()
             + ", initiating session");
    isFirstConnect = false;
    long sessId = (seenRwServerBefore) ? sessionId : 0;
    ConnectRequest conReq = new ConnectRequest(0, lastZxid,
            sessionTimeout, sessId, sessionPasswd);
    synchronized (outgoingQueue) {
        // We add backwards since we are pushing into the front
        // Only send if there's a pending watch
        // TODO: here we have the only remaining use of zooKeeper in
        // this class. It's to be eliminated!
        if (!disableAutoWatchReset) {
            List<String> dataWatches = zooKeeper.getDataWatches();
            List<String> existWatches = zooKeeper.getExistWatches();
            List<String> childWatches = zooKeeper.getChildWatches();
            if (!dataWatches.isEmpty()
                        || !existWatches.isEmpty() || !childWatches.isEmpty()) {
                SetWatches sw = new SetWatches(lastZxid,
                        prependChroot(dataWatches),
                        prependChroot(existWatches),
                        prependChroot(childWatches));
                RequestHeader h = new RequestHeader();
                h.setType(ZooDefs.OpCode.setWatches);
                h.setXid(-8);
                Packet packet = new Packet(h, new ReplyHeader(), sw, null, null);
                outgoingQueue.addFirst(packet);
            }
        }

        for (AuthData id : authInfo) {
            outgoingQueue.addFirst(new Packet(new RequestHeader(-4,
                    OpCode.auth), null, new AuthPacket(0, id.scheme,
                    id.data), null, null));
        }
        outgoingQueue.addFirst(new Packet(null, null, conReq,
                    null, null, readOnly));
    }
    clientCnxnSocket.enableReadWriteOnly();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session establishment request sent on "
                + clientCnxnSocket.getRemoteSocketAddress());
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:46,代码来源:ClientCnxn.java

示例8: primeConnection

import org.apache.zookeeper.proto.RequestHeader; //导入方法依赖的package包/类
void primeConnection() throws IOException {
    LOG.info("Socket connection established to "
             + clientCnxnSocket.getRemoteSocketAddress()
             + ", initiating session");
    isFirstConnect = false;
    long sessId = (seenRwServerBefore) ? sessionId : 0;
    ConnectRequest conReq = new ConnectRequest(0, lastZxid,
            sessionTimeout, sessId, sessionPasswd);
    synchronized (outgoingQueue) {
        // We add backwards since we are pushing into the front
        // Only send if there's a pending watch
        // TODO: here we have the only remaining use of zooKeeper in
        // this class. It's to be eliminated!
        if (!disableAutoWatchReset
                && (!zooKeeper.getDataWatches().isEmpty()
                        || !zooKeeper.getExistWatches().isEmpty() || !zooKeeper
                        .getChildWatches().isEmpty())) {
            SetWatches sw = new SetWatches(lastZxid,
                    zooKeeper.getDataWatches(),
                    zooKeeper.getExistWatches(),
                    zooKeeper.getChildWatches());
            RequestHeader h = new RequestHeader();
            h.setType(ZooDefs.OpCode.setWatches);
            h.setXid(-8);
            Packet packet = new Packet(h, new ReplyHeader(), sw, null, null);
            outgoingQueue.addFirst(packet);
        }

        for (AuthData id : authInfo) {
            outgoingQueue.addFirst(new Packet(new RequestHeader(-4,
                    OpCode.auth), null, new AuthPacket(0, id.scheme,
                    id.data), null, null));
        }
        outgoingQueue.addFirst(new Packet(null, null, conReq,
                    null, null, readOnly));
    }
    clientCnxnSocket.enableReadWriteOnly();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session establishment request sent on "
                + clientCnxnSocket.getRemoteSocketAddress());
    }
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:43,代码来源:ClientCnxn.java

示例9: primeConnection

import org.apache.zookeeper.proto.RequestHeader; //导入方法依赖的package包/类
void primeConnection() throws IOException {
    LOG.info("Socket connection established to "
            + clientCnxnSocket.getRemoteSocketAddress()
            + ", initiating session");
    isFirstConnect = false;
    long sessId = (seenRwServerBefore) ? sessionId : 0;
    ConnectRequest conReq = new ConnectRequest(0, lastZxid,
            sessionTimeout, sessId, sessionPasswd);
    synchronized (outgoingQueue) {
        // We add backwards since we are pushing into the front
        // Only send if there's a pending watch
        // TODO: here we have the only remaining use of zooKeeper in
        // this class. It's to be eliminated!
        if (!disableAutoWatchReset) {
            List<String> dataWatches = zooKeeper.getDataWatches();
            List<String> existWatches = zooKeeper.getExistWatches();
            List<String> childWatches = zooKeeper.getChildWatches();
            if (!dataWatches.isEmpty()
                    || !existWatches.isEmpty() || !childWatches.isEmpty()) {
                SetWatches sw = new SetWatches(lastZxid,
                        prependChroot(dataWatches),
                        prependChroot(existWatches),
                        prependChroot(childWatches));
                RequestHeader h = new RequestHeader();
                h.setType(ZooDefs.OpCode.setWatches);
                h.setXid(-8);
                Packet packet = new Packet(h, new ReplyHeader(), sw, null, null);
                outgoingQueue.addFirst(packet);
            }
        }

        for (AuthData id : authInfo) {
            outgoingQueue.addFirst(new Packet(new RequestHeader(-4,
                    OpCode.auth), null, new AuthPacket(0, id.scheme,
                    id.data), null, null));
        }
        outgoingQueue.addFirst(new Packet(null, null, conReq,
                null, null, readOnly));
    }
    clientCnxnSocket.enableReadWriteOnly();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session establishment request sent on "
                + clientCnxnSocket.getRemoteSocketAddress());
    }
}
 
开发者ID:blentle,项目名称:zookeeper-src-learning,代码行数:46,代码来源:ClientCnxn.java


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