Java Code Examples for org.apache.hadoop.mapreduce.v2.api.records.TaskReport#getProgress()

The following examples show how to use org.apache.hadoop.mapreduce.v2.api.records.TaskReport#getProgress() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskInfo.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public TaskInfo(Task task) {
  TaskType ttype = task.getType();
  this.type = ttype.toString();
  TaskReport report = task.getReport();
  this.startTime = report.getStartTime();
  this.finishTime = report.getFinishTime();
  this.state = report.getTaskState();
  this.elapsedTime = Times.elapsed(this.startTime, this.finishTime,
    this.state == TaskState.RUNNING);
  if (this.elapsedTime == -1) {
    this.elapsedTime = 0;
  }
  this.progress = report.getProgress() * 100;
  this.status =  report.getStatus();
  this.id = MRApps.toString(task.getID());
  this.taskNum = task.getID().getId();
  this.successful = getSuccessfulAttempt(task);
  if (successful != null) {
    this.successfulAttempt = MRApps.toString(successful.getID());
  } else {
    this.successfulAttempt = "";
  }
}
 
Example 2
Source File: TaskInfo.java    From big-c with Apache License 2.0 6 votes vote down vote up
public TaskInfo(Task task) {
  TaskType ttype = task.getType();
  this.type = ttype.toString();
  TaskReport report = task.getReport();
  this.startTime = report.getStartTime();
  this.finishTime = report.getFinishTime();
  this.state = report.getTaskState();
  this.elapsedTime = Times.elapsed(this.startTime, this.finishTime,
    this.state == TaskState.RUNNING);
  if (this.elapsedTime == -1) {
    this.elapsedTime = 0;
  }
  this.progress = report.getProgress() * 100;
  this.status =  report.getStatus();
  this.id = MRApps.toString(task.getID());
  this.taskNum = task.getID().getId();
  this.successful = getSuccessfulAttempt(task);
  if (successful != null) {
    this.successfulAttempt = MRApps.toString(successful.getID());
  } else {
    this.successfulAttempt = "";
  }
}
 
Example 3
Source File: MockJobs.java    From hadoop with Apache License 2.0 4 votes vote down vote up
public static Task newTask(JobId jid, int i, int m, final boolean hasFailedTasks) {
  final TaskId tid = Records.newRecord(TaskId.class);
  tid.setJobId(jid);
  tid.setId(i);
  tid.setTaskType(TASK_TYPES.next());
  final TaskReport report = newTaskReport(tid);
  final Map<TaskAttemptId, TaskAttempt> attempts = newTaskAttempts(tid, m);
  return new Task() {
    @Override
    public TaskId getID() {
      return tid;
    }

    @Override
    public TaskReport getReport() {
      return report;
    }

    @Override
    public Counters getCounters() {
      if (hasFailedTasks) {
        return null;
      }
      return new Counters(
        TypeConverter.fromYarn(report.getCounters()));
    }

    @Override
    public float getProgress() {
      return report.getProgress();
    }

    @Override
    public TaskType getType() {
      return tid.getTaskType();
    }

    @Override
    public Map<TaskAttemptId, TaskAttempt> getAttempts() {
      return attempts;
    }

    @Override
    public TaskAttempt getAttempt(TaskAttemptId attemptID) {
      return attempts.get(attemptID);
    }

    @Override
    public boolean isFinished() {
      switch (report.getTaskState()) {
      case SUCCEEDED:
      case KILLED:
      case FAILED:
        return true;
      }
      return false;
    }

    @Override
    public boolean canCommit(TaskAttemptId taskAttemptID) {
      return false;
    }

    @Override
    public TaskState getState() {
      return report.getTaskState();
    }
  };
}
 
Example 4
Source File: MockJobs.java    From big-c with Apache License 2.0 4 votes vote down vote up
public static Task newTask(JobId jid, int i, int m, final boolean hasFailedTasks) {
  final TaskId tid = Records.newRecord(TaskId.class);
  tid.setJobId(jid);
  tid.setId(i);
  tid.setTaskType(TASK_TYPES.next());
  final TaskReport report = newTaskReport(tid);
  final Map<TaskAttemptId, TaskAttempt> attempts = newTaskAttempts(tid, m);
  return new Task() {
    @Override
    public TaskId getID() {
      return tid;
    }

    @Override
    public TaskReport getReport() {
      return report;
    }

    @Override
    public Counters getCounters() {
      if (hasFailedTasks) {
        return null;
      }
      return new Counters(
        TypeConverter.fromYarn(report.getCounters()));
    }

    @Override
    public float getProgress() {
      return report.getProgress();
    }

    @Override
    public TaskType getType() {
      return tid.getTaskType();
    }

    @Override
    public Map<TaskAttemptId, TaskAttempt> getAttempts() {
      return attempts;
    }

    @Override
    public TaskAttempt getAttempt(TaskAttemptId attemptID) {
      return attempts.get(attemptID);
    }

    @Override
    public boolean isFinished() {
      switch (report.getTaskState()) {
      case SUCCEEDED:
      case KILLED:
      case FAILED:
        return true;
      }
      return false;
    }

    @Override
    public boolean canCommit(TaskAttemptId taskAttemptID) {
      return false;
    }

    @Override
    public TaskState getState() {
      return report.getTaskState();
    }
  };
}