use of models.AppResult in project dr-elephant by linkedin.
the class Application method getJobHistory.
/**
* Returns the job history. Returns at max MAX_HISTORY_LIMIT executions.
*
* @param version The version of job history to return
* @return The job history page based on the version.
*/
private static Result getJobHistory(Version version) {
DynamicForm form = Form.form().bindFromRequest(request());
String partialJobDefId = form.get(JOB_DEF_ID);
partialJobDefId = (partialJobDefId != null) ? partialJobDefId.trim() : null;
boolean hasSparkJob = false;
// get the graph type
String graphType = form.get("select-graph-type");
if (graphType == null) {
graphType = "resources";
}
if (!Utils.isSet(partialJobDefId)) {
if (version.equals(Version.NEW)) {
return ok(jobHistoryPage.render(partialJobDefId, graphType, jobHistoryResults.render(null, null, -1, null)));
} else {
return ok(oldJobHistoryPage.render(partialJobDefId, graphType, oldJobHistoryResults.render(null, null, -1, null)));
}
}
IdUrlPair jobDefPair = bestSchedulerInfoMatchGivenPartialId(partialJobDefId, AppResult.TABLE.JOB_DEF_ID);
List<AppResult> results;
if (graphType.equals("time") || graphType.equals("resources")) {
// we don't need APP_HEURISTIC_RESULT_DETAILS data to plot for time and resources
results = AppResult.find.select(AppResult.getSearchFields() + "," + AppResult.TABLE.FLOW_EXEC_ID + "," + AppResult.TABLE.FLOW_EXEC_URL).where().eq(AppResult.TABLE.JOB_DEF_ID, jobDefPair.getId()).order().desc(AppResult.TABLE.FINISH_TIME).setMaxRows(JOB_HISTORY_LIMIT).findList();
} else {
// Fetch all job executions
results = AppResult.find.select(AppResult.getSearchFields() + "," + AppResult.TABLE.FLOW_EXEC_ID + "," + AppResult.TABLE.FLOW_EXEC_URL).where().eq(AppResult.TABLE.JOB_DEF_ID, jobDefPair.getId()).order().desc(AppResult.TABLE.FINISH_TIME).setMaxRows(JOB_HISTORY_LIMIT).fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS, "*").fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS + "." + AppHeuristicResult.TABLE.APP_HEURISTIC_RESULT_DETAILS, "*").findList();
}
for (AppResult result : results) {
if (result.jobType.equals("Spark")) {
hasSparkJob = true;
}
}
if (results.size() == 0) {
return notFound("Unable to find record for job def id: " + jobDefPair.getId());
}
Map<IdUrlPair, List<AppResult>> flowExecIdToJobsMap = ControllerUtil.limitHistoryResults(ControllerUtil.groupJobs(results, ControllerUtil.GroupBy.FLOW_EXECUTION_ID), results.size(), MAX_HISTORY_LIMIT);
// Compute job execution data
List<Long> flowExecTimeList = new ArrayList<Long>();
int maxStages = 0;
Map<IdUrlPair, List<AppResult>> executionMap = new LinkedHashMap<IdUrlPair, List<AppResult>>();
for (Map.Entry<IdUrlPair, List<AppResult>> entry : flowExecIdToJobsMap.entrySet()) {
// Reverse the list content from desc order of finish time to increasing order so that when grouping we get
// the job list in the order of completion.
List<AppResult> mrJobsList = Lists.reverse(entry.getValue());
// Get the finish time of the last mr job that completed in current flow.
flowExecTimeList.add(mrJobsList.get(mrJobsList.size() - 1).finishTime);
// Find the maximum number of mr stages for any job execution
int stageSize = flowExecIdToJobsMap.get(entry.getKey()).size();
if (stageSize > maxStages) {
maxStages = stageSize;
}
executionMap.put(entry.getKey(), Lists.reverse(flowExecIdToJobsMap.get(entry.getKey())));
}
if (maxStages > STAGE_LIMIT) {
maxStages = STAGE_LIMIT;
}
if (version.equals(Version.NEW)) {
if (graphType.equals("heuristics")) {
return ok(jobHistoryPage.render(jobDefPair.getId(), graphType, jobHistoryResults.render(jobDefPair, executionMap, maxStages, flowExecTimeList)));
} else if (graphType.equals("resources") || graphType.equals("time")) {
return ok(jobHistoryPage.render(jobDefPair.getId(), graphType, jobMetricsHistoryResults.render(jobDefPair, graphType, executionMap, maxStages, flowExecTimeList)));
}
} else {
if (graphType.equals("heuristics")) {
return ok(oldJobHistoryPage.render(jobDefPair.getId(), graphType, oldJobHistoryResults.render(jobDefPair, executionMap, maxStages, flowExecTimeList)));
} else if (graphType.equals("resources") || graphType.equals("time")) {
if (hasSparkJob) {
return notFound("Resource and time graph are not supported for spark right now");
} else {
return ok(oldJobHistoryPage.render(jobDefPair.getId(), graphType, oldJobMetricsHistoryResults.render(jobDefPair, graphType, executionMap, maxStages, flowExecTimeList)));
}
}
}
return notFound("Unable to find graph type: " + graphType);
}
use of models.AppResult in project dr-elephant by linkedin.
the class Application method getFlowHistory.
/**
* Returns the flowHistory based on the version provided
*
* @param version Can be either new or old
* @return The flowhistory page based on the version provided
*/
private static Result getFlowHistory(Version version) {
DynamicForm form = Form.form().bindFromRequest(request());
String partialFlowDefId = form.get(FLOW_DEF_ID);
partialFlowDefId = (partialFlowDefId != null) ? partialFlowDefId.trim() : null;
boolean hasSparkJob = false;
String graphType = form.get("select-graph-type");
// get the graph type
if (graphType == null) {
graphType = "resources";
}
if (!Utils.isSet(partialFlowDefId)) {
if (version.equals(Version.NEW)) {
return ok(flowHistoryPage.render(partialFlowDefId, graphType, flowHistoryResults.render(null, null, null, null)));
} else {
return ok(oldFlowHistoryPage.render(partialFlowDefId, graphType, oldFlowHistoryResults.render(null, null, null, null)));
}
}
IdUrlPair flowDefPair = bestSchedulerInfoMatchGivenPartialId(partialFlowDefId, AppResult.TABLE.FLOW_DEF_ID);
List<AppResult> results;
if (graphType.equals("time") || graphType.equals("resources")) {
// if graph type is time or resources, we don't need the result from APP_HEURISTIC_RESULTS
results = AppResult.find.select(AppResult.getSearchFields() + "," + AppResult.TABLE.FLOW_EXEC_ID + "," + AppResult.TABLE.FLOW_EXEC_URL + "," + AppResult.TABLE.JOB_DEF_ID + "," + AppResult.TABLE.JOB_DEF_URL + "," + AppResult.TABLE.JOB_NAME).where().eq(AppResult.TABLE.FLOW_DEF_ID, flowDefPair.getId()).order().desc(AppResult.TABLE.FINISH_TIME).setMaxRows(JOB_HISTORY_LIMIT).findList();
} else {
// Fetch available flow executions with latest JOB_HISTORY_LIMIT mr jobs.
results = AppResult.find.select(AppResult.getSearchFields() + "," + AppResult.TABLE.FLOW_EXEC_ID + "," + AppResult.TABLE.FLOW_EXEC_URL + "," + AppResult.TABLE.JOB_DEF_ID + "," + AppResult.TABLE.JOB_DEF_URL + "," + AppResult.TABLE.JOB_NAME).where().eq(AppResult.TABLE.FLOW_DEF_ID, flowDefPair.getId()).order().desc(AppResult.TABLE.FINISH_TIME).setMaxRows(JOB_HISTORY_LIMIT).fetch(AppResult.TABLE.APP_HEURISTIC_RESULTS, AppHeuristicResult.getSearchFields()).findList();
}
if (results.size() == 0) {
return notFound("Unable to find record for flow def id: " + flowDefPair.getId());
}
for (AppResult result : results) {
if (result.jobType.equals("Spark")) {
hasSparkJob = true;
}
}
Map<IdUrlPair, List<AppResult>> flowExecIdToJobsMap = ControllerUtil.limitHistoryResults(ControllerUtil.groupJobs(results, ControllerUtil.GroupBy.FLOW_EXECUTION_ID), results.size(), MAX_HISTORY_LIMIT);
// Compute flow execution data
// All jobs starting from latest execution
List<AppResult> filteredResults = new ArrayList<AppResult>();
// To map executions to resp execution time
List<Long> flowExecTimeList = new ArrayList<Long>();
Map<IdUrlPair, Map<IdUrlPair, List<AppResult>>> executionMap = new LinkedHashMap<IdUrlPair, Map<IdUrlPair, List<AppResult>>>();
for (Map.Entry<IdUrlPair, List<AppResult>> entry : flowExecIdToJobsMap.entrySet()) {
// Reverse the list content from desc order of finish time to increasing order so that when grouping we get
// the job list in the order of completion.
List<AppResult> mrJobsList = Lists.reverse(entry.getValue());
// Flow exec time is the finish time of the last mr job in the flow
flowExecTimeList.add(mrJobsList.get(mrJobsList.size() - 1).finishTime);
filteredResults.addAll(mrJobsList);
executionMap.put(entry.getKey(), ControllerUtil.groupJobs(mrJobsList, ControllerUtil.GroupBy.JOB_DEFINITION_ID));
}
// Calculate unique list of jobs (job def url) to maintain order across executions. List will contain job def urls
// from latest execution first followed by any other extra job def url that may appear in previous executions.
final Map<IdUrlPair, String> idPairToJobNameMap = new ListOrderedMap();
Map<IdUrlPair, List<AppResult>> filteredTempMap = ControllerUtil.groupJobs(filteredResults, ControllerUtil.GroupBy.JOB_DEFINITION_ID);
List<Map.Entry<IdUrlPair, List<AppResult>>> filteredMapList = new LinkedList<Map.Entry<IdUrlPair, List<AppResult>>>(filteredTempMap.entrySet());
Collections.sort(filteredMapList, new Comparator<Map.Entry<IdUrlPair, List<AppResult>>>() {
@Override
public int compare(Map.Entry<IdUrlPair, List<AppResult>> idUrlPairListMap, Map.Entry<IdUrlPair, List<AppResult>> t1) {
return (new Long(idUrlPairListMap.getValue().get(0).finishTime)).compareTo(t1.getValue().get(0).finishTime);
}
});
for (Map.Entry<IdUrlPair, List<AppResult>> entry : filteredMapList) {
idPairToJobNameMap.put(entry.getKey(), entry.getValue().get(0).jobName);
}
if (version.equals(Version.NEW)) {
if (graphType.equals("heuristics")) {
return ok(flowHistoryPage.render(flowDefPair.getId(), graphType, flowHistoryResults.render(flowDefPair, executionMap, idPairToJobNameMap, flowExecTimeList)));
} else if (graphType.equals("resources") || graphType.equals("time")) {
return ok(flowHistoryPage.render(flowDefPair.getId(), graphType, flowMetricsHistoryResults.render(flowDefPair, graphType, executionMap, idPairToJobNameMap, flowExecTimeList)));
}
} else {
if (graphType.equals("heuristics")) {
return ok(oldFlowHistoryPage.render(flowDefPair.getId(), graphType, oldFlowHistoryResults.render(flowDefPair, executionMap, idPairToJobNameMap, flowExecTimeList)));
} else if (graphType.equals("resources") || graphType.equals("time")) {
if (hasSparkJob) {
return notFound("Cannot plot graph for " + graphType + " since it contains a spark job. " + graphType + " graphs are not supported for spark right now");
} else {
return ok(oldFlowHistoryPage.render(flowDefPair.getId(), graphType, oldFlowMetricsHistoryResults.render(flowDefPair, graphType, executionMap, idPairToJobNameMap, flowExecTimeList)));
}
}
}
return notFound("Unable to find graph type: " + graphType);
}
use of models.AppResult in project dr-elephant by linkedin.
the class Application method bestSchedulerInfoMatchLikeValue.
/**
* Returns the scheduler info id/url pair for the most recent app result that has an id like value
* (which can use % and _ SQL wild cards) for the specified field. Note that this is a pair rather
* than merely an ID/URL because for some schedulers (e.g. Airflow) they are not equivalent and
* usually the UI wants to display the ID with a link to the URL. While it is true that the URL
* can probably be derived from the ID in most cases, we would need scheduler specific logic which
* would be a mess.
*/
private static IdUrlPair bestSchedulerInfoMatchLikeValue(String value, String schedulerIdField) {
String schedulerUrlField;
if (schedulerIdField.equals(AppResult.TABLE.FLOW_DEF_ID)) {
schedulerUrlField = AppResult.TABLE.FLOW_DEF_URL;
} else if (schedulerIdField.equals(AppResult.TABLE.FLOW_EXEC_ID)) {
schedulerUrlField = AppResult.TABLE.FLOW_EXEC_URL;
} else if (schedulerIdField.equals(AppResult.TABLE.JOB_DEF_ID)) {
schedulerUrlField = AppResult.TABLE.JOB_DEF_URL;
} else if (schedulerIdField.equals(AppResult.TABLE.JOB_EXEC_ID)) {
schedulerUrlField = AppResult.TABLE.JOB_EXEC_URL;
} else {
throw new RuntimeException(String.format("%s is not a valid scheduler info id field", schedulerIdField));
}
AppResult result = AppResult.find.select(String.format("%s, %s", schedulerIdField, schedulerUrlField)).where().like(schedulerIdField, value).order().desc(AppResult.TABLE.FINISH_TIME).setMaxRows(1).findUnique();
if (result != null) {
if (schedulerIdField.equals(AppResult.TABLE.FLOW_DEF_ID)) {
return new IdUrlPair(result.flowDefId, result.flowDefUrl);
} else if (schedulerIdField.equals(AppResult.TABLE.FLOW_EXEC_ID)) {
return new IdUrlPair(result.flowExecId, result.flowExecUrl);
} else if (schedulerIdField.equals(AppResult.TABLE.JOB_DEF_ID)) {
return new IdUrlPair(result.jobDefId, result.jobDefUrl);
} else if (schedulerIdField.equals(AppResult.TABLE.JOB_EXEC_ID)) {
return new IdUrlPair(result.jobExecId, result.jobExecUrl);
}
}
return null;
}
use of models.AppResult in project dr-elephant by linkedin.
the class Application method restJobMetricsGraphData.
/**
* The data for plotting the job history graph using time and resource metrics. While plotting the job history
* graph an ajax call is made to this to fetch the graph data.
*
* Data Returned:
* <pre>
* [
* {
* "flowtime": 1461234105456,
* "runtime": 2312107,
* "waittime": 118879,
* "resourceused": 304934912,
* "resourcewasted": 172913,
* "jobmetrics": [
* {
* "stageid": "application_1458194917883_1587177",
* "runtime": 642986,
* "waittime": 14016,
* "resourceused": 277352448,
* "resourcewasted": 0
* }],
* },
* {
* "flowtime": 1461237538639,
* "runtime": 2155354,
* "waittime": 112187,
* "resourceused": 293096448,
* "resourcewasted": 400461,
* "jobmetrics": [
* {
* "stageid": "application_1458194917883_1589302",
* "runtime": 548924,
* "waittime": 16903,
* "resourceused": 266217472,
* "resourcewasted": 0
* }]
* }
* ]
*
* </pre>
*/
public static Result restJobMetricsGraphData(String jobDefId) {
JsonArray datasets = new JsonArray();
if (jobDefId == null || jobDefId.isEmpty()) {
return ok(new Gson().toJson(datasets));
}
List<AppResult> results = getRestJobAppResults(jobDefId);
if (results.size() == 0) {
logger.info("No results for Job url");
}
Map<IdUrlPair, List<AppResult>> flowExecIdToJobsMap = ControllerUtil.limitHistoryResults(ControllerUtil.groupJobs(results, ControllerUtil.GroupBy.FLOW_EXECUTION_ID), results.size(), MAX_HISTORY_LIMIT);
// Compute the graph data starting from the earliest available execution to latest
List<IdUrlPair> keyList = new ArrayList<IdUrlPair>(flowExecIdToJobsMap.keySet());
for (int i = keyList.size() - 1; i >= 0; i--) {
IdUrlPair flowExecPair = keyList.get(i);
int jobPerfScore = 0;
JsonArray stageMetrics = new JsonArray();
List<AppResult> mrJobsList = Lists.reverse(flowExecIdToJobsMap.get(flowExecPair));
long totalMemoryUsed = 0;
long totalMemoryWasted = 0;
long totalDelay = 0;
for (AppResult appResult : flowExecIdToJobsMap.get(flowExecPair)) {
// Each MR job triggered by jobDefId for flowExecId
int mrPerfScore = 0;
for (AppHeuristicResult appHeuristicResult : appResult.yarnAppHeuristicResults) {
mrPerfScore += appHeuristicResult.score;
}
// A particular mr stage
JsonObject stageMetric = new JsonObject();
stageMetric.addProperty("stageid", appResult.id);
stageMetric.addProperty("runtime", appResult.finishTime - appResult.startTime);
stageMetric.addProperty("waittime", appResult.totalDelay);
stageMetric.addProperty("resourceused", appResult.resourceUsed);
stageMetric.addProperty("resourcewasted", appResult.resourceWasted);
stageMetrics.add(stageMetric);
jobPerfScore += mrPerfScore;
totalMemoryUsed += appResult.resourceUsed;
totalMemoryWasted += appResult.resourceWasted;
}
// Execution record
JsonObject dataset = new JsonObject();
dataset.addProperty("flowtime", Utils.getFlowTime(mrJobsList.get(mrJobsList.size() - 1)));
dataset.addProperty("runtime", Utils.getTotalRuntime(mrJobsList));
dataset.addProperty("waittime", Utils.getTotalWaittime(mrJobsList));
dataset.addProperty("resourceused", totalMemoryUsed);
dataset.addProperty("resourcewasted", totalMemoryWasted);
dataset.add("jobmetrics", stageMetrics);
datasets.add(dataset);
}
JsonArray sortedDatasets = Utils.sortJsonArray(datasets);
return ok(new Gson().toJson(sortedDatasets));
}
use of models.AppResult in project dr-elephant by linkedin.
the class Web method restWorkflowFromFlowId.
/**
* This method returns the workflow response object based on the flow execution id
* @param flowId The flow execution id for which the flow should be returned
* @return Return the workflow detail based on the flow execution id
*
* response object:
* <pre>
* *{
* "workflows": {
* "id": "flowid",
* "username": "username",
* "starttime": 1471910835628,
* "finishtime": 1471911099238,
* "runtime": 263610,
* "waittime": 46234,
* "resourceused": 101382144,
* "resourcewasted": 15993417,
* "severity": "Moderate",
* "flowexecid": "flowexecid",
* "flowdefid": "flowdefid",
* "jobssummaries": [
* {
* "id": "jobid",
* "jobname": "jobname",
* "jobtype": "Pig",
* "username": "username",
* "starttime": 1471910835628,
* "finishtime": 1471911099238,
* "runtime": 263610,
* "waittime": 46234,
* "resourceused": 101382144,
* "resourcewasted": 15993417,
* "severity": "Moderate",
* "tasksseverity": [
* {
* "severity": "Moderate",
* "count": 1
* }
* ]
* }
* ],
* "jobsseverity": [
* {
* "severity": "Moderate",
* "count": 1
* }
* ]
* }
*}
* </pre>
*/
public static Result restWorkflowFromFlowId(String flowId) {
if (flowId == null || flowId.isEmpty()) {
JsonObject parent = new JsonObject();
parent.add(JsonKeys.WORKFLOWS, new JsonObject());
return notFound(new Gson().toJson(parent));
}
JsonArray jobSeverityArray = new JsonArray();
JsonArray jobSummaryArray = new JsonArray();
JsonObject data = new JsonObject();
String flowExecId = flowId;
String username = "";
long totalFlowResourceUsed = 0;
long totalFlowResourceWasted = 0;
long totalFlowRuntime = 0;
long totalFlowDelay = 0;
Severity flowSeverity = Severity.NONE;
long flowStartTime = Long.MAX_VALUE;
long flowEndTime = 0;
String flowDefinitionId = "";
Map<Severity, Long> jobSeverityCount = new HashMap<Severity, Long>();
String wfQueueName = "";
String wfSchedulerName = "";
List<AppResult> results = getRestFlowResultsFromFlowExecutionId(flowId);
if (results.isEmpty()) {
JsonObject parent = new JsonObject();
parent.add(JsonKeys.WORKFLOWS, data);
return notFound(new Gson().toJson(parent));
}
Map<IdUrlPair, List<AppResult>> jobExecIdToJobsMap = ControllerUtil.groupJobs(results, ControllerUtil.GroupBy.JOB_EXECUTION_ID);
for (IdUrlPair jobDefPair : jobExecIdToJobsMap.keySet()) {
long totalJobMemoryUsed = 0;
long totalJobMemoryWasted = 0;
long totalJobDelay = 0;
long totalJobRuntime = 0;
long jobStartTime = Long.MAX_VALUE;
long jobEndTime = 0;
Severity jobSeverity = Severity.NONE;
String jobType = null;
String jobId = jobDefPair.getId();
String jobName = "";
String queueName = "";
String schedulerName = "";
Map<Severity, Long> taskSeverityCount = new HashMap<Severity, Long>();
for (AppResult task : jobExecIdToJobsMap.get(jobDefPair)) {
totalJobMemoryUsed += task.resourceUsed;
totalJobMemoryWasted += task.resourceWasted;
username = task.username;
jobType = task.jobType;
jobName = task.jobName;
flowDefinitionId = task.flowDefId;
queueName = task.queueName;
schedulerName = task.scheduler;
if (task.startTime < jobStartTime) {
jobStartTime = task.startTime;
}
if (task.finishTime > jobEndTime) {
jobEndTime = task.finishTime;
}
if (task.severity.getValue() > jobSeverity.getValue()) {
jobSeverity = task.severity;
}
if (taskSeverityCount.containsKey(task.severity)) {
taskSeverityCount.put(task.severity, taskSeverityCount.get(task.severity) + 1L);
} else {
taskSeverityCount.put(task.severity, 1L);
}
}
if (jobSeverityCount.containsKey(jobSeverity)) {
jobSeverityCount.put(jobSeverity, jobSeverityCount.get(jobSeverity) + 1L);
} else {
jobSeverityCount.put(jobSeverity, 1L);
}
JsonArray taskSeverity = new JsonArray();
List<Severity> keys = getSortedSeverityKeys(taskSeverityCount.keySet());
for (Severity key : keys) {
JsonObject severityObject = new JsonObject();
severityObject.addProperty(JsonKeys.SEVERITY, key.getText());
severityObject.addProperty(JsonKeys.COUNT, taskSeverityCount.get(key));
taskSeverity.add(severityObject);
}
wfQueueName = queueName;
wfSchedulerName = schedulerName;
totalJobDelay = Utils.getTotalWaittime(jobExecIdToJobsMap.get(jobDefPair));
totalJobRuntime = Utils.getTotalRuntime(jobExecIdToJobsMap.get(jobDefPair));
JsonObject jobObject = new JsonObject();
jobObject.addProperty(JsonKeys.ID, jobId);
jobObject.addProperty(JsonKeys.JOB_NAME, jobName);
jobObject.addProperty(JsonKeys.JOB_TYPE, jobType);
jobObject.addProperty(JsonKeys.USERNAME, username);
jobObject.addProperty(JsonKeys.START_TIME, jobStartTime);
jobObject.addProperty(JsonKeys.FINISH_TIME, jobEndTime);
jobObject.addProperty(JsonKeys.RUNTIME, totalJobRuntime);
jobObject.addProperty(JsonKeys.WAITTIME, totalJobDelay);
jobObject.addProperty(JsonKeys.RESOURCE_USED, totalJobMemoryUsed);
jobObject.addProperty(JsonKeys.RESOURCE_WASTED, totalJobMemoryWasted);
jobObject.addProperty(JsonKeys.QUEUE, queueName);
jobObject.addProperty(JsonKeys.SCHEDULER, schedulerName);
jobObject.addProperty(JsonKeys.SEVERITY, jobSeverity.getText());
jobObject.add(JsonKeys.TASKS_SEVERITY, taskSeverity);
jobSummaryArray.add(jobObject);
totalFlowResourceUsed += totalJobMemoryUsed;
totalFlowResourceWasted += totalJobMemoryWasted;
if (jobSeverity.getValue() > flowSeverity.getValue()) {
flowSeverity = jobSeverity;
}
if (flowStartTime > jobStartTime) {
flowStartTime = jobStartTime;
}
if (flowEndTime < jobEndTime) {
flowEndTime = jobEndTime;
}
}
// job map scope ends here
List<Severity> keys = getSortedSeverityKeys(jobSeverityCount.keySet());
for (Severity key : keys) {
JsonObject severityObject = new JsonObject();
severityObject.addProperty(JsonKeys.SEVERITY, key.getText());
severityObject.addProperty(JsonKeys.COUNT, jobSeverityCount.get(key));
jobSeverityArray.add(severityObject);
}
totalFlowDelay = Utils.getTotalWaittime(results);
totalFlowRuntime = Utils.getTotalRuntime(results);
data.addProperty(JsonKeys.ID, flowExecId);
data.addProperty(JsonKeys.USERNAME, username);
data.addProperty(JsonKeys.START_TIME, flowStartTime);
data.addProperty(JsonKeys.FINISH_TIME, flowEndTime);
data.addProperty(JsonKeys.RUNTIME, totalFlowRuntime);
data.addProperty(JsonKeys.WAITTIME, totalFlowDelay);
data.addProperty(JsonKeys.RESOURCE_USED, totalFlowResourceUsed);
data.addProperty(JsonKeys.RESOURCE_WASTED, totalFlowResourceWasted);
data.addProperty(JsonKeys.SEVERITY, flowSeverity.getText());
data.addProperty(JsonKeys.FLOW_EXEC_ID, flowExecId);
data.addProperty(JsonKeys.FLOW_DEF_ID, flowDefinitionId);
data.addProperty(JsonKeys.QUEUE, wfQueueName);
data.addProperty(JsonKeys.SCHEDULER, wfSchedulerName);
data.add(JsonKeys.JOBSSUMMARIES, jobSummaryArray);
data.add(JsonKeys.JOBS_SEVERITY, jobSeverityArray);
JsonObject parent = new JsonObject();
parent.add(JsonKeys.WORKFLOWS, data);
return ok(new Gson().toJson(parent));
}
Aggregations