@Produces(MediaType.APPLICATION_JSON)
@Path("/task")
public TaskData getTaskSummary(@QueryParam("jobId") String jobId, @QueryParam("width") int steps, @QueryParam("workflowId") String workflowId,
@DefaultValue("-1") @QueryParam("startTime") long minFinishTime, @DefaultValue("-1") @QueryParam("endTime") long maxStartTime) {
TaskData points = new TaskData();
PostgresConnector conn = null;
try {
conn = getConnector();
List<TaskAttempt> taskAttempts = null;
long startTime = -1;
long endTime = -1;
if (jobId != null) {
long[] times = conn.fetchJobStartStopTimes(jobId);
if (times != null) {
startTime = times[0];
endTime = times[1];
taskAttempts = conn.fetchJobTaskAttempts(jobId);
}
} else {
startTime = minFinishTime;
endTime = maxStartTime;
if (workflowId != null)
taskAttempts = conn.fetchWorkflowTaskAttempts(workflowId);
else
taskAttempts = conn.fetchTaskAttempts(minFinishTime, maxStartTime);
}
if (startTime > 0 && endTime > 0 && endTime >= startTime) {
double submitTimeSecs = startTime / 1000.0;
double finishTimeSecs = endTime / 1000.0;
double step = (finishTimeSecs - submitTimeSecs) / steps;
if (step < 1)
step = 1;
if (taskAttempts != null)
getTaskDetails(taskAttempts, points, submitTimeSecs, finishTimeSecs, step);
}
} catch (IOException e) {
LOG.error("Error interacting with RCA database ", e);
} finally {
if (conn != null) {
conn.close();
}
}
return points;
}