use of com.hazelcast.jet.impl.util.ExceptionUtil 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());
}
use of com.hazelcast.jet.impl.util.ExceptionUtil 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