Search in sources :

Example 6 with ErrorResponse

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);
}
Also used : ErrorResponse(com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse)

Example 7 with ErrorResponse

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);
    }
}
Also used : CallTimeoutResponse(com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse) NormalResponse(com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse) ResponseAlreadySentException(com.hazelcast.spi.exception.ResponseAlreadySentException) ErrorResponse(com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse)

Example 8 with ErrorResponse

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());
}
Also used : Packet(com.hazelcast.internal.nio.Packet) Operation(com.hazelcast.spi.impl.operationservice.Operation) IOException(java.io.IOException) ErrorResponse(com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse) ParallelJVMTest(com.hazelcast.test.annotation.ParallelJVMTest) QuickTest(com.hazelcast.test.annotation.QuickTest) Test(org.junit.Test)

Aggregations

ErrorResponse (com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse)8 Address (com.hazelcast.cluster.Address)3 Operation (com.hazelcast.spi.impl.operationservice.Operation)3 CallTimeoutResponse (com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse)3 NormalResponse (com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse)3 Packet (com.hazelcast.internal.nio.Packet)2 Response (com.hazelcast.spi.impl.operationservice.impl.responses.Response)2 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)2 QuickTest (com.hazelcast.test.annotation.QuickTest)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 ServerConnection (com.hazelcast.internal.server.ServerConnection)1 ServerConnectionManager (com.hazelcast.internal.server.ServerConnectionManager)1 Address (com.hazelcast.nio.Address)1 ResponseAlreadySentException (com.hazelcast.spi.exception.ResponseAlreadySentException)1 BlockingOperation (com.hazelcast.spi.impl.operationservice.BlockingOperation)1 OperationAccessor.setCallerAddress (com.hazelcast.spi.impl.operationservice.OperationAccessor.setCallerAddress)1 Operations.isJoinOperation (com.hazelcast.spi.impl.operationservice.Operations.isJoinOperation)1 Operations.isMigrationOperation (com.hazelcast.spi.impl.operationservice.Operations.isMigrationOperation)1 Operations.isWanReplicationOperation (com.hazelcast.spi.impl.operationservice.Operations.isWanReplicationOperation)1