use of com.hazelcast.internal.nio.PacketIOHelper in project hazelcast by hazelcast.
the class MockServerConnection method readFromPacket.
private Packet readFromPacket(Packet packet) {
Packet newPacket;
PacketIOHelper packetReader = new PacketIOHelper();
PacketIOHelper packetWriter = new PacketIOHelper();
ByteBuffer buffer = ByteBuffer.allocate(4096);
boolean writeDone;
do {
writeDone = packetWriter.writeTo(packet, buffer);
upcast(buffer).flip();
newPacket = packetReader.readFrom(buffer);
if (buffer.hasRemaining()) {
throw new IllegalStateException("Buffer should be empty! " + buffer);
}
upcast(buffer).clear();
} while (!writeDone);
assertNotNull(newPacket);
newPacket.setConn(otherConnection);
return newPacket;
}
Aggregations