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);
}
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);
}
}
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();
}
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);
}
Aggregations