use of org.apache.ignite.internal.processors.job.ComputeJobStatusEnum in project ignite by apache.
the class GridTaskWorker method jobStatuses.
/**
* Collects statistics on jobs locally, only for those jobs that have
* already sent a response or are being executed locally.
*
* @return Job statistics for the task. Mapping: Job status -> count of jobs.
*/
Map<ComputeJobStatusEnum, Long> jobStatuses() {
List<GridJobResultImpl> jobResults = null;
synchronized (mux) {
if (jobRes != null)
jobResults = new ArrayList<>(jobRes.values());
}
// Jobs have not been mapped yet.
if (F.isEmpty(jobResults))
return emptyMap();
UUID locNodeId = ctx.localNodeId();
boolean getLocJobStatistics = false;
Map<ComputeJobStatusEnum, Long> res = new EnumMap<>(ComputeJobStatusEnum.class);
for (GridJobResultImpl jobResult : jobResults) {
if (jobResult.hasResponse()) {
ComputeJobStatusEnum jobStatus;
if (jobResult.isCancelled())
jobStatus = CANCELLED;
else if (jobResult.getException() != null)
jobStatus = FAILED;
else
jobStatus = FINISHED;
res.merge(jobStatus, 1L, Long::sum);
} else if (!getLocJobStatistics && locNodeId.equals(jobResult.getNode().id()))
getLocJobStatistics = true;
}
if (getLocJobStatistics) {
Map<ComputeJobStatusEnum, Long> jobStatuses = ctx.job().jobStatuses(getTaskSessionId());
for (Map.Entry<ComputeJobStatusEnum, Long> e : jobStatuses.entrySet()) res.merge(e.getKey(), e.getValue(), Long::sum);
}
return res;
}
Aggregations