use of org.apache.zookeeper_voltpatches.proto.ConnectResponse in project voltdb by VoltDB.
the class NIOServerCnxn method finishSessionInit.
@Override
public void finishSessionInit(boolean valid) {
// register with JMX
try {
jmxConnectionBean = new ConnectionBean(this, zk);
MBeanRegistry.getInstance().register(jmxConnectionBean, zk.jmxServerBean);
} catch (Exception e) {
LOG.warn("Failed to register with JMX", e);
jmxConnectionBean = null;
}
try {
ConnectResponse rsp = new ConnectResponse(0, valid ? sessionTimeout : // send 0 if session is no
0, // send 0 if session is no
valid ? sessionId : 0, // longer valid
valid ? zk.generatePasswd(sessionId) : new byte[16]);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
BinaryOutputArchive bos = BinaryOutputArchive.getArchive(baos);
bos.writeInt(-1, "len");
rsp.serialize(bos, "connect");
baos.close();
ByteBuffer bb = ByteBuffer.wrap(baos.toByteArray());
bb.putInt(bb.remaining() - 4).rewind();
sendBuffer(bb);
if (!valid) {
LOG.info("Invalid session 0x" + Long.toHexString(sessionId) + " for client " + sock.socket().getRemoteSocketAddress() + ", probably expired");
sendCloseSession();
} else {
LOG.info("Established session 0x" + Long.toHexString(sessionId) + " with negotiated timeout " + sessionTimeout + " for client " + sock.socket().getRemoteSocketAddress());
}
// Now that the session is ready we can start receiving packets
synchronized (this.factory) {
sk.selector().wakeup();
enableRecv();
}
} catch (Exception e) {
LOG.warn("Exception while establishing session, closing", e);
close();
}
}
use of org.apache.zookeeper_voltpatches.proto.ConnectResponse in project voltdb by VoltDB.
the class ConnectResponse method equals.
@Override
public boolean equals(Object peer_) {
if (!(peer_ instanceof ConnectResponse)) {
return false;
}
if (peer_ == this) {
return true;
}
ConnectResponse peer = (ConnectResponse) peer_;
boolean ret = false;
ret = (protocolVersion == peer.protocolVersion);
if (!ret)
return ret;
ret = (timeOut == peer.timeOut);
if (!ret)
return ret;
ret = (sessionId == peer.sessionId);
if (!ret)
return ret;
ret = org.apache.jute_voltpatches.Utils.bufEquals(passwd, peer.passwd);
if (!ret)
return ret;
return ret;
}
use of org.apache.zookeeper_voltpatches.proto.ConnectResponse in project voltdb by VoltDB.
the class ConnectResponse method compareTo.
public int compareTo(Object peer_) throws ClassCastException {
if (!(peer_ instanceof ConnectResponse)) {
throw new ClassCastException("Comparing different types of records.");
}
ConnectResponse peer = (ConnectResponse) peer_;
int ret = 0;
ret = (protocolVersion == peer.protocolVersion) ? 0 : ((protocolVersion < peer.protocolVersion) ? -1 : 1);
if (ret != 0)
return ret;
ret = (timeOut == peer.timeOut) ? 0 : ((timeOut < peer.timeOut) ? -1 : 1);
if (ret != 0)
return ret;
ret = (sessionId == peer.sessionId) ? 0 : ((sessionId < peer.sessionId) ? -1 : 1);
if (ret != 0)
return ret;
{
byte[] my = passwd;
byte[] ur = peer.passwd;
ret = org.apache.jute_voltpatches.Utils.compareBytes(my, 0, my.length, ur, 0, ur.length);
}
if (ret != 0)
return ret;
return ret;
}
Aggregations