java.lang.Object
org.apache.hadoop.mapreduce.v2.app.job.impl.TaskImpl
All Implemented Interfaces:
Task, org.apache.hadoop.yarn.event.EventHandler<TaskEvent>
Direct Known Subclasses:
MapTaskImpl, ReduceTaskImpl

public abstract class TaskImpl extends Object implements Task, org.apache.hadoop.yarn.event.EventHandler<TaskEvent>
Implementation of Task interface.
  • Field Details

    • conf

      protected final org.apache.hadoop.mapred.JobConf conf
    • jobFile

      protected final org.apache.hadoop.fs.Path jobFile
    • partition

      protected final int partition
    • taskAttemptListener

      protected final TaskAttemptListener taskAttemptListener
    • eventHandler

      protected final org.apache.hadoop.yarn.event.EventHandler eventHandler
    • clock

      protected final org.apache.hadoop.yarn.util.Clock clock
    • appContext

      protected final AppContext appContext
    • encryptedShuffle

      protected boolean encryptedShuffle
    • credentials

      protected org.apache.hadoop.security.Credentials credentials
    • jobToken

      protected org.apache.hadoop.security.token.Token<org.apache.hadoop.mapreduce.security.token.JobTokenIdentifier> jobToken
    • nextAttemptNumber

      protected int nextAttemptNumber
  • Constructor Details

    • TaskImpl

      public TaskImpl(org.apache.hadoop.mapreduce.v2.api.records.JobId jobId, org.apache.hadoop.mapreduce.v2.api.records.TaskType taskType, int partition, org.apache.hadoop.yarn.event.EventHandler eventHandler, org.apache.hadoop.fs.Path remoteJobConfFile, org.apache.hadoop.mapred.JobConf conf, TaskAttemptListener taskAttemptListener, org.apache.hadoop.security.token.Token<org.apache.hadoop.mapreduce.security.token.JobTokenIdentifier> jobToken, org.apache.hadoop.security.Credentials credentials, org.apache.hadoop.yarn.util.Clock clock, int appAttemptId, MRAppMetrics metrics, AppContext appContext)
  • Method Details

    • getState

      public org.apache.hadoop.mapreduce.v2.api.records.TaskState getState()
      Specified by:
      getState in interface Task
    • getAttempts

      public Map<org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId,TaskAttempt> getAttempts()
      Specified by:
      getAttempts in interface Task
    • getAttempt

      public TaskAttempt getAttempt(org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId attemptID)
      Specified by:
      getAttempt in interface Task
    • getID

      public org.apache.hadoop.mapreduce.v2.api.records.TaskId getID()
      Specified by:
      getID in interface Task
    • isFinished

      public boolean isFinished()
      Description copied from interface: Task
      Has Task reached the final state or not.
      Specified by:
      isFinished in interface Task
    • getReport

      public org.apache.hadoop.mapreduce.v2.api.records.TaskReport getReport()
      Specified by:
      getReport in interface Task
    • getCounters

      public org.apache.hadoop.mapreduce.Counters getCounters()
      Specified by:
      getCounters in interface Task
    • getProgress

      public float getProgress()
      Specified by:
      getProgress in interface Task
    • getInternalState

      @VisibleForTesting public TaskStateInternal getInternalState()
    • canCommit

      public boolean canCommit(org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptId taskAttemptID)
      Description copied from interface: Task
      Can the output of the taskAttempt be committed. Note that once the task gives a go for a commit, further canCommit requests from any other attempts should return false.
      Specified by:
      canCommit in interface Task
      Returns:
      whether the attempt's output can be committed or not.
    • createAttempt

      protected abstract TaskAttemptImpl createAttempt()
    • getMaxAttempts

      protected abstract int getMaxAttempts()
    • getSuccessfulAttempt

      protected TaskAttempt getSuccessfulAttempt()
    • handle

      public void handle(TaskEvent event)
      Specified by:
      handle in interface org.apache.hadoop.yarn.event.EventHandler<TaskEvent>
    • internalError

      protected void internalError(TaskEventType type)
    • getSplitsAsString

      protected String getSplitsAsString()
      Returns:
      a String representation of the splits. Subclasses can override this method to provide their own representations of splits (if any).