示例#1
0
  /**
   * Creates a "status report" for this task. Includes the task ID and overall status, plus reports
   * for all the component task-threads that have ever been started.
   */
  synchronized TaskReport generateSingleReport() {
    ArrayList<String> diagnostics = new ArrayList<String>();
    for (List<String> l : taskDiagnosticData.values()) {
      diagnostics.addAll(l);
    }
    TIPStatus currentStatus = null;
    if (isRunning() && !isComplete()) {
      currentStatus = TIPStatus.RUNNING;
    } else if (isComplete()) {
      currentStatus = TIPStatus.COMPLETE;
    } else if (wasKilled()) {
      currentStatus = TIPStatus.KILLED;
    } else if (isFailed()) {
      currentStatus = TIPStatus.FAILED;
    } else if (!(isComplete() || isRunning() || wasKilled())) {
      currentStatus = TIPStatus.PENDING;
    }

    TaskReport report =
        new TaskReport(
            getTIPId(),
            (float) progress,
            state,
            diagnostics.toArray(new String[diagnostics.size()]),
            currentStatus,
            execStartTime,
            execFinishTime,
            counters);
    if (currentStatus == TIPStatus.RUNNING) {
      report.setRunningTaskAttempts(activeTasks.keySet());
    } else if (currentStatus == TIPStatus.COMPLETE) {
      report.setSuccessfulAttempt(getSuccessfulTaskid());
    }
    return report;
  }
示例#2
0
 @Override
 public boolean equals(Object o) {
   if (o == null) return false;
   if (o.getClass().equals(TaskReport.class)) {
     TaskReport report = (TaskReport) o;
     return counters.equals(report.getCounters())
         && Arrays.toString(this.diagnostics).equals(Arrays.toString(report.getDiagnostics()))
         && this.finishTime == report.getFinishTime()
         && this.progress == report.getProgress()
         && this.startTime == report.getStartTime()
         && this.state.equals(report.getState())
         && this.taskid.equals(report.getTaskID());
   }
   return false;
 }