use of com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse in project hazelcast by hazelcast.
the class PartitionIteratingOperation method onExecutionFailure.
@Override
public void onExecutionFailure(Throwable cause) {
// we also send a response so that the caller doesn't wait indefinitely.
sendResponse(new ErrorResponse(cause, getCallId(), isUrgent()));
getLogger().severe(cause);
}
use of com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse in project hazelcast by hazelcast.
the class Invocation method sendResponse.
@Override
public void sendResponse(Operation op, Object response) {
if (!RESPONSE_RECEIVED.compareAndSet(this, FALSE, TRUE)) {
throw new ResponseAlreadySentException("NormalResponse already responseReceived for callback: " + this + ", current-response: " + response);
}
if (response instanceof CallTimeoutResponse) {
notifyCallTimeout();
} else if (response instanceof ErrorResponse || response instanceof Throwable) {
notifyError(response);
} else if (response instanceof NormalResponse) {
NormalResponse normalResponse = (NormalResponse) response;
notifyNormalResponse(normalResponse.getValue(), normalResponse.getBackupAcks());
} else {
// there are no backups or the number of expected backups has returned; so signal the future that the result is ready
complete(response);
}
}
use of com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse in project hazelcast by hazelcast.
the class OutboundResponseHandlerTest method sendResponse_whenThrowable.
@Test
public void sendResponse_whenThrowable() {
Exception exception = new Exception();
Operation op = createDummyOperation(10);
ArgumentCaptor<Packet> argument = ArgumentCaptor.forClass(Packet.class);
when(connectionManager.transmit(argument.capture(), eq(thatAddress), anyInt())).thenReturn(true);
// make the call
handler.sendResponse(op, exception);
// verify that the right object was send
ErrorResponse expectedResponse = new ErrorResponse(exception, op.getCallId(), op.isUrgent());
assertEquals(serializationService.toData(expectedResponse), argument.getValue());
}
Aggregations