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);
}
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);
}
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;
}
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);
}
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());
}
});
}
Aggregations