use of org.apache.zookeeper.server.ServerCnxn in project zookeeper by apache.
the class RemoveWatchesTest method isServerSessionWatcher.
/**
* Checks if a session is registered with the server as a watcher.
*
* @param long sessionId the session ID to check
* @param path the path to check for watchers
* @param type the type of watcher
* @return true if the client session is a watcher on path for the type
*/
private boolean isServerSessionWatcher(long sessionId, String path, WatcherType type) {
Set<ServerCnxn> cnxns = new HashSet<>();
CollectionUtils.addAll(cnxns, serverFactory.getConnections().iterator());
for (ServerCnxn cnxn : cnxns) {
if (cnxn.getSessionId() == sessionId) {
return getServer(serverFactory).getZKDatabase().getDataTree().containsWatcher(path, type, cnxn);
}
}
return false;
}
use of org.apache.zookeeper.server.ServerCnxn in project zookeeper by apache.
the class Learner method revalidate.
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);
}
}
use of org.apache.zookeeper.server.ServerCnxn in project zookeeper by apache.
the class ConsCommand method commandRun.
@Override
public void commandRun() {
if (!isZKServerRunning()) {
pw.println(ZK_NOT_SERVING);
} else {
for (ServerCnxn c : factory.getConnections()) {
c.dumpConnectionInfo(pw, false);
pw.println();
}
pw.println();
}
}
use of org.apache.zookeeper.server.ServerCnxn in project zookeeper by apache.
the class StatCommand method commandRun.
@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());
}
}
Aggregations