@Override public OperationRunner createGenericRunner() { return new OperationRunnerImpl(operationService, GENERIC_PARTITION_ID, genericId++, null); } }
@Override public void run(Operation op) { executedOperationsCounter.inc(); boolean publishCurrentTask = publishCurrentTask(); if (publishCurrentTask) { currentTask = op; } try { checkNodeState(op); if (timeout(op)) { return; } ensureNoPartitionProblems(op); ensureQuorumPresent(op); op.beforeRun(); call(op); } catch (Throwable e) { handleOperationError(op, e); } finally { if (publishCurrentTask) { currentTask = null; } } }
private boolean publishCurrentTask() { boolean isClientRunnable = currentTask instanceof MessageTask; return getPartitionId() != AD_HOC_PARTITION_ID && (currentTask == null || isClientRunnable); }
@Override public void run(Packet packet) throws Exception { boolean publishCurrentTask = publishCurrentTask(); setCallerAddress(op, caller); setConnection(op, connection); setCallerUuidIfNotSet(caller, op); setOperationResponseHandler(op); if (!ensureValidMember(op)) { return; currentTask = null; run(op); } catch (Throwable throwable) { long callId = extractOperationCallId(packet); outboundResponseHandler.send(caller, new ErrorResponse(throwable, callId, packet.isUrgent())); logOperationDeserializationException(throwable, callId); throw ExceptionUtil.rethrow(throwable); } finally {
private void ensureNoPartitionProblems(Operation op) { int partitionId = op.getPartitionId(); if (partitionId < 0) { return; } if (partitionId != getPartitionId()) { throw new IllegalStateException("wrong partition, expected: " + getPartitionId() + " but found:" + partitionId); } if (internalPartition == null) { internalPartition = nodeEngine.getPartitionService().getPartition(partitionId); } if (!isAllowedToRetryDuringMigration(op) && internalPartition.isMigrating()) { throw new PartitionMigratingException(thisAddress, partitionId, op.getClass().getName(), op.getServiceName()); } Address owner = internalPartition.getReplicaAddress(op.getReplicaIndex()); if (op.validatesTarget() && !thisAddress.equals(owner)) { throw new WrongTargetException(thisAddress, owner, partitionId, op.getReplicaIndex(), op.getClass().getName(), op.getServiceName()); } }
private void call(Operation op) throws Exception { CallStatus callStatus = op.call(); switch (callStatus.ordinal()) { case DONE_RESPONSE_ORDINAL: handleResponse(op); afterRun(op); break; case DONE_VOID_ORDINAL: op.afterRun(); break; case OFFLOAD_ORDINAL: op.afterRun(); Offload offload = (Offload) callStatus; offload.init(nodeEngine, operationService.asyncOperations); offload.start(); break; case WAIT_ORDINAL: nodeEngine.getOperationParker().park((BlockingOperation) op); break; default: throw new IllegalStateException(); } }
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 run(Packet packet) throws Exception { boolean publishCurrentTask = publishCurrentTask(); setCallerAddress(op, caller); setConnection(op, connection); setCallerUuidIfNotSet(caller, op); setOperationResponseHandler(op); if (!ensureValidMember(op)) { return; currentTask = null; run(op); } catch (Throwable throwable) { long callId = extractOperationCallId(packet); outboundResponseHandler.send(caller, new ErrorResponse(throwable, callId, packet.isUrgent())); logOperationDeserializationException(throwable, callId); throw ExceptionUtil.rethrow(throwable); } finally {
private void ensureNoPartitionProblems(Operation op) { int partitionId = op.getPartitionId(); if (partitionId < 0) { return; } if (partitionId != getPartitionId()) { throw new IllegalStateException("wrong partition, expected: " + getPartitionId() + " but found:" + partitionId); } if (internalPartition == null) { internalPartition = nodeEngine.getPartitionService().getPartition(partitionId); } if (!isAllowedToRetryDuringMigration(op) && internalPartition.isMigrating()) { throw new PartitionMigratingException(thisAddress, partitionId, op.getClass().getName(), op.getServiceName()); } PartitionReplica owner = internalPartition.getReplica(op.getReplicaIndex()); if (op.validatesTarget() && (owner == null || !owner.isIdentical(node.getLocalMember()))) { Member target = owner != null ? node.getClusterService().getMember(owner.address(), owner.uuid()) : null; throw new WrongTargetException(node.getLocalMember(), target, partitionId, op.getReplicaIndex(), op.getClass().getName(), op.getServiceName()); } }
private void call(Operation op) throws Exception { CallStatus callStatus = op.call(); switch (callStatus.ordinal()) { case DONE_RESPONSE_ORDINAL: handleResponse(op); afterRun(op); break; case DONE_VOID_ORDINAL: op.afterRun(); break; case OFFLOAD_ORDINAL: op.afterRun(); Offload offload = (Offload) callStatus; offload.init(nodeEngine, operationService.asyncOperations); offload.start(); break; case WAIT_ORDINAL: nodeEngine.getOperationParker().park((BlockingOperation) op); break; default: throw new IllegalStateException(); } }
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 run(Operation op) { executedOperationsCounter.inc(); boolean publishCurrentTask = publishCurrentTask(); if (publishCurrentTask) { currentTask = op; } try { checkNodeState(op); if (timeout(op)) { return; } ensureNoPartitionProblems(op); ensureQuorumPresent(op); op.beforeRun(); call(op); } catch (Throwable e) { handleOperationError(op, e); } finally { if (publishCurrentTask) { currentTask = null; } } }
@Override public OperationRunner createPartitionRunner(int partitionId) { return new OperationRunnerImpl(operationService, partitionId, 0, operationService.failedBackupsCount); }
private boolean publishCurrentTask() { boolean isClientRunnable = currentTask instanceof MessageTask; return getPartitionId() != AD_HOC_PARTITION_ID && (currentTask == null || isClientRunnable); }
@Override public OperationRunner createAdHocRunner() { return new OperationRunnerImpl(operationService, AD_HOC_PARTITION_ID, 0, null); }
@Override public OperationRunner createGenericRunner() { return new OperationRunnerImpl(operationService, GENERIC_PARTITION_ID, genericId++, null); } }
@Override public OperationRunner createAdHocRunner() { return new OperationRunnerImpl(operationService, AD_HOC_PARTITION_ID, 0, null); }
@Override public OperationRunner createPartitionRunner(int partitionId) { return new OperationRunnerImpl(operationService, partitionId, 0, operationService.failedBackupsCount); }