Search in sources :

Example 1 with CallTimeoutResponse

use of com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse in project hazelcast by hazelcast.

the class ParkedOperation method isCallTimedOut.

public boolean isCallTimedOut() {
    final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    InternalOperationService operationService = nodeEngine.getOperationService();
    if (operationService.isCallTimedOut(op)) {
        cancel(new CallTimeoutResponse(op.getCallId(), op.isUrgent()));
        return true;
    }
    return false;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) CallTimeoutResponse(com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse) InternalOperationService(com.hazelcast.spi.impl.operationservice.InternalOperationService)

Example 2 with CallTimeoutResponse

use of com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse 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);
    }
}
Also used : CallTimeoutResponse(com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse) Response(com.hazelcast.spi.impl.operationservice.impl.responses.Response) BackupAckResponse(com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse) NormalResponse(com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse) ErrorResponse(com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse) CallTimeoutResponse(com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse) BackupAckResponse(com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse) Address(com.hazelcast.nio.Address) NormalResponse(com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse) ErrorResponse(com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse)

Example 3 with CallTimeoutResponse

use of com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse in project hazelcast by hazelcast.

the class WaitSetEntry method isCallTimedOut.

public boolean isCallTimedOut() {
    final NodeEngineImpl nodeEngine = (NodeEngineImpl) getNodeEngine();
    OperationServiceImpl operationService = nodeEngine.getOperationService();
    if (operationService.isCallTimedOut(op)) {
        cancel(new CallTimeoutResponse(op.getCallId(), op.isUrgent()));
        return true;
    }
    return false;
}
Also used : NodeEngineImpl(com.hazelcast.spi.impl.NodeEngineImpl) CallTimeoutResponse(com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse) OperationServiceImpl(com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)

Example 4 with CallTimeoutResponse

use of com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse in project hazelcast by hazelcast.

the class OutboundResponseHandlerTest method sendResponse_whenTimeoutResponse.

@Test
public void sendResponse_whenTimeoutResponse() {
    CallTimeoutResponse response = new CallTimeoutResponse(10, false);
    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, response);
    // verify that the right object was send
    assertEquals(serializationService.toData(response), argument.getValue());
}
Also used : Packet(com.hazelcast.internal.nio.Packet) CallTimeoutResponse(com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse) 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 CallTimeoutResponse

use of com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse 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)

Aggregations

CallTimeoutResponse (com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse)5 NodeEngineImpl (com.hazelcast.spi.impl.NodeEngineImpl)2 ErrorResponse (com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse)2 NormalResponse (com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse)2 Packet (com.hazelcast.internal.nio.Packet)1 Address (com.hazelcast.nio.Address)1 ResponseAlreadySentException (com.hazelcast.spi.exception.ResponseAlreadySentException)1 InternalOperationService (com.hazelcast.spi.impl.operationservice.InternalOperationService)1 Operation (com.hazelcast.spi.impl.operationservice.Operation)1 OperationServiceImpl (com.hazelcast.spi.impl.operationservice.impl.OperationServiceImpl)1 BackupAckResponse (com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse)1 Response (com.hazelcast.spi.impl.operationservice.impl.responses.Response)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1 Test (org.junit.Test)1