Java 类org.apache.zookeeper.server.ServerCnxn 实例源码

项目:fuck_zookeeper    文件:Learner.java   
/**
 * validate a session for a client
 *
 * @param clientId
 *                the client to be revalidated
 * @param timeout
 *                the timeout for which the session is valid
 * @return
 * @throws IOException
 */
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
        throws IOException {
    LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeLong(clientId);
    dos.writeInt(timeout);
    dos.close();
    QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
            .toByteArray(), null);
    pendingRevalidations.put(clientId, cnxn);
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                                 ZooTrace.SESSION_TRACE_MASK,
                                 "To validate session 0x"
                                 + Long.toHexString(clientId));
    }
    writePacket(qp, true);
}
项目:fuck_zookeeper    文件:Learner.java   
protected void revalidate(QuorumPacket qp) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(qp
            .getData());
    DataInputStream dis = new DataInputStream(bis);
    long sessionId = dis.readLong();
    boolean valid = dis.readBoolean();
    ServerCnxn cnxn = pendingRevalidations
    .remove(sessionId);
    if (cnxn == null) {
        LOG.warn("Missing session 0x"
                + Long.toHexString(sessionId)
                + " for validation");
    } else {
        zk.finishSessionInit(cnxn, valid);
    }
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                ZooTrace.SESSION_TRACE_MASK,
                "Session 0x" + Long.toHexString(sessionId)
                + " is valid: " + valid);
    }
}
项目:fuck_zookeeper    文件:DigestAuthenticationProvider.java   
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
项目:https-github.com-apache-zookeeper    文件:Learner.java   
/**
 * validate a session for a client
 *
 * @param clientId
 *                the client to be revalidated
 * @param timeout
 *                the timeout for which the session is valid
 * @return
 * @throws IOException
 */
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
        throws IOException {
    LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeLong(clientId);
    dos.writeInt(timeout);
    dos.close();
    QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
            .toByteArray(), null);
    pendingRevalidations.put(clientId, cnxn);
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                                 ZooTrace.SESSION_TRACE_MASK,
                                 "To validate session 0x"
                                 + Long.toHexString(clientId));
    }
    writePacket(qp, true);
}
项目:https-github.com-apache-zookeeper    文件:Learner.java   
protected void revalidate(QuorumPacket qp) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(qp
            .getData());
    DataInputStream dis = new DataInputStream(bis);
    long sessionId = dis.readLong();
    boolean valid = dis.readBoolean();
    ServerCnxn cnxn = pendingRevalidations.remove(sessionId);
    if (cnxn == null) {
        LOG.warn("Missing session 0x"
                + Long.toHexString(sessionId)
                + " for validation");
    } else {
        zk.finishSessionInit(cnxn, valid);
    }
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                ZooTrace.SESSION_TRACE_MASK,
                "Session 0x" + Long.toHexString(sessionId)
                + " is valid: " + valid);
    }
}
项目:https-github.com-apache-zookeeper    文件:DigestAuthenticationProvider.java   
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
项目:https-github.com-apache-zookeeper    文件:StatCommand.java   
@Override
public void commandRun() {
    if (!isZKServerRunning()) {
        pw.println(ZK_NOT_SERVING);
    } else {
        pw.print("Zookeeper version: ");
        pw.println(Version.getFullVersion());
        if (zkServer instanceof ReadOnlyZooKeeperServer) {
            pw.println("READ-ONLY mode; serving only read-only clients");
        }
        if (len == FourLetterCommands.statCmd) {
            LOG.info("Stat command output");
            pw.println("Clients:");
            for(ServerCnxn c : factory.getConnections()){
                c.dumpConnectionInfo(pw, true);
                pw.println();
            }
            pw.println();
        }
        pw.print(zkServer.serverStats().toString());
        pw.print("Node count: ");
        pw.println(zkServer.getZKDatabase().getNodeCount());
    }
}
项目:ZooKeeper    文件:Learner.java   
/**
 * validate a session for a client
 *
 * @param clientId
 *                the client to be revalidated
 * @param timeout
 *                the timeout for which the session is valid
 * @return
 * @throws IOException
 */
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
        throws IOException {
    LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeLong(clientId);
    dos.writeInt(timeout);
    dos.close();
    QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
            .toByteArray(), null);
    pendingRevalidations.put(clientId, cnxn);
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                                 ZooTrace.SESSION_TRACE_MASK,
                                 "To validate session 0x"
                                 + Long.toHexString(clientId));
    }
    writePacket(qp, true);
}
项目:ZooKeeper    文件:Learner.java   
protected void revalidate(QuorumPacket qp) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(qp
            .getData());
    DataInputStream dis = new DataInputStream(bis);
    long sessionId = dis.readLong();
    boolean valid = dis.readBoolean();
    ServerCnxn cnxn = pendingRevalidations
    .remove(sessionId);
    if (cnxn == null) {
        LOG.warn("Missing session 0x"
                + Long.toHexString(sessionId)
                + " for validation");
    } else {
        zk.finishSessionInit(cnxn, valid);
    }
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                ZooTrace.SESSION_TRACE_MASK,
                "Session 0x" + Long.toHexString(sessionId)
                + " is valid: " + valid);
    }
}
项目:ZooKeeper    文件:DigestAuthenticationProvider.java   
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
项目:ZooKeeper    文件:FourLetterWordsWhiteListTest.java   
@Test(timeout=30000)
public void testFourLetterWordsAllDisabledByDefault() throws Exception {
    stopServer();
    ServerCnxn.resetWhiteList();
    System.setProperty("zookeeper.4lw.commands.whitelist", "stat");
    startServer();

    // Default white list for 3.5.x is empty, so all command should fail.
    verifyAllCommandsFail();

    TestableZooKeeper zk = createClient();

    verifyAllCommandsFail();

    zk.getData("/", true, null);

    verifyAllCommandsFail();

    zk.close();

    verifyFuzzyMatch("stat", "Outstanding");
    verifyAllCommandsFail();
}
项目:ZooKeeper    文件:FourLetterWordsWhiteListTest.java   
@Test(timeout=30000)
public void testFourLetterWordsEnableSomeCommands() throws Exception {
    stopServer();
    ServerCnxn.resetWhiteList();
    System.setProperty("zookeeper.4lw.commands.whitelist", "stat, ruok, isro");
    startServer();
    // stat, ruok and isro are white listed.
    verifyFuzzyMatch("stat", "Outstanding");
    verifyExactMatch("ruok", "imok");
    verifyExactMatch("isro", "rw");

    // Rest of commands fail.
    verifyExactMatch("conf", generateExpectedMessage("conf"));
    verifyExactMatch("cons", generateExpectedMessage("cons"));
    verifyExactMatch("crst", generateExpectedMessage("crst"));
    verifyExactMatch("dump", generateExpectedMessage("dump"));
    verifyExactMatch("envi", generateExpectedMessage("envi"));
    verifyExactMatch("gtmk", generateExpectedMessage("gtmk"));
    verifyExactMatch("stmk", generateExpectedMessage("stmk"));
    verifyExactMatch("srst", generateExpectedMessage("srst"));
    verifyExactMatch("wchc", generateExpectedMessage("wchc"));
    verifyExactMatch("wchp", generateExpectedMessage("wchp"));
    verifyExactMatch("wchs", generateExpectedMessage("wchs"));
    verifyExactMatch("mntr", generateExpectedMessage("mntr"));
}
项目:StreamProcessingInfrastructure    文件:Learner.java   
/**
 * validate a session for a client
 *
 * @param clientId
 *                the client to be revalidated
 * @param timeout
 *                the timeout for which the session is valid
 * @return
 * @throws IOException
 */
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
        throws IOException {
    LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeLong(clientId);
    dos.writeInt(timeout);
    dos.close();
    QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
            .toByteArray(), null);
    pendingRevalidations.put(clientId, cnxn);
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                                 ZooTrace.SESSION_TRACE_MASK,
                                 "To validate session 0x"
                                 + Long.toHexString(clientId));
    }
    writePacket(qp, true);
}
项目:StreamProcessingInfrastructure    文件:Learner.java   
protected void revalidate(QuorumPacket qp) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(qp
            .getData());
    DataInputStream dis = new DataInputStream(bis);
    long sessionId = dis.readLong();
    boolean valid = dis.readBoolean();
    ServerCnxn cnxn = pendingRevalidations
    .remove(sessionId);
    if (cnxn == null) {
        LOG.warn("Missing session 0x"
                + Long.toHexString(sessionId)
                + " for validation");
    } else {
        zk.finishSessionInit(cnxn, valid);
    }
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                ZooTrace.SESSION_TRACE_MASK,
                "Session 0x" + Long.toHexString(sessionId)
                + " is valid: " + valid);
    }
}
项目:StreamProcessingInfrastructure    文件:DigestAuthenticationProvider.java   
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
项目:bigstreams    文件:Learner.java   
/**
 * validate a session for a client
 *
 * @param clientId
 *                the client to be revalidated
 * @param timeout
 *                the timeout for which the session is valid
 * @return
 * @throws IOException
 */
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
        throws IOException {
    LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeLong(clientId);
    dos.writeInt(timeout);
    dos.close();
    QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
            .toByteArray(), null);
    pendingRevalidations.put(clientId, cnxn);
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                                 ZooTrace.SESSION_TRACE_MASK,
                                 "To validate session 0x"
                                 + Long.toHexString(clientId));
    }
    writePacket(qp, true);
}
项目:bigstreams    文件:Learner.java   
protected void revalidate(QuorumPacket qp) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(qp
            .getData());
    DataInputStream dis = new DataInputStream(bis);
    long sessionId = dis.readLong();
    boolean valid = dis.readBoolean();
    ServerCnxn cnxn = pendingRevalidations
    .remove(sessionId);
    if (cnxn == null) {
        LOG.warn("Missing session 0x"
                + Long.toHexString(sessionId)
                + " for validation");
    } else {
        zk.finishSessionInit(cnxn, valid);
    }
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                ZooTrace.SESSION_TRACE_MASK,
                "Session 0x" + Long.toHexString(sessionId)
                + " is valid: " + valid);
    }
}
项目:bigstreams    文件:DigestAuthenticationProvider.java   
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
项目:bigstreams    文件:Learner.java   
/**
 * validate a session for a client
 *
 * @param clientId
 *                the client to be revalidated
 * @param timeout
 *                the timeout for which the session is valid
 * @return
 * @throws IOException
 */
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
        throws IOException {
    LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeLong(clientId);
    dos.writeInt(timeout);
    dos.close();
    QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
            .toByteArray(), null);
    pendingRevalidations.put(clientId, cnxn);
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                                 ZooTrace.SESSION_TRACE_MASK,
                                 "To validate session 0x"
                                 + Long.toHexString(clientId));
    }
    writePacket(qp, true);
}
项目:bigstreams    文件:Learner.java   
protected void revalidate(QuorumPacket qp) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(qp
            .getData());
    DataInputStream dis = new DataInputStream(bis);
    long sessionId = dis.readLong();
    boolean valid = dis.readBoolean();
    ServerCnxn cnxn = pendingRevalidations
    .remove(sessionId);
    if (cnxn == null) {
        LOG.warn("Missing session 0x"
                + Long.toHexString(sessionId)
                + " for validation");
    } else {
        zk.finishSessionInit(cnxn, valid);
    }
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                ZooTrace.SESSION_TRACE_MASK,
                "Session 0x" + Long.toHexString(sessionId)
                + " is valid: " + valid);
    }
}
项目:bigstreams    文件:DigestAuthenticationProvider.java   
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
项目:zookeeper-src-learning    文件:Learner.java   
/**
 * validate a session for a client
 *
 * @param clientId
 *                the client to be revalidated
 * @param timeout
 *                the timeout for which the session is valid
 * @return
 * @throws IOException
 */
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
        throws IOException {
    LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeLong(clientId);
    dos.writeInt(timeout);
    dos.close();
    QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
            .toByteArray(), null);
    pendingRevalidations.put(clientId, cnxn);
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                                 ZooTrace.SESSION_TRACE_MASK,
                                 "To validate session 0x"
                                 + Long.toHexString(clientId));
    }
    writePacket(qp, true);
}
项目:zookeeper-src-learning    文件:Learner.java   
protected void revalidate(QuorumPacket qp) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(qp
            .getData());
    DataInputStream dis = new DataInputStream(bis);
    long sessionId = dis.readLong();
    boolean valid = dis.readBoolean();
    ServerCnxn cnxn = pendingRevalidations
    .remove(sessionId);
    if (cnxn == null) {
        LOG.warn("Missing session 0x"
                + Long.toHexString(sessionId)
                + " for validation");
    } else {
        zk.finishSessionInit(cnxn, valid);
    }
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                ZooTrace.SESSION_TRACE_MASK,
                "Session 0x" + Long.toHexString(sessionId)
                + " is valid: " + valid);
    }
}
项目:zookeeper-src-learning    文件:DigestAuthenticationProvider.java   
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
项目:zookeeper    文件:Learner.java   
/**
 * validate a session for a client
 *
 * @param clientId
 *                the client to be revalidated
 * @param timeout
 *                the timeout for which the session is valid
 * @return
 * @throws IOException
 */
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
        throws IOException {
    LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeLong(clientId);
    dos.writeInt(timeout);
    dos.close();
    QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
            .toByteArray(), null);
    pendingRevalidations.put(clientId, cnxn);
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                                 ZooTrace.SESSION_TRACE_MASK,
                                 "To validate session 0x"
                                 + Long.toHexString(clientId));
    }
    writePacket(qp, true);
}
项目:zookeeper    文件:Learner.java   
protected void revalidate(QuorumPacket qp) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(qp
            .getData());
    DataInputStream dis = new DataInputStream(bis);
    long sessionId = dis.readLong();
    boolean valid = dis.readBoolean();
    ServerCnxn cnxn = pendingRevalidations
    .remove(sessionId);
    if (cnxn == null) {
        LOG.warn("Missing session 0x"
                + Long.toHexString(sessionId)
                + " for validation");
    } else {
        zk.finishSessionInit(cnxn, valid);
    }
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                ZooTrace.SESSION_TRACE_MASK,
                "Session 0x" + Long.toHexString(sessionId)
                + " is valid: " + valid);
    }
}
项目:zookeeper    文件:DigestAuthenticationProvider.java   
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
项目:SecureKeeper    文件:Learner.java   
/**
 * validate a session for a client
 *
 * @param clientId
 *                the client to be revalidated
 * @param timeout
 *                the timeout for which the session is valid
 * @return
 * @throws IOException
 */
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
        throws IOException {
    LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeLong(clientId);
    dos.writeInt(timeout);
    dos.close();
    QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
            .toByteArray(), null);
    pendingRevalidations.put(clientId, cnxn);
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                                 ZooTrace.SESSION_TRACE_MASK,
                                 "To validate session 0x"
                                 + Long.toHexString(clientId));
    }
    writePacket(qp, true);
}
项目:SecureKeeper    文件:Learner.java   
protected void revalidate(QuorumPacket qp) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(qp
            .getData());
    DataInputStream dis = new DataInputStream(bis);
    long sessionId = dis.readLong();
    boolean valid = dis.readBoolean();
    ServerCnxn cnxn = pendingRevalidations.remove(sessionId);
    if (cnxn == null) {
        LOG.warn("Missing session 0x"
                + Long.toHexString(sessionId)
                + " for validation");
    } else {
        zk.finishSessionInit(cnxn, valid);
    }
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                ZooTrace.SESSION_TRACE_MASK,
                "Session 0x" + Long.toHexString(sessionId)
                + " is valid: " + valid);
    }
}
项目:SecureKeeper    文件:DigestAuthenticationProvider.java   
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
项目:SecureKeeper    文件:StatCommand.java   
@Override
public void commandRun() {
    if (zkServer == null) {
        pw.println(ZK_NOT_SERVING);
    } else {
        pw.print("Zookeeper version: ");
        pw.println(Version.getFullVersion());
        if (zkServer instanceof ReadOnlyZooKeeperServer) {
            pw.println("READ-ONLY mode; serving only read-only clients");
        }
        if (len == FourLetterCommands.statCmd) {
            LOG.info("Stat command output");
            pw.println("Clients:");
            for(ServerCnxn c : factory.getConnections()){
                c.dumpConnectionInfo(pw, true);
                pw.println();
            }
            pw.println();
        }
        pw.print(zkServer.serverStats().toString());
        pw.print("Node count: ");
        pw.println(zkServer.getZKDatabase().getNodeCount());
    }
}
项目:SecureKeeper    文件:Learner.java   
/**
 * validate a session for a client
 *
 * @param clientId
 *                the client to be revalidated
 * @param timeout
 *                the timeout for which the session is valid
 * @return
 * @throws IOException
 */
void validateSession(ServerCnxn cnxn, long clientId, int timeout)
        throws IOException {
    LOG.info("Revalidating client: 0x" + Long.toHexString(clientId));
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(baos);
    dos.writeLong(clientId);
    dos.writeInt(timeout);
    dos.close();
    QuorumPacket qp = new QuorumPacket(Leader.REVALIDATE, -1, baos
            .toByteArray(), null);
    pendingRevalidations.put(clientId, cnxn);
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                                 ZooTrace.SESSION_TRACE_MASK,
                                 "To validate session 0x"
                                 + Long.toHexString(clientId));
    }
    writePacket(qp, true);
}
项目:SecureKeeper    文件:Learner.java   
protected void revalidate(QuorumPacket qp) throws IOException {
    ByteArrayInputStream bis = new ByteArrayInputStream(qp
            .getData());
    DataInputStream dis = new DataInputStream(bis);
    long sessionId = dis.readLong();
    boolean valid = dis.readBoolean();
    ServerCnxn cnxn = pendingRevalidations.remove(sessionId);
    if (cnxn == null) {
        LOG.warn("Missing session 0x"
                + Long.toHexString(sessionId)
                + " for validation");
    } else {
        zk.finishSessionInit(cnxn, valid);
    }
    if (LOG.isTraceEnabled()) {
        ZooTrace.logTraceMessage(LOG,
                ZooTrace.SESSION_TRACE_MASK,
                "Session 0x" + Long.toHexString(sessionId)
                + " is valid: " + valid);
    }
}
项目:SecureKeeper    文件:DigestAuthenticationProvider.java   
public KeeperException.Code 
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = new String(authData);
    try {
        String digest = generateDigest(id);
        if (digest.equals(superDigest)) {
            cnxn.addAuthInfo(new Id("super", ""));
        }
        cnxn.addAuthInfo(new Id(getScheme(), digest));
        return KeeperException.Code.OK;
    } catch (NoSuchAlgorithmException e) {
        LOG.error("Missing algorithm",e);
    }
    return KeeperException.Code.AUTHFAILED;
}
项目:SecureKeeper    文件:StatCommand.java   
@Override
public void commandRun() {
    if (zkServer == null) {
        pw.println(ZK_NOT_SERVING);
    } else {
        pw.print("Zookeeper version: ");
        pw.println(Version.getFullVersion());
        if (zkServer instanceof ReadOnlyZooKeeperServer) {
            pw.println("READ-ONLY mode; serving only read-only clients");
        }
        if (len == FourLetterCommands.statCmd) {
            LOG.info("Stat command output");
            pw.println("Clients:");
            for(ServerCnxn c : factory.getConnections()){
                c.dumpConnectionInfo(pw, true);
                pw.println();
            }
            pw.println();
        }
        pw.print(zkServer.serverStats().toString());
        pw.print("Node count: ");
        pw.println(zkServer.getZKDatabase().getNodeCount());
    }
}
项目:fuck_zookeeper    文件:LeaderZooKeeperServer.java   
@Override
protected void revalidateSession(ServerCnxn cnxn, long sessionId,
    int sessionTimeout) throws IOException {
    super.revalidateSession(cnxn, sessionId, sessionTimeout);
    try {
        // setowner as the leader itself, unless updated
        // via the follower handlers
        setOwner(sessionId, ServerCnxn.me);
    } catch (SessionExpiredException e) {
        // this is ok, it just means that the session revalidation failed.
    }
}
项目:fuck_zookeeper    文件:SASLAuthenticationProvider.java   
public KeeperException.Code
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    // Should never call this: SASL authentication is negotiated at session initiation.
    // TODO: consider substituting current implementation of direct ClientCnxn manipulation with
    // a call to this method (SASLAuthenticationProvider:handleAuthentication()) at session initiation.
    return KeeperException.Code.AUTHFAILED;

}
项目:fuck_zookeeper    文件:IPAuthenticationProvider.java   
public KeeperException.Code
    handleAuthentication(ServerCnxn cnxn, byte[] authData)
{
    String id = cnxn.getRemoteSocketAddress().getAddress().getHostAddress();
    cnxn.addAuthInfo(new Id(getScheme(), id));
    return KeeperException.Code.OK;
}
项目:https-github.com-apache-zookeeper    文件:LearnerZooKeeperServer.java   
@Override
protected void revalidateSession(ServerCnxn cnxn, long sessionId,
        int sessionTimeout) throws IOException {
    if (upgradeableSessionTracker.isLocalSession(sessionId)) {
        super.revalidateSession(cnxn, sessionId, sessionTimeout);
    } else {
        getLearner().validateSession(cnxn, sessionId, sessionTimeout);
    }
}
项目:https-github.com-apache-zookeeper    文件:LeaderZooKeeperServer.java   
@Override
protected void revalidateSession(ServerCnxn cnxn, long sessionId,
    int sessionTimeout) throws IOException {
    super.revalidateSession(cnxn, sessionId, sessionTimeout);
    try {
        // setowner as the leader itself, unless updated
        // via the follower handlers
        setOwner(sessionId, ServerCnxn.me);
    } catch (SessionExpiredException e) {
        // this is ok, it just means that the session revalidation failed.
    }
}