use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketDecoder method onRead.
@Override
public HandlerStatus onRead() throws Exception {
upcast(src).flip();
try {
while (src.hasRemaining()) {
Packet packet = packetReader.readFrom(src);
if (packet == null) {
break;
}
onPacketComplete(packet);
}
return CLEAN;
} finally {
compactOrClear(src);
}
}
use of com.hazelcast.internal.nio.Packet 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.nio.Packet in project hazelcast by hazelcast.
the class TcpServerConnectionManager_TransmitTest method withAddress_whenConnectionCantBeEstablished.
@Test
public void withAddress_whenConnectionCantBeEstablished() throws UnknownHostException {
final Packet packet = new Packet(serializationService.toBytes("foo"));
boolean result = tcpServerA.getConnectionManager(MEMBER).transmit(packet, new Address(addressA.getHost(), 6701));
// true is being returned because there is no synchronization on the connection being established
assertTrue(result);
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class TcpServerConnectionManager_TransmitTest method withAddress_whenConnectionExists.
@Test
public void withAddress_whenConnectionExists() {
tcpServerB.start();
final Packet packet = new Packet(serializationService.toBytes("foo"));
connect(tcpServerA, addressB);
boolean result = tcpServerA.getConnectionManager(MEMBER).transmit(packet, addressB);
assertTrue(result);
assertTrueEventually(() -> assertContains(packetsB, packet));
}
use of com.hazelcast.internal.nio.Packet 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