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 |
---|---|
abstract void |
addOnCompleteCallback(scala.Function0<scala.runtime.BoxedUnit> f)
Adds a callback function to be executed on task completion.
|
TaskContext |
addTaskCompletionListener(scala.Function1<TaskContext,scala.runtime.BoxedUnit> 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 long |
attemptId() |
abstract int |
attemptNumber()
How many times this task has been attempted.
|
static TaskContext |
get()
Return the currently active TaskContext.
|
abstract scala.collection.Seq<org.apache.spark.metrics.source.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 scala.collection.immutable.Map<String,Accumulator<Object>> |
internalMetricsToAccumulators()
Accumulators for tracking internal metrics indexed by the name.
|
abstract boolean |
isCompleted()
Returns true if the task has completed.
|
abstract boolean |
isInterrupted()
Returns true if the task has been killed.
|
abstract boolean |
isRunningLocally()
Returns true if the task is running locally in the driver program.
|
abstract int |
partitionId()
The ID of the RDD partition that is computed by this task.
|
abstract boolean |
runningLocally() |
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()
::DeveloperApi::
|
public static TaskContext get()
public static int getPartitionId()
public abstract boolean isCompleted()
public abstract boolean isInterrupted()
public abstract boolean runningLocally()
public abstract boolean isRunningLocally()
public abstract TaskContext addTaskCompletionListener(TaskCompletionListener listener)
Exceptions thrown by the listener will result in failure of the task.
listener
- (undocumented)public TaskContext addTaskCompletionListener(scala.Function1<TaskContext,scala.runtime.BoxedUnit> f)
Exceptions thrown by the listener will result in failure of the task.
f
- (undocumented)public abstract TaskContext addTaskFailureListener(TaskFailureListener listener)
onTaskFailure
can be called multiple times.listener
- (undocumented)public TaskContext addTaskFailureListener(scala.Function2<TaskContext,Throwable,scala.runtime.BoxedUnit> f)
onTaskFailure
can be called multiple times.f
- (undocumented)public abstract void addOnCompleteCallback(scala.Function0<scala.runtime.BoxedUnit> f)
f
- Callback function.public abstract int stageId()
public abstract int partitionId()
public abstract int attemptNumber()
public abstract long attemptId()
public abstract long taskAttemptId()
public abstract org.apache.spark.executor.TaskMetrics taskMetrics()
public abstract scala.collection.Seq<org.apache.spark.metrics.source.Source> getMetricsSources(String sourceName)
org.apache.spark.metrics.MetricsSystem!
.sourceName
- (undocumented)public abstract scala.collection.immutable.Map<String,Accumulator<Object>> internalMetricsToAccumulators()