public void deregister(Operation operation) { Map<Long, Operation> operations = liveOperations.get(operation.getCallerAddress()); if (operations == null) { throw new IllegalStateException("Missing address during de-registration of operation=" + operation); } if (operations.remove(operation.getCallId()) == null) { throw new IllegalStateException("Missing operation during de-registration of operation=" + operation); } }
public void register(Operation operation) { Map<Long, Operation> callIds = liveOperations.computeIfAbsent(operation.getCallerAddress(), (key) -> new ConcurrentHashMap<>()); if (callIds.putIfAbsent(operation.getCallId(), operation) != null) { throw new IllegalStateException("Duplicate operation during registration of operation=" + operation); } }
private void scan(OperationRunner[] runners, LiveOperations result) { for (OperationRunner runner : runners) { Object task = runner.currentTask(); if (!(task instanceof Operation) || task.getClass() == Backup.class) { continue; } Operation operation = (Operation) task; result.add(operation.getCallerAddress(), operation.getCallId()); } }
private void scan(OperationRunner[] runners, LiveOperations result) { for (OperationRunner runner : runners) { Object task = runner.currentTask(); if (!(task instanceof Operation) || task.getClass() == Backup.class) { continue; } Operation operation = (Operation) task; result.add(operation.getCallerAddress(), operation.getCallId()); } }
private boolean ensureValidMember(Operation op) { if (node.clusterService.getMember(op.getCallerAddress()) != null || isJoinOperation(op) || isWanReplicationOperation(op)) { return true; } Exception error = new CallerNotMemberException(thisAddress, op.getCallerAddress(), op.getPartitionId(), op.getClass().getName(), op.getServiceName()); handleOperationError(op, error); return false; }
private boolean ensureValidMember(Operation op) { if (node.clusterService.getMember(op.getCallerAddress()) != null || isJoinOperation(op) || isWanReplicationOperation(op)) { return true; } Exception error = new CallerNotMemberException(thisAddress, op.getCallerAddress(), op.getPartitionId(), op.getClass().getName(), op.getServiceName()); handleOperationError(op, error); return false; }
@Override public void populate(LiveOperations liveOperations) { for (WaitSetEntry entry : queue) { // we need to read out the data from the BlockedOperation; not from the WaitSetEntry Operation operation = entry.getOperation(); liveOperations.add(operation.getCallerAddress(), operation.getCallId()); } }
@Override public void populate(LiveOperations liveOperations) { operationExecutor.populate(liveOperations); for (Operation op : asyncOperations) { liveOperations.add(op.getCallerAddress(), op.getCallId()); } }
@Override public void populate(LiveOperations liveOperations) { for (WaitSetEntry entry : queue) { // we need to read out the data from the BlockedOperation; not from the WaitSetEntry Operation operation = entry.getOperation(); liveOperations.add(operation.getCallerAddress(), operation.getCallId()); } }
@Override public void populate(LiveOperations liveOperations) { operationExecutor.populate(liveOperations); for (Operation op : asyncOperations) { liveOperations.add(op.getCallerAddress(), op.getCallId()); } }
private static Backup newBackup(BackupAwareOperation backupAwareOp, Object backupOp, long[] replicaVersions, int replicaIndex, boolean respondBack) { Operation op = (Operation) backupAwareOp; Backup backup; if (backupOp instanceof Operation) { backup = new Backup((Operation) backupOp, op.getCallerAddress(), replicaVersions, respondBack); } else if (backupOp instanceof Data) { backup = new Backup((Data) backupOp, op.getCallerAddress(), replicaVersions, respondBack); } else { throw new IllegalArgumentException("Only 'Data' or 'Operation' typed backup operation is supported!"); } backup.setPartitionId(op.getPartitionId()).setReplicaIndex(replicaIndex); if (hasActiveInvocation(op)) { setCallId(backup, op.getCallId()); } return backup; }
private static Backup newBackup(BackupAwareOperation backupAwareOp, Object backupOp, long[] replicaVersions, int replicaIndex, boolean respondBack) { Operation op = (Operation) backupAwareOp; Backup backup; if (backupOp instanceof Operation) { backup = new Backup((Operation) backupOp, op.getCallerAddress(), replicaVersions, respondBack); } else if (backupOp instanceof Data) { backup = new Backup((Data) backupOp, op.getCallerAddress(), replicaVersions, respondBack); } else { throw new IllegalArgumentException("Only 'Data' or 'Operation' typed backup operation is supported!"); } backup.setPartitionId(op.getPartitionId()).setReplicaIndex(replicaIndex); if (hasActiveInvocation(op)) { setCallId(backup, op.getCallId()); } return backup; }
public void onShutdown() { Object response = new HazelcastInstanceNotActiveException(); Address thisAddress = nodeEngine.getThisAddress(); for (WaitSetEntry entry : queue) { if (!entry.isValid()) { continue; } Operation op = entry.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); } } queue.clear(); } }
public void onShutdown() { Object response = new HazelcastInstanceNotActiveException(); Address thisAddress = nodeEngine.getThisAddress(); for (WaitSetEntry entry : queue) { if (!entry.isValid()) { continue; } Operation op = entry.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); } } queue.clear(); } }
@Override public void sendResponse(Operation operation, Object obj) { Address target = operation.getCallerAddress(); boolean send; if (obj == null) { send = sendNormalResponse(target, operation.getCallId(), 0, operation.isUrgent(), null); } else if (obj.getClass() == NormalResponse.class) { NormalResponse response = (NormalResponse) obj; send = sendNormalResponse( target, response.getCallId(), response.getBackupAcks(), response.isUrgent(), response.getValue()); } else if (obj.getClass() == ErrorResponse.class || obj.getClass() == CallTimeoutResponse.class) { send = send(target, (Response) obj); } else if (obj instanceof Throwable) { send = send(target, new ErrorResponse((Throwable) obj, operation.getCallId(), operation.isUrgent())); } else { // most regular responses not wrapped in a NormalResponse. So we are now completely skipping the // NormalResponse instance send = sendNormalResponse(target, operation.getCallId(), 0, operation.isUrgent(), obj); } if (!send) { logger.warning("Cannot send response: " + obj + " to " + target + ". " + operation); } }
@Override public void sendResponse(Operation operation, Object obj) { Address target = operation.getCallerAddress(); boolean send; if (obj == null) { send = sendNormalResponse(target, operation.getCallId(), 0, operation.isUrgent(), null); } else if (obj.getClass() == NormalResponse.class) { NormalResponse response = (NormalResponse) obj; send = sendNormalResponse( target, response.getCallId(), response.getBackupAcks(), response.isUrgent(), response.getValue()); } else if (obj.getClass() == ErrorResponse.class || obj.getClass() == CallTimeoutResponse.class) { send = send(target, (Response) obj); } else if (obj instanceof Throwable) { send = send(target, new ErrorResponse((Throwable) obj, operation.getCallId(), operation.isUrgent())); } else { // most regular responses not wrapped in a NormalResponse. So we are now completely skipping the // NormalResponse instance send = sendNormalResponse(target, operation.getCallId(), 0, operation.isUrgent(), obj); } if (!send) { logger.warning("Cannot send response: " + obj + " to " + target + ". " + operation); } }