use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketDecoderTest method whenPriorityPacket.
@Test
public void whenPriorityPacket() throws Exception {
ByteBuffer src = ByteBuffer.allocate(1000);
Packet packet = new Packet(serializationService.toBytes("foobar")).raiseFlags(Packet.FLAG_URGENT);
new PacketIOHelper().writeTo(packet, src);
decoder.src(src);
decoder.onRead();
assertEquals(1, dispatcher.packets.size());
Packet found = dispatcher.packets.get(0);
assertEquals(packet, found);
assertEquals(0, normalPacketCounter.get());
assertEquals(1, priorityPacketCounter.get());
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketDecoderTest method whenMultiplePackets.
@Test
public void whenMultiplePackets() throws Exception {
ByteBuffer src = ByteBuffer.allocate(1000);
Packet packet1 = new Packet(serializationService.toBytes("packet1"));
new PacketIOHelper().writeTo(packet1, src);
Packet packet2 = new Packet(serializationService.toBytes("packet2"));
new PacketIOHelper().writeTo(packet2, src);
Packet packet3 = new Packet(serializationService.toBytes("packet3"));
new PacketIOHelper().writeTo(packet3, src);
Packet packet4 = new Packet(serializationService.toBytes("packet4"));
packet4.raiseFlags(Packet.FLAG_URGENT);
new PacketIOHelper().writeTo(packet4, src);
decoder.src(src);
decoder.onRead();
assertEquals(asList(packet1, packet2, packet3, packet4), dispatcher.packets);
assertEquals(3, normalPacketCounter.get());
assertEquals(1, priorityPacketCounter.get());
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketDecoderTest method whenNormalPacket.
@Test
public void whenNormalPacket() throws Exception {
ByteBuffer src = ByteBuffer.allocate(1000);
Packet packet = new Packet(serializationService.toBytes("foobar"));
new PacketIOHelper().writeTo(packet, src);
decoder.src(src);
decoder.onRead();
assertEquals(1, dispatcher.packets.size());
Packet found = dispatcher.packets.get(0);
assertEquals(packet, found);
assertEquals(1, normalPacketCounter.get());
assertEquals(0, priorityPacketCounter.get());
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketTest method resetFlagsTo.
@Test
public void resetFlagsTo() {
Packet packet = new Packet().setPacketType(Packet.Type.OPERATION);
packet.resetFlagsTo(FLAG_URGENT);
assertSame(Packet.Type.NULL, packet.getPacketType());
assertEquals(FLAG_URGENT, packet.getFlags());
}
use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.
the class PacketTest method isFlagSet.
@Test
public void isFlagSet() {
Packet packet = new Packet();
packet.setPacketType(Packet.Type.OPERATION);
packet.raiseFlags(FLAG_URGENT);
assertSame(Packet.Type.OPERATION, packet.getPacketType());
assertTrue(packet.isFlagRaised(FLAG_URGENT));
assertFalse(packet.isFlagRaised(FLAG_OP_CONTROL));
}
Aggregations