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

项目:fuck_zookeeper    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:https-github.com-apache-zookeeper    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:ZooKeeper    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:StreamProcessingInfrastructure    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:bigstreams    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:bigstreams    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:zookeeper-src-learning    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:zookeeper    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:SecureKeeper    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:SecureKeeper    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:StreamBench    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:ACaZoo    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:LoadBalanced_zk    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:LoadBalanced_zk    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:zookeeper.dsc    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!zooKeeper.state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:zookeeper-pkg    文件:ClientCnxn.java   
public void addAuthInfo(String scheme, byte auth[]) {
    if (!state.isAlive()) {
        return;
    }
    authInfo.add(new AuthData(scheme, auth));
    queuePacket(new RequestHeader(-4, OpCode.auth), null,
            new AuthPacket(0, scheme, auth), null, null, null, null,
            null, null);
}
项目:fuck_zookeeper    文件:ClientCnxn.java   
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());
    }
}
项目:https-github.com-apache-zookeeper    文件:ClientCnxn.java   
/**
 * Setup session, previous watches, authentication.
 */
void primeConnection() throws IOException {
    LOG.info("Socket connection established, initiating session, client: {}, server: {}",
            clientCnxnSocket.getLocalSocketAddress(),
            clientCnxnSocket.getRemoteSocketAddress());
    isFirstConnect = false;
    long sessId = (seenRwServerBefore) ? sessionId : 0;
    ConnectRequest conReq = new ConnectRequest(0, lastZxid,
            sessionTimeout, sessId, sessionPasswd);
    // 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 (!clientConfig.getBoolean(ZKClientConfig.DISABLE_AUTO_WATCH_RESET)) {
        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 header = new RequestHeader(-8, OpCode.setWatches);
                Packet packet = new Packet(header, 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.connectionPrimed();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session establishment request sent on "
                + clientCnxnSocket.getRemoteSocketAddress());
    }
}
项目:ZooKeeper    文件:ClientCnxn.java   
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());
    }
}
项目:StreamProcessingInfrastructure    文件:ClientCnxn.java   
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());
    }
}
项目:bigstreams    文件:ClientCnxn.java   
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());
    }
}
项目:bigstreams    文件:ClientCnxn.java   
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());
    }
}
项目:zookeeper-src-learning    文件:ClientCnxn.java   
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());
    }
}
项目:zookeeper    文件:ClientCnxn.java   
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());
    }
}
项目:SecureKeeper    文件:ClientCnxn.java   
/**
 * Setup session, previous watches, authentication.
 */
void primeConnection() throws IOException {
    LOG.info("Socket connection established, initiating session, client: {}, server: {}",
            clientCnxnSocket.getLocalSocketAddress(),
            clientCnxnSocket.getRemoteSocketAddress());
    isFirstConnect = false;
    long sessId = (seenRwServerBefore) ? sessionId : 0;
    ConnectRequest conReq = new ConnectRequest(0, lastZxid,
            sessionTimeout, sessId, sessionPasswd);
    // 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 header = new RequestHeader(-8, OpCode.setWatches);
                Packet packet = new Packet(header, 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.connectionPrimed();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session establishment request sent on "
                + clientCnxnSocket.getRemoteSocketAddress());
    }
}
项目:SecureKeeper    文件:ClientCnxn.java   
/**
 * Setup session, previous watches, authentication.
 */
void primeConnection() throws IOException {
    LOG.info("Socket connection established, initiating session, client: {}, server: {}",
            clientCnxnSocket.getLocalSocketAddress(),
            clientCnxnSocket.getRemoteSocketAddress());
    isFirstConnect = false;
    long sessId = (seenRwServerBefore) ? sessionId : 0;
    ConnectRequest conReq = new ConnectRequest(0, lastZxid,
            sessionTimeout, sessId, sessionPasswd);
    // 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 header = new RequestHeader(-8, OpCode.setWatches);
                Packet packet = new Packet(header, 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.connectionPrimed();
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session establishment request sent on "
                + clientCnxnSocket.getRemoteSocketAddress());
    }
}
项目:StreamBench    文件:ClientCnxn.java   
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());
    }
}
项目:ACaZoo    文件:ClientCnxn.java   
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());
    }
}
项目:LoadBalanced_zk    文件:ClientCnxn.java   
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());
    }
}
项目:LoadBalanced_zk    文件:ClientCnxn.java   
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());
    }
}
项目:zookeeper.dsc    文件:ClientCnxn.java   
private void primeConnection(SelectionKey k) throws IOException {
    LOG.info("Socket connection established to "
            + ((SocketChannel)sockKey.channel())
                .socket().getRemoteSocketAddress()
            + ", initiating session");
    lastConnectIndex = currentConnectIndex;
    ConnectRequest conReq = new ConnectRequest(0, lastZxid,
            sessionTimeout, sessionId, sessionPasswd);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    BinaryOutputArchive boa = BinaryOutputArchive.getArchive(baos);
    boa.writeInt(-1, "len");
    conReq.serialize(boa, "connect");
    baos.close();
    ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
    bb.putInt(bb.capacity() - 4);
    bb.rewind();
    synchronized (outgoingQueue) {
        // We add backwards since we are pushing into the front
        // Only send if there's a pending watch
        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,
                        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, null));
        }
        outgoingQueue.addFirst((new Packet(null, null, null, null, bb,
                null)));
    }
    synchronized (this) {
        k.interestOps(SelectionKey.OP_READ | SelectionKey.OP_WRITE);
    }
    if (LOG.isDebugEnabled()) {
        LOG.debug("Session establishment request sent on "
                + ((SocketChannel)sockKey.channel())
                    .socket().getRemoteSocketAddress());
    }
}
项目:zookeeper-lite    文件:IAuthRequest.java   
public IAuthRequest() {
    this(new AuthPacket());
}
项目:zookeeper-lite    文件:IAuthRequest.java   
public IAuthRequest(int type, String scheme, byte[] auth) {
    this(new AuthPacket(type, scheme, auth));
}
项目:zookeeper-lite    文件:IAuthRequest.java   
public IAuthRequest(AuthPacket record) {
    super(record);
}
项目:zookeeper-pkg    文件:ClientCnxn.java   
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());
    }
}