public abstract class TaskContext
extends Object
implements java.io.Serializable
org.apache.spark.TaskContext.get()
Constructor and Description |
---|
TaskContext() |
Modifier and Type | Method and Description |
---|---|
<U> TaskContext |
addTaskCompletionListener(scala.Function1<TaskContext,U> f)
Adds a listener in the form of a Scala closure to be executed on task completion.
|
abstract TaskContext |
addTaskCompletionListener(TaskCompletionListener listener)
Adds a (Java friendly) listener to be executed on task completion.
|
TaskContext |
addTaskFailureListener(scala.Function2<TaskContext,Throwable,scala.runtime.BoxedUnit> f)
Adds a listener to be executed on task failure.
|
abstract TaskContext |
addTaskFailureListener(TaskFailureListener listener)
Adds a listener to be executed on task failure.
|
abstract int |
attemptNumber()
How many times this task has been attempted.
|
static TaskContext |
get()
Return the currently active TaskContext.
|
abstract String |
getLocalProperty(String key)
Get a local property set upstream in the driver, or null if it is missing.
|
abstract scala.collection.Seq<Source> |
getMetricsSources(String sourceName)
::DeveloperApi::
Returns all metrics sources with the given name which are associated with the instance
which runs the task.
|
static int |
getPartitionId()
Returns the partition id of currently active TaskContext.
|
abstract boolean |
isCompleted()
Returns true if the task has completed.
|
abstract boolean |
isInterrupted()
Returns true if the task has been killed.
|
abstract int |
partitionId()
The ID of the RDD partition that is computed by this task.
|
abstract scala.collection.immutable.Map<String,ResourceInformation> |
resources()
Resources allocated to the task.
|
abstract java.util.Map<String,ResourceInformation> |
resourcesJMap()
(java-specific) Resources allocated to the task.
|
abstract int |
stageAttemptNumber()
How many times the stage that this task belongs to has been attempted.
|
abstract int |
stageId()
The ID of the stage that this task belong to.
|
abstract long |
taskAttemptId()
An ID that is unique to this task attempt (within the same SparkContext, no two task attempts
will share the same attempt ID).
|
abstract org.apache.spark.executor.TaskMetrics |
taskMetrics() |
public static TaskContext get()
public static int getPartitionId()
public abstract boolean isCompleted()
public abstract boolean isInterrupted()
public abstract TaskContext addTaskCompletionListener(TaskCompletionListener listener)
An example use is for HadoopRDD to register a callback to close the input stream.
Exceptions thrown by the listener will result in failure of the task.
listener
- (undocumented)public <U> TaskContext addTaskCompletionListener(scala.Function1<TaskContext,U> f)
An example use is for HadoopRDD to register a callback to close the input stream.
Exceptions thrown by the listener will result in failure of the task.
f
- (undocumented)public abstract TaskContext addTaskFailureListener(TaskFailureListener listener)
listener
- (undocumented)public TaskContext addTaskFailureListener(scala.Function2<TaskContext,Throwable,scala.runtime.BoxedUnit> f)
f
- (undocumented)public abstract int stageId()
public abstract int stageAttemptNumber()
public abstract int partitionId()
public abstract int attemptNumber()
public abstract long taskAttemptId()
public abstract String getLocalProperty(String key)
org.apache.spark.SparkContext.setLocalProperty
.key
- (undocumented)public abstract scala.collection.immutable.Map<String,ResourceInformation> resources()
ResourceInformation
for
specifics.public abstract java.util.Map<String,ResourceInformation> resourcesJMap()
ResourceInformation
for specifics.public abstract org.apache.spark.executor.TaskMetrics taskMetrics()
public abstract scala.collection.Seq<Source> getMetricsSources(String sourceName)
org.apache.spark.metrics.MetricsSystem
.sourceName
- (undocumented)