Search in sources :

Example 1 with Packet

use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.

the class Invocation method notifyNormalResponse.

void notifyNormalResponse(Object value, int expectedBackups) {
    // we will complete the response immediately and delegate backup count to caller
    if (op.getClientCallId() != -1) {
        this.backupsAcksExpected = 0;
        if (value instanceof Packet) {
            NormalResponse response = context.serializationService.toObject(value);
            value = response.getValue();
        }
        complete(new ClientBackupAwareResponse(expectedBackups, value));
        return;
    }
    notifyResponse(value, expectedBackups);
}
Also used : Packet(com.hazelcast.internal.nio.Packet) ClientBackupAwareResponse(com.hazelcast.client.impl.ClientBackupAwareResponse) NormalResponse(com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse)

Example 2 with Packet

use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.

the class OutboundResponseHandler method sendBackupAck.

public void sendBackupAck(ServerConnectionManager connectionManager, Address target, long callId, boolean urgent) {
    checkTarget(target);
    Packet packet = toBackupAckPacket(callId, urgent);
    transmit(target, packet, connectionManager);
}
Also used : Packet(com.hazelcast.internal.nio.Packet)

Example 3 with Packet

use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.

the class OutboundOperationHandler method toPacket.

private Packet toPacket(Operation op) {
    byte[] bytes = serializationService.toBytes(op);
    int partitionId = op.getPartitionId();
    Packet packet = new Packet(bytes, partitionId).setPacketType(Packet.Type.OPERATION);
    if (op.isUrgent()) {
        packet.raiseFlags(FLAG_URGENT);
    }
    return packet;
}
Also used : Packet(com.hazelcast.internal.nio.Packet)

Example 4 with Packet

use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.

the class OperationThreadTest method executePacket_withInvalid_partitionId.

@Test
public void executePacket_withInvalid_partitionId() {
    final int partitionId = Integer.MAX_VALUE;
    Operation operation = new DummyPartitionOperation(partitionId);
    Packet packet = new Packet(serializationService.toBytes(operation), operation.getPartitionId()).setPacketType(Packet.Type.OPERATION);
    testExecute_withInvalid_partitionId(packet);
}
Also used : Packet(com.hazelcast.internal.nio.Packet) Operation(com.hazelcast.spi.impl.operationservice.Operation) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Example 5 with Packet

use of com.hazelcast.internal.nio.Packet in project hazelcast by hazelcast.

the class OperationThreadTest method testExecute_withInvalid_partitionId.

private void testExecute_withInvalid_partitionId(Object task) {
    handlerFactory = mock(OperationRunnerFactory.class);
    OperationRunner handler = mock(OperationRunner.class);
    when(handlerFactory.createGenericRunner()).thenReturn(handler);
    when(handlerFactory.createPartitionRunner(anyInt())).thenReturn(handler);
    initExecutor();
    if (task instanceof Operation) {
        executor.execute((Operation) task);
    } else if (task instanceof PartitionSpecificRunnable) {
        executor.execute((PartitionSpecificRunnable) task);
    } else if (task instanceof Packet) {
        executor.accept((Packet) task);
    } else {
        fail("invalid task!");
    }
    final Runnable emptyRunnable = new Runnable() {

        @Override
        public void run() {
        }
    };
    executor.executeOnPartitionThreads(emptyRunnable);
    assertTrueEventually(new AssertTask() {

        @Override
        public void run() throws Exception {
            assertEquals(0, executor.getPriorityQueueSize());
        }
    });
}
Also used : Packet(com.hazelcast.internal.nio.Packet) OperationRunnerFactory(com.hazelcast.spi.impl.operationexecutor.OperationRunnerFactory) PartitionSpecificRunnable(com.hazelcast.spi.impl.PartitionSpecificRunnable) AssertTask(com.hazelcast.test.AssertTask) OperationRunner(com.hazelcast.spi.impl.operationexecutor.OperationRunner) Operation(com.hazelcast.spi.impl.operationservice.Operation) PartitionSpecificRunnable(com.hazelcast.spi.impl.PartitionSpecificRunnable)

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