Search in sources :

Example 1 with ResponseAlreadySentException

use of com.hazelcast.spi.exception.ResponseAlreadySentException 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 2 with ResponseAlreadySentException

use of com.hazelcast.spi.exception.ResponseAlreadySentException 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

ResponseAlreadySentException (com.hazelcast.spi.exception.ResponseAlreadySentException)2 NormalResponse (com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse)2 CallTimeoutResponse (com.hazelcast.spi.impl.operationservice.impl.responses.CallTimeoutResponse)1 ErrorResponse (com.hazelcast.spi.impl.operationservice.impl.responses.ErrorResponse)1