Search in sources :

Example 6 with NormalResponse

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

the class OperationRunnerImpl method sendResponse.

private void sendResponse(Operation op, int backupAcks) {
    try {
        Object response = op.getResponse();
        if (backupAcks > 0) {
            response = new NormalResponse(response, op.getCallId(), backupAcks, op.isUrgent());
        }
        op.sendResponse(response);
    } catch (ResponseAlreadySentException e) {
        logOperationError(op, e);
    }
}
Also used : NormalResponse(com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse) ResponseAlreadySentException(com.hazelcast.spi.exception.ResponseAlreadySentException)

Example 7 with NormalResponse

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

NormalResponse (com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse)7 Packet (com.hazelcast.nio.Packet)4 AssertTask (com.hazelcast.test.AssertTask)4 QuickTest (com.hazelcast.test.annotation.QuickTest)4 Test (org.junit.Test)4 ExpectedRuntimeException (com.hazelcast.test.ExpectedRuntimeException)3 ParallelTest (com.hazelcast.test.annotation.ParallelTest)3 ResponseAlreadySentException (com.hazelcast.spi.exception.ResponseAlreadySentException)2 CallTimeoutResponse (com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse)2 ErrorResponse (com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse)2 Address (com.hazelcast.nio.Address)1 BackupAckResponse (com.hazelcast.spi.impl.operationservice.impl.responses.BackupAckResponse)1 Response (com.hazelcast.spi.impl.operationservice.impl.responses.Response)1