use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketDispatcherTest method whenUnrecognizedPacket_thenSwallowed.
// unrecognized packets are logged. No handlers is contacted.
@Test
public void whenUnrecognizedPacket_thenSwallowed() {
Packet packet = new Packet().setPacketType(Packet.Type.NULL);
dispatcher.accept(packet);
verifyZeroInteractions(responseHandler, operationExecutor, eventService, invocationMonitor, jetService);
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketDispatcherTest method whenOperationControlPacket.
@Test
public void whenOperationControlPacket() {
Packet packet = new Packet().setPacketType(Packet.Type.OPERATION).raiseFlags(FLAG_OP_CONTROL);
dispatcher.accept(packet);
verify(invocationMonitor).accept(packet);
verifyZeroInteractions(responseHandler, operationExecutor, eventService, jetService);
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketIOHelperTest method lotsOfPackets.
@Test
public void lotsOfPackets() {
List<Packet> originalPackets = new LinkedList<Packet>();
Random random = new Random();
for (int k = 0; k < 1000; k++) {
byte[] bytes = generateRandomString(random.nextInt(1000) + 8).getBytes();
Packet originalPacket = new Packet(bytes);
originalPackets.add(originalPacket);
}
ByteBuffer bb = ByteBuffer.allocate(20);
for (Packet originalPacket : originalPackets) {
Packet clonedPacket;
boolean writeCompleted;
do {
writeCompleted = packetWriter.writeTo(originalPacket, bb);
upcast(bb).flip();
clonedPacket = packetReader.readFrom(bb);
upcast(bb).clear();
} while (!writeCompleted);
assertNotNull(clonedPacket);
assertPacketEquals(originalPacket, clonedPacket);
}
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class MockServerConnection method write.
public boolean write(OutboundFrame frame) {
if (!isAlive()) {
return false;
}
Packet packet = (Packet) frame;
Packet newPacket = readFromPacket(packet);
try {
remoteNodeEngine.getPacketDispatcher().accept(newPacket);
} catch (Exception e) {
throw rethrow(e);
}
return true;
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class OverloadedConnectionsPluginTest method assertToKey.
private void assertToKey(String key, Object object) {
Packet packet = new Packet(serializationService.toBytes(object));
assertEquals(key, plugin.toKey(packet));
}
Aggregations