use of com.hazelcast.jet.impl.util.CompletionToken in project hazelcast-jet by hazelcast.
the class MasterContext method invokeStartExecution.
// If a participant leaves or the execution fails in a participant locally, executions are cancelled
// on the remaining participants and the callback is completed after all invocations return.
private void invokeStartExecution() {
logger.fine("Executing " + jobIdString());
long executionId = this.executionId;
ExecutionInvocationCallback callback = new ExecutionInvocationCallback(executionId);
cancellationToken.whenCompleted(callback::cancelInvocations);
CompletionToken executionRestartToken = new CompletionToken(logger);
executionRestartToken.whenCompleted(callback::cancelInvocations);
Function<ExecutionPlan, Operation> operationCtor = plan -> new StartExecutionOperation(jobId, executionId);
Consumer<Map<MemberInfo, Object>> completionCallback = results -> {
this.executionRestartToken = null;
onExecuteStepCompleted(results, executionRestartToken.isCompleted());
};
// We must set executionRestartToken before we call invoke() method because once all invocations
// are done, executionRestartToken will be reset. Therefore, setting it after the invoke() call is racy.
this.executionRestartToken = executionRestartToken;
jobStatus.set(RUNNING);
invoke(operationCtor, completionCallback, callback);
if (isSnapshottingEnabled()) {
coordinationService.scheduleSnapshot(jobId, executionId);
}
}
Aggregations