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


Java ConnectResponse.getSessionId方法代码示例

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


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

示例1: readConnectResult

import org.apache.zookeeper.proto.ConnectResponse; //导入方法依赖的package包/类
void readConnectResult() throws IOException {
    if (LOG.isTraceEnabled()) {
        StringBuilder buf = new StringBuilder("0x[");
        for (byte b : incomingBuffer.array()) {
            buf.append(Integer.toHexString(b) + ",");
        }
        buf.append("]");
        LOG.trace("readConnectResult " + incomingBuffer.remaining() + " "
                + buf.toString());
    }
    ByteBufferInputStream bbis = new ByteBufferInputStream(incomingBuffer);
    BinaryInputArchive bbia = BinaryInputArchive.getArchive(bbis);
    ConnectResponse conRsp = new ConnectResponse();
    conRsp.deserialize(bbia, "connect");

    // read "is read-only" flag
    boolean isRO = false;
    try {
        isRO = bbia.readBool("readOnly");
    } catch (IOException e) {
        // this is ok -- just a packet from an old server which
        // doesn't contain readOnly field
        LOG.warn("Connected to an old server; r-o mode will be unavailable");
    }

    this.sessionId = conRsp.getSessionId();
    sendThread.onConnected(conRsp.getTimeOut(), this.sessionId,
            conRsp.getPasswd(), isRO);
}
 
开发者ID:maoling,项目名称:fuck_zookeeper,代码行数:30,代码来源:ClientCnxnSocket.java

示例2: readConnectResult

import org.apache.zookeeper.proto.ConnectResponse; //导入方法依赖的package包/类
void readConnectResult() throws IOException {
    if (LOG.isTraceEnabled()) {
        StringBuffer buf = new StringBuffer("0x[");
        for (byte b : incomingBuffer.array()) {
            buf.append(Integer.toHexString(b) + ",");
        }
        buf.append("]");
        LOG.trace("readConnectRestult " + incomingBuffer.remaining() + " "
                + buf.toString());
    }
    ByteBufferInputStream bbis = new ByteBufferInputStream(incomingBuffer);
    BinaryInputArchive bbia = BinaryInputArchive.getArchive(bbis);
    ConnectResponse conRsp = new ConnectResponse();
    conRsp.deserialize(bbia, "connect");

    // read "is read-only" flag
    boolean isRO = false;
    try {
        isRO = bbia.readBool("readOnly");
    } catch (IOException e) {
        // this is ok -- just a packet from an old server which
        // doesn't contain readOnly field
        LOG.warn("Connected to an old server; r-o mode will be unavailable");
    }

    this.sessionId = conRsp.getSessionId();
    sendThread.onConnected(conRsp.getTimeOut(), this.sessionId,
            conRsp.getPasswd(), isRO);
}
 
开发者ID:gerritjvv,项目名称:bigstreams,代码行数:30,代码来源:ClientCnxnSocket.java

示例3: readConnectResult

import org.apache.zookeeper.proto.ConnectResponse; //导入方法依赖的package包/类
void readConnectResult() throws IOException {
    ByteBufferInputStream bbis = new ByteBufferInputStream(
            incomingBuffer);
    BinaryInputArchive bbia = BinaryInputArchive.getArchive(bbis);
    ConnectResponse conRsp = new ConnectResponse();
    conRsp.deserialize(bbia, "connect");
    negotiatedSessionTimeout = conRsp.getTimeOut();
    if (negotiatedSessionTimeout <= 0) {
        zooKeeper.state = States.CLOSED;

        eventThread.queueEvent(new WatchedEvent(
                Watcher.Event.EventType.None,
                Watcher.Event.KeeperState.Expired, null));
        eventThread.queueEventOfDeath();
        throw new SessionExpiredException(
                "Unable to reconnect to ZooKeeper service, session 0x"
                + Long.toHexString(sessionId) + " has expired");
    }
    readTimeout = negotiatedSessionTimeout * 2 / 3;
    connectTimeout = negotiatedSessionTimeout / serverAddrs.size();
    sessionId = conRsp.getSessionId();
    sessionPasswd = conRsp.getPasswd();
    zooKeeper.state = States.CONNECTED;
    LOG.info("Session establishment complete on server "
            + ((SocketChannel)sockKey.channel())
                .socket().getRemoteSocketAddress()
            + ", sessionid = 0x"
            + Long.toHexString(sessionId)
            + ", negotiated timeout = " + negotiatedSessionTimeout);
    eventThread.queueEvent(new WatchedEvent(Watcher.Event.EventType.None,
            Watcher.Event.KeeperState.SyncConnected, null));
}
 
开发者ID:prodigeni,项目名称:zookeeper.dsc,代码行数:33,代码来源:ClientCnxn.java


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