use of com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse in project hazelcast by hazelcast.
the class InboundResponseHandler method handle.
@Override
public void handle(Packet packet) throws Exception {
Response response = serializationService.toObject(packet);
Address sender = packet.getConn().getEndPoint();
try {
if (response instanceof NormalResponse) {
NormalResponse normalResponse = (NormalResponse) response;
notifyNormalResponse(normalResponse.getCallId(), normalResponse.getValue(), normalResponse.getBackupAcks(), sender);
} else if (response instanceof BackupAckResponse) {
notifyBackupComplete(response.getCallId());
} else if (response instanceof CallTimeoutResponse) {
notifyCallTimeout(response.getCallId(), sender);
} else if (response instanceof ErrorResponse) {
ErrorResponse errorResponse = (ErrorResponse) response;
notifyErrorResponse(errorResponse.getCallId(), errorResponse.getCause(), sender);
} else {
logger.severe("Unrecognized response: " + response);
}
} catch (Throwable e) {
logger.severe("While processing response...", e);
}
}
use of com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse in project hazelcast by hazelcast.
the class AsyncInboundResponseHandlerTest method whenNoProblemPacket.
@Test
public void whenNoProblemPacket() throws Exception {
final Packet packet = new Packet(serializationService.toBytes(new NormalResponse("foo", 1, 0, false))).setPacketType(Packet.Type.OPERATION).raiseFlags(FLAG_OP_RESPONSE);
asyncHandler.handle(packet);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
verify(responsePacketHandler).handle(packet);
}
});
}
use of com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse in project hazelcast by hazelcast.
the class OperationExecutorImpl_HandlePacketTest method test_whenResponsePacket.
@Test
public void test_whenResponsePacket() {
initExecutor();
final NormalResponse normalResponse = new NormalResponse(null, 1, 0, false);
final Packet packet = new Packet(serializationService.toBytes(normalResponse), 0).setPacketType(Packet.Type.OPERATION).raiseFlags(FLAG_OP_RESPONSE);
executor.handle(packet);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
DummyResponsePacketHandler responsePacketHandler = (DummyResponsePacketHandler) OperationExecutorImpl_HandlePacketTest.this.responsePacketHandler;
responsePacketHandler.packets.contains(packet);
responsePacketHandler.responses.contains(normalResponse);
}
});
}
use of com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse in project hazelcast by hazelcast.
the class AsyncInboundResponseHandlerTest method whenPacketThrowsException.
@Test
public void whenPacketThrowsException() throws Exception {
final Packet badPacket = new Packet(serializationService.toBytes(new NormalResponse("bad", 1, 0, false))).setPacketType(Packet.Type.OPERATION).raiseFlags(FLAG_OP_RESPONSE);
final Packet goodPacket = new Packet(serializationService.toBytes(new NormalResponse("good", 1, 0, false))).setPacketType(Packet.Type.OPERATION).raiseFlags(FLAG_OP_RESPONSE);
doThrow(new ExpectedRuntimeException()).when(responsePacketHandler).handle(badPacket);
asyncHandler.handle(badPacket);
asyncHandler.handle(goodPacket);
assertTrueEventually(new AssertTask() {
@Override
public void run() throws Exception {
verify(responsePacketHandler).handle(goodPacket);
}
});
}
use of com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse in project hazelcast by hazelcast.
the class AsyncInboundResponseHandlerTest method whenShutdown.
@Test
public void whenShutdown() throws InterruptedException {
asyncHandler.shutdown();
// we need to wait for the responseThread to die first.
assertJoinable(asyncHandler.responseThread);
final Packet packet = new Packet(serializationService.toBytes(new NormalResponse("foo", 1, 0, false))).setPacketType(Packet.Type.OPERATION).raiseFlags(FLAG_OP_RESPONSE);
asyncHandler.handle(packet);
assertTrueFiveSeconds(new AssertTask() {
@Override
public void run() throws Exception {
verifyZeroInteractions(responsePacketHandler);
}
});
}
Aggregations