Search in sources :

Example 16 with Packet

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);
}
Also used : Packet(com.hazelcast.internal.nio.Packet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 17 with Packet

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);
}
Also used : Packet(com.hazelcast.internal.nio.Packet) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 18 with Packet

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);
    }
}
Also used : Packet(com.hazelcast.internal.nio.Packet) Random(java.util.Random) ByteBuffer(java.nio.ByteBuffer) LinkedList(java.util.LinkedList) QuickTest(com.hazelcast.test.annotation.QuickTest) SerializationConcurrencyTest(com.hazelcast.internal.serialization.impl.SerializationConcurrencyTest) Test(org.junit.Test)

Example 19 with Packet

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;
}
Also used : Packet(com.hazelcast.internal.nio.Packet) UnknownHostException(java.net.UnknownHostException)

Example 20 with Packet

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));
}
Also used : Packet(com.hazelcast.internal.nio.Packet)

Aggregations

Packet (com.hazelcast.internal.nio.Packet)65 Test (org.junit.Test)46 QuickTest (com.hazelcast.test.annotation.QuickTest)41 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)19 Operation (com.hazelcast.spi.impl.operationservice.Operation)11 ByteBuffer (java.nio.ByteBuffer)10 NormalResponse (com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse)9 AssertTask (com.hazelcast.test.AssertTask)6 PacketIOHelper (com.hazelcast.internal.nio.PacketIOHelper)5 SerializationConcurrencyTest (com.hazelcast.internal.serialization.impl.SerializationConcurrencyTest)3 OperationRunner (com.hazelcast.spi.impl.operationexecutor.OperationRunner)3 IOException (java.io.IOException)3 Address (com.hazelcast.cluster.Address)2 MemberHandshake (com.hazelcast.internal.cluster.impl.MemberHandshake)2 HandlerStatus (com.hazelcast.internal.networking.HandlerStatus)2 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)2 HeapData (com.hazelcast.internal.serialization.impl.HeapData)2 ServerConnection (com.hazelcast.internal.server.ServerConnection)2 ServerConnectionManager (com.hazelcast.internal.server.ServerConnectionManager)2 OperationRunnerFactory (com.hazelcast.spi.impl.operationexecutor.OperationRunnerFactory)2