use of com.hazelcast.internal.cluster.impl.MemberHandshake in project hazelcast by hazelcast.
the class TcpServerControl method process.
public void process(Packet packet) {
MemberHandshake handshake = serverContext.getSerializationService().toObject(packet);
TcpServerConnection connection = (TcpServerConnection) packet.getConn();
if (!connection.setHandshake()) {
if (logger.isFinestEnabled()) {
logger.finest("Connection " + connection + " handshake is already completed, ignoring incoming " + handshake);
}
return;
}
if (handshake.getPlaneCount() != expectedPlaneCount) {
connection.close("The connection handshake has incorrect number of planes. " + "Expected " + expectedPlaneCount + " found " + handshake.getPlaneCount(), null);
return;
}
// before we register the connection on the plane, we make sure the plane index is set on the connection
// so that we can safely remove the connection from the plane.
connection.setPlaneIndex(handshake.getPlaneIndex());
process(connection, handshake);
}
use of com.hazelcast.internal.cluster.impl.MemberHandshake in project hazelcast by hazelcast.
the class SendMemberHandshakeTask method run.
@Override
public void run() {
connection.setRemoteAddress(remoteAddress);
serverContext.onSuccessfulConnection(remoteAddress);
// make sure memberHandshake packet is the first packet sent to the end point.
if (logger.isFinestEnabled()) {
logger.finest("Sending memberHandshake packet to " + remoteAddress);
}
MemberHandshake memberHandshake = new MemberHandshake(SCHEMA_VERSION_2, getConfiguredLocalAddresses(), remoteAddress, reply, serverContext.getThisUuid()).addOption(OPTION_PLANE_COUNT, planeCount).addOption(OPTION_PLANE_INDEX, planeIndex);
byte[] bytes = serverContext.getSerializationService().toBytes(memberHandshake);
Packet packet = new Packet(bytes).setPacketType(Packet.Type.SERVER_CONTROL);
connection.write(packet);
// now you can send anything...
}
use of com.hazelcast.internal.cluster.impl.MemberHandshake in project hazelcast by hazelcast.
the class TcpServerControlTest method memberHandshakeMessage.
private Packet memberHandshakeMessage() {
MemberHandshake handshake = new MemberHandshake(SCHEMA_VERSION_2, localAddresses, new Address(CLIENT_SOCKET_ADDRESS), reply, MEMBER_UUID);
Packet packet = new Packet(serializationService.toBytes(handshake));
connection = new TcpServerConnection(connectionManager, lifecycleListener, 1, channel, false);
if (connectionType != null) {
connection.setConnectionType(connectionType);
}
packet.setConn(connection);
return packet;
}
Aggregations