Search in sources :

Example 6 with OperationResponseHandler

use of com.hazelcast.spi.OperationResponseHandler in project hazelcast by hazelcast.

the class OperationRunnerImpl method setOperationResponseHandler.

private void setOperationResponseHandler(Operation op) {
    OperationResponseHandler handler = outboundResponseHandler;
    if (op.getCallId() == 0) {
        if (op.returnsResponse()) {
            throw new HazelcastException("Operation " + op + " wants to return a response, but doesn't have a call ID");
        }
        handler = createEmptyResponseHandler();
    }
    op.setOperationResponseHandler(handler);
}
Also used : HazelcastException(com.hazelcast.core.HazelcastException) RetryableHazelcastException(com.hazelcast.spi.exception.RetryableHazelcastException) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler)

Example 7 with OperationResponseHandler

use of com.hazelcast.spi.OperationResponseHandler in project hazelcast by hazelcast.

the class ParkedOperation method run.

@Override
public void run() throws Exception {
    if (!valid) {
        return;
    }
    boolean expired = isExpired();
    boolean cancelled = isCancelled();
    if (!expired && !cancelled) {
        return;
    }
    if (!queue.remove(this)) {
        return;
    }
    valid = false;
    if (expired) {
        blockingOperation.onWaitExpire();
    } else {
        OperationResponseHandler responseHandler = op.getOperationResponseHandler();
        responseHandler.sendResponse(op, cancelResponse);
    }
}
Also used : OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler)

Example 8 with OperationResponseHandler

use of com.hazelcast.spi.OperationResponseHandler in project hazelcast by hazelcast.

the class OperationParkerImpl method shutdown.

public void shutdown() {
    logger.finest("Stopping tasks...");
    expirationTaskFuture.cancel(true);
    expirationExecutor.shutdown();
    final Object response = new HazelcastInstanceNotActiveException();
    final Address thisAddress = nodeEngine.getThisAddress();
    for (Queue<ParkedOperation> parkQueue : parkQueueMap.values()) {
        for (ParkedOperation parkedOperation : parkQueue) {
            if (!parkedOperation.isValid()) {
                continue;
            }
            Operation op = parkedOperation.getOperation();
            // only for local invocations, remote ones will be expired via #onMemberLeft()
            if (thisAddress.equals(op.getCallerAddress())) {
                try {
                    OperationResponseHandler responseHandler = op.getOperationResponseHandler();
                    responseHandler.sendResponse(op, response);
                } catch (Exception e) {
                    logger.finest("While sending HazelcastInstanceNotActiveException response...", e);
                }
            }
        }
        parkQueue.clear();
    }
    parkQueueMap.clear();
}
Also used : HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) Address(com.hazelcast.nio.Address) BlockingOperation(com.hazelcast.spi.BlockingOperation) Operation(com.hazelcast.spi.Operation) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler) HazelcastInstanceNotActiveException(com.hazelcast.core.HazelcastInstanceNotActiveException) PartitionMigratingException(com.hazelcast.spi.exception.PartitionMigratingException)

Example 9 with OperationResponseHandler

use of com.hazelcast.spi.OperationResponseHandler in project hazelcast by hazelcast.

the class ReplicaSyncResponse method prepareOperation.

private void prepareOperation(Operation op) {
    int partitionId = getPartitionId();
    int replicaIndex = getReplicaIndex();
    NodeEngine nodeEngine = getNodeEngine();
    ILogger opLogger = nodeEngine.getLogger(op.getClass());
    OperationResponseHandler responseHandler = createErrorLoggingResponseHandler(opLogger);
    op.setNodeEngine(nodeEngine).setPartitionId(partitionId).setReplicaIndex(replicaIndex).setOperationResponseHandler(responseHandler);
}
Also used : NodeEngine(com.hazelcast.spi.NodeEngine) ILogger(com.hazelcast.logging.ILogger) OperationResponseHandler(com.hazelcast.spi.OperationResponseHandler)

Aggregations

OperationResponseHandler (com.hazelcast.spi.OperationResponseHandler)9 Operation (com.hazelcast.spi.Operation)6 NodeEngine (com.hazelcast.spi.NodeEngine)5 ILogger (com.hazelcast.logging.ILogger)2 BlockingOperation (com.hazelcast.spi.BlockingOperation)2 OperationService (com.hazelcast.spi.OperationService)2 PartitionMigratingException (com.hazelcast.spi.exception.PartitionMigratingException)2 HazelcastException (com.hazelcast.core.HazelcastException)1 HazelcastInstanceNotActiveException (com.hazelcast.core.HazelcastInstanceNotActiveException)1 MapOperation (com.hazelcast.map.impl.operation.MapOperation)1 MapOperationProvider (com.hazelcast.map.impl.operation.MapOperationProvider)1 RemoveFromLoadAllOperation (com.hazelcast.map.impl.operation.RemoveFromLoadAllOperation)1 Address (com.hazelcast.nio.Address)1 UrgentSystemOperation (com.hazelcast.spi.UrgentSystemOperation)1 RetryableHazelcastException (com.hazelcast.spi.exception.RetryableHazelcastException)1