private static void saveJobStats(Job job, StepExecution stepExecution) {
if (stepExecution == null) {
return;
}
ExecutionContext executionContext = stepExecution.getExecutionContext();
String statusPrefix = "Job Status::";
executionContext.put(statusPrefix + "ID", JobUtils.getJobId(job).toString());
executionContext.put(statusPrefix + "Name", job.getJobName());
executionContext.put(statusPrefix + "Tracking URL", job.getTrackingURL());
executionContext.put(statusPrefix + "State", JobUtils.getStatus(job).toString());
try {
for (String cgName : job.getCounters().getGroupNames()) {
CounterGroup group = job.getCounters().getGroup(cgName);
Iterator<Counter> ci = group.iterator();
while (ci.hasNext()) {
Counter c = ci.next();
executionContext.put(group.getDisplayName().trim() + "::" + c.getDisplayName().trim(), c.getValue());
}
}
} catch (Exception ignore) {}
}