try {
wrt.write("[");
ExecutionGraph graph = jobmanager.getRecentExecutionGraph(jobEvent.getJobID());
//Serialize job to json
wrt.write("{");
wrt.write("\"jobid\": \"" + jobEvent.getJobID() + "\",");
wrt.write("\"jobname\": \"" + jobEvent.getJobName()+"\",");
wrt.write("\"status\": \""+ jobEvent.getJobStatus() + "\",");
wrt.write("\"SCHEDULED\": "+ graph.getStatusTimestamp(JobStatus.CREATED) + ",");
wrt.write("\"RUNNING\": "+ graph.getStatusTimestamp(JobStatus.RUNNING) + ",");
wrt.write("\"FINISHED\": "+ graph.getStatusTimestamp(JobStatus.FINISHED) + ",");
wrt.write("\"FAILED\": "+ graph.getStatusTimestamp(JobStatus.FAILED) + ",");
wrt.write("\"CANCELED\": "+ graph.getStatusTimestamp(JobStatus.CANCELED) + ",");
if (jobEvent.getJobStatus() == JobStatus.FAILED) {
wrt.write("\"failednodes\": [");
boolean first = true;
for (ExecutionVertex vertex : graph.getAllExecutionVertices()) {
if (vertex.getExecutionState() == ExecutionState.FAILED) {
AllocatedSlot slot = vertex.getCurrentAssignedResource();
Throwable failureCause = vertex.getFailureCause();
if (slot != null || failureCause != null) {
if (first) {
first = false;
} else {
wrt.write(",");
}
wrt.write("{");
wrt.write("\"node\": \"" + (slot == null ? "(none)" : slot.getInstance().getInstanceConnectionInfo().getFQDNHostname()) + "\",");
wrt.write("\"message\": \"" + (failureCause == null ? "" : StringUtils.escapeHtml(ExceptionUtils.stringifyException(failureCause))) + "\"");
wrt.write("}");
}
}
}
wrt.write("],");
}
// Serialize ManagementGraph to json
wrt.write("\"groupvertices\": [");
boolean first = true;
for (ExecutionJobVertex groupVertex : graph.getVerticesTopologically()) {
//Write seperator between json objects
if(first) {
first = false;
} else {
wrt.write(","); }
wrt.write(JsonFactory.toJson(groupVertex));
}
wrt.write("],");
// write accumulators
Map<String, Object> accMap = AccumulatorHelper.toResultMap(jobmanager.getAccumulators(jobEvent.getJobID()));
wrt.write("\n\"accumulators\": [");
int i = 0;
for( Entry<String, Object> accumulator : accMap.entrySet()) {
wrt.write("{ \"name\": \""+accumulator.getKey()+" (" + accumulator.getValue().getClass().getName()+")\","
+ " \"value\": \""+accumulator.getValue().toString()+"\"}\n");
if(++i < accMap.size()) {
wrt.write(",");
}
}
wrt.write("],\n");
wrt.write("\"groupverticetimes\": {");
first = true;
for (ExecutionJobVertex groupVertex : graph.getVerticesTopologically()) {
if(first) {
first = false;
} else {
wrt.write(","); }