Class TaskAttemptImpl

java.lang.Object
org.apache.hadoop.mapreduce.v2.app.job.impl.TaskAttemptImpl
All Implemented Interfaces:
TaskAttempt, org.apache.hadoop.yarn.event.EventHandler<TaskAttemptEvent>
Direct Known Subclasses:
MapTaskAttemptImpl, ReduceTaskAttemptImpl

public abstract class TaskAttemptImpl extends Object implements TaskAttempt, org.apache.hadoop.yarn.event.EventHandler<TaskAttemptEvent>
Implementation of TaskAttempt interface.
  • Field Details

    • RESOURCE_REQUEST_CACHE

      @VisibleForTesting protected static final Map<org.apache.hadoop.mapreduce.v2.api.records.TaskType,org.apache.hadoop.yarn.api.records.Resource> RESOURCE_REQUEST_CACHE
    • conf

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

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

      protected final int partition
    • eventHandler

      protected org.apache.hadoop.yarn.event.EventHandler eventHandler
    • dataLocalHosts

      protected Set<String> dataLocalHosts
    • dataLocalRacks

      protected Set<String> dataLocalRacks
    • container

      @VisibleForTesting public org.apache.hadoop.yarn.api.records.Container container
  • Constructor Details

    • TaskAttemptImpl

      public TaskAttemptImpl(org.apache.hadoop.mapreduce.v2.api.records.TaskId taskId, int i, org.apache.hadoop.yarn.event.EventHandler eventHandler, TaskAttemptListener taskAttemptListener, org.apache.hadoop.fs.Path jobFile, int partition, org.apache.hadoop.mapred.JobConf conf, String[] dataLocalHosts, 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, AppContext appContext)
  • Method Details

    • getAssignedContainerID

      public org.apache.hadoop.yarn.api.records.ContainerId getAssignedContainerID()
      Specified by:
      getAssignedContainerID in interface TaskAttempt
      Returns:
      the container ID if a container is assigned, otherwise null.
    • getAssignedContainerMgrAddress

      public String getAssignedContainerMgrAddress()
      Specified by:
      getAssignedContainerMgrAddress in interface TaskAttempt
      Returns:
      container mgr address if a container is assigned, otherwise null.
    • getLaunchTime

      public long getLaunchTime()
      Specified by:
      getLaunchTime in interface TaskAttempt
      Returns:
      time at which container is launched. If container is not launched yet, returns 0.
    • getFinishTime

      public long getFinishTime()
      Specified by:
      getFinishTime in interface TaskAttempt
      Returns:
      attempt's finish time. If attempt is not finished yet, returns 0.
    • getShuffleFinishTime

      public long getShuffleFinishTime()
      Specified by:
      getShuffleFinishTime in interface TaskAttempt
      Returns:
      The attempt's shuffle finish time if the attempt is a reduce. If attempt is not finished yet, returns 0.
    • getSortFinishTime

      public long getSortFinishTime()
      Specified by:
      getSortFinishTime in interface TaskAttempt
      Returns:
      The attempt's sort or merge finish time if the attempt is a reduce. If attempt is not finished yet, returns 0.
    • getShufflePort

      public int getShufflePort()
      Specified by:
      getShufflePort in interface TaskAttempt
      Returns:
      the port shuffle is on.
    • getNodeId

      public org.apache.hadoop.yarn.api.records.NodeId getNodeId()
      Specified by:
      getNodeId in interface TaskAttempt
      Returns:
      node's id if a container is assigned, otherwise null.
    • getNodeHttpAddress

      public String getNodeHttpAddress()
      If container Assigned then return the node's address, otherwise null.
      Specified by:
      getNodeHttpAddress in interface TaskAttempt
      Returns:
      node's http address if a container is assigned, otherwise null.
    • getNodeRackName

      public String getNodeRackName()
      If container Assigned then return the node's rackname, otherwise null.
      Specified by:
      getNodeRackName in interface TaskAttempt
      Returns:
      node's rack name if a container is assigned, otherwise null.
    • createRemoteTask

      protected abstract org.apache.hadoop.mapred.Task createRemoteTask()
    • getID

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

      public boolean isFinished()
      Description copied from interface: TaskAttempt
      Has attempt reached the final state or not.
      Specified by:
      isFinished in interface TaskAttempt
      Returns:
      true if it has finished, else false
    • getReport

      public org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptReport getReport()
      Specified by:
      getReport in interface TaskAttempt
    • getDiagnostics

      public List<String> getDiagnostics()
      Specified by:
      getDiagnostics in interface TaskAttempt
    • getCounters

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

      public float getProgress()
      Specified by:
      getProgress in interface TaskAttempt
    • getPhase

      public org.apache.hadoop.mapreduce.v2.api.records.Phase getPhase()
      Specified by:
      getPhase in interface TaskAttempt
    • getState

      public org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState getState()
      Specified by:
      getState in interface TaskAttempt
    • handle

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

      @VisibleForTesting public TaskAttemptStateInternal getInternalState()
    • getLocality

      public org.apache.hadoop.mapreduce.v2.api.records.Locality getLocality()
    • setLocality

      public void setLocality(org.apache.hadoop.mapreduce.v2.api.records.Locality locality)
    • getAvataar

      public org.apache.hadoop.mapreduce.v2.api.records.Avataar getAvataar()
    • setAvataar

      public void setAvataar(org.apache.hadoop.mapreduce.v2.api.records.Avataar avataar)
    • setTaskFailFast

      public void setTaskFailFast(boolean failFast)
    • isTaskFailFast

      public boolean isTaskFailFast()
    • recover

      public TaskAttemptStateInternal recover(org.apache.hadoop.mapreduce.jobhistory.JobHistoryParser.TaskAttemptInfo taInfo, org.apache.hadoop.mapreduce.OutputCommitter committer, boolean recoverOutput)
    • getExternalState

      protected static org.apache.hadoop.mapreduce.v2.api.records.TaskAttemptState getExternalState(TaskAttemptStateInternal smState)
    • resolveHosts

      protected Set<String> resolveHosts(String[] src)
    • resolveHost

      protected String resolveHost(String src)
    • isIP

      protected boolean isIP(String src)