use of com.hazelcast.jet.impl.exception.JobRestartRequestedException in project hazelcast-jet by hazelcast.
the class MasterContext method getExecuteResult.
/**
* <ul>
* <li>Returns null if there is no failure.
* <li>Returns CancellationException if the job is cancelled.
* <li>Returns JobRestartRequestedException if the current execution is cancelled
* <li>If there is at least one non-restartable failure, such as an exception in user code, then returns that failure.
* <li>Otherwise, the failure is because a job participant has left the cluster.
* In that case, {@code TopologyChangeException} is returned so that the job will be restarted.
* </ul>
*/
private Throwable getExecuteResult(Map<MemberInfo, Object> responses, boolean isRestartRequested) {
if (cancellationToken.isCompleted()) {
logger.fine(jobIdString() + " to be cancelled after execute");
return new CancellationException();
} else if (isRestartRequested) {
return new JobRestartRequestedException();
}
Map<Boolean, List<Entry<MemberInfo, Object>>> grouped = groupResponses(responses);
Collection<MemberInfo> successfulMembers = grouped.get(false).stream().map(Entry::getKey).collect(toList());
if (successfulMembers.size() == executionPlanMap.size()) {
logger.fine("Execute of " + jobIdString() + " is successful.");
return null;
}
List<Entry<MemberInfo, Object>> failures = grouped.get(true);
logger.fine("Execute of " + jobIdString() + " has failures: " + failures);
// In that case, all remaining participants return a CancellationException.
return failures.stream().map(e -> (Throwable) e.getValue()).filter(t -> !(t instanceof CancellationException || isTopologicalFailure(t))).findFirst().map(ExceptionUtil::peel).orElse(new TopologyChangedException());
}
Aggregations