Search in sources :

Example 1 with IndeterminateOperationState

use of com.hazelcast.core.IndeterminateOperationState in project hazelcast by hazelcast.

the class InvocationFuture method resolve.

@SuppressWarnings({ "checkstyle:npathcomplexity", "checkstyle:cyclomaticcomplexity" })
@Override
protected Object resolve(Object unresolved) {
    if (unresolved == null) {
        return null;
    } else if (unresolved == INTERRUPTED) {
        return new ExceptionalResult(new InterruptedException(invocation.op.getClass().getSimpleName() + " was interrupted. " + invocation));
    } else if (unresolved == CALL_TIMEOUT) {
        return new ExceptionalResult(newOperationTimeoutException(false));
    } else if (unresolved == HEARTBEAT_TIMEOUT) {
        return new ExceptionalResult(newOperationTimeoutException(true));
    } else if (unresolved.getClass() == Packet.class) {
        NormalResponse response = invocation.context.serializationService.toObject(unresolved);
        unresolved = response.getValue();
    }
    Object value = unresolved;
    if (deserialize && value instanceof Data) {
        value = invocation.context.serializationService.toObject(value);
        if (value == null) {
            return null;
        }
    }
    Throwable cause = (value instanceof ExceptionalResult) ? ((ExceptionalResult) value).getCause() : null;
    if (invocation.shouldFailOnIndeterminateOperationState() && (value instanceof IndeterminateOperationState || cause instanceof IndeterminateOperationState)) {
        value = wrapThrowable(new IndeterminateOperationStateException("indeterminate operation state", cause == null ? (Throwable) value : cause));
    }
    return value;
}
Also used : Data(com.hazelcast.internal.serialization.Data) IndeterminateOperationStateException(com.hazelcast.core.IndeterminateOperationStateException) NormalResponse(com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse) IndeterminateOperationState(com.hazelcast.core.IndeterminateOperationState)

Aggregations

IndeterminateOperationState (com.hazelcast.core.IndeterminateOperationState)1 IndeterminateOperationStateException (com.hazelcast.core.IndeterminateOperationStateException)1 Data (com.hazelcast.internal.serialization.Data)1 NormalResponse (com.hazelcast.spi.impl.operationservice.impl.responses.NormalResponse)1