use of com.hazelcast.jet.core.JobStatus.FAILED in project hazelcast-jet by hazelcast.
the class MasterContext method getInitResult.
/**
* If there is no failure, then returns null. If the job is cancelled, then returns CancellationException.
* If there is at least one non-restartable failure, such as an exception in user code, then returns that failure.
* Otherwise, the failure is because a job participant has left the cluster.
* In that case, TopologyChangeException is returned so that the job will be restarted.
*/
private Throwable getInitResult(Map<MemberInfo, Object> responses) {
if (cancellationToken.isCompleted()) {
logger.fine(jobIdString() + " to be cancelled after init");
return new CancellationException();
}
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("Init of " + jobIdString() + " is successful.");
return null;
}
List<Entry<MemberInfo, Object>> failures = grouped.get(true);
logger.fine("Init of " + jobIdString() + " failed with: " + failures);
// otherwise, return TopologyChangedException so that the job will be restarted
return failures.stream().map(e -> (Throwable) e.getValue()).filter(t -> !isTopologicalFailure(t)).findFirst().map(ExceptionUtil::peel).orElse(new TopologyChangedException());
}
Aggregations