| <!DOCTYPE HTML> |
| <html lang="en"> |
| <head> |
| <!-- Generated by javadoc (17) on Mon Sep 16 05:41:48 UTC 2024 --> |
| <title>TaskContext (Spark 4.0.0-preview2 JavaDoc)</title> |
| <meta name="viewport" content="width=device-width, initial-scale=1"> |
| <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| <meta name="dc.created" content="2024-09-16"> |
| <meta name="description" content="declaration: package: org.apache.spark, class: TaskContext"> |
| <meta name="generator" content="javadoc/ClassWriterImpl"> |
| <link rel="stylesheet" type="text/css" href="../../../stylesheet.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../script-dir/jquery-ui.min.css" title="Style"> |
| <link rel="stylesheet" type="text/css" href="../../../jquery-ui.overrides.css" title="Style"> |
| <script type="text/javascript" src="../../../script.js"></script> |
| <script type="text/javascript" src="../../../script-dir/jquery-3.6.1.min.js"></script> |
| <script type="text/javascript" src="../../../script-dir/jquery-ui.min.js"></script> |
| </head> |
| <body class="class-declaration-page"> |
| <script type="text/javascript">var evenRowColor = "even-row-color"; |
| var oddRowColor = "odd-row-color"; |
| var tableTab = "table-tab"; |
| var activeTableTab = "active-table-tab"; |
| var pathtoroot = "../../../"; |
| loadScripts(document, 'script');</script> |
| <noscript> |
| <div>JavaScript is disabled on your browser.</div> |
| </noscript> |
| <div class="flex-box"> |
| <header role="banner" class="flex-header"> |
| <nav role="navigation"> |
| <!-- ========= START OF TOP NAVBAR ======= --> |
| <div class="top-nav" id="navbar-top"> |
| <div class="skip-nav"><a href="#skip-navbar-top" title="Skip navigation links">Skip navigation links</a></div> |
| <ul id="navbar-top-firstrow" class="nav-list" title="Navigation"> |
| <li><a href="../../../index.html">Overview</a></li> |
| <li><a href="package-summary.html">Package</a></li> |
| <li class="nav-bar-cell1-rev">Class</li> |
| <li><a href="../../../deprecated-list.html">Deprecated</a></li> |
| <li><a href="../../../index-all.html">Index</a></li> |
| <li><a href="../../../help-doc.html#class">Help</a></li> |
| </ul> |
| </div> |
| <div class="sub-nav"> |
| <div> |
| <ul class="sub-nav-list"> |
| <li>Summary: </li> |
| <li>Nested | </li> |
| <li>Field | </li> |
| <li><a href="#constructor-summary">Constr</a> | </li> |
| <li><a href="#method-summary">Method</a></li> |
| </ul> |
| <ul class="sub-nav-list"> |
| <li>Detail: </li> |
| <li>Field | </li> |
| <li><a href="#constructor-detail">Constr</a> | </li> |
| <li><a href="#method-detail">Method</a></li> |
| </ul> |
| </div> |
| <div class="nav-list-search"><label for="search-input">SEARCH:</label> |
| <input type="text" id="search-input" value="search" disabled="disabled"> |
| <input type="reset" id="reset-button" value="reset" disabled="disabled"> |
| </div> |
| </div> |
| <!-- ========= END OF TOP NAVBAR ========= --> |
| <span class="skip-nav" id="skip-navbar-top"></span></nav> |
| </header> |
| <div class="flex-content"> |
| <main role="main"> |
| <!-- ======== START OF CLASS DATA ======== --> |
| <div class="header"> |
| <div class="sub-title"><span class="package-label-in-type">Package</span> <a href="package-summary.html">org.apache.spark</a></div> |
| <h1 title="Class TaskContext" class="title">Class TaskContext</h1> |
| </div> |
| <div class="inheritance" title="Inheritance Tree"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a> |
| <div class="inheritance">org.apache.spark.TaskContext</div> |
| </div> |
| <section class="class-description" id="class-description"> |
| <dl class="notes"> |
| <dt>All Implemented Interfaces:</dt> |
| <dd><code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Serializable.html" title="class or interface in java.io" class="external-link">Serializable</a></code></dd> |
| </dl> |
| <dl class="notes"> |
| <dt>Direct Known Subclasses:</dt> |
| <dd><code><a href="BarrierTaskContext.html" title="class in org.apache.spark">BarrierTaskContext</a></code></dd> |
| </dl> |
| <hr> |
| <div class="type-signature"><span class="modifiers">public abstract class </span><span class="element-name type-name-label">TaskContext</span> |
| <span class="extends-implements">extends <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a> |
| implements <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/io/Serializable.html" title="class or interface in java.io" class="external-link">Serializable</a></span></div> |
| <div class="block">Contextual information about a task which can be read or mutated during |
| execution. To access the TaskContext for a running task, use: |
| <pre><code> |
| org.apache.spark.TaskContext.get() |
| </code></pre></div> |
| <dl class="notes"> |
| <dt>See Also:</dt> |
| <dd> |
| <ul class="see-list"> |
| <li><a href="../../../serialized-form.html#org.apache.spark.TaskContext">Serialized Form</a></li> |
| </ul> |
| </dd> |
| </dl> |
| </section> |
| <section class="summary"> |
| <ul class="summary-list"> |
| <!-- ======== CONSTRUCTOR SUMMARY ======== --> |
| <li> |
| <section class="constructor-summary" id="constructor-summary"> |
| <h2>Constructor Summary</h2> |
| <div class="caption"><span>Constructors</span></div> |
| <div class="summary-table two-column-summary"> |
| <div class="table-header col-first">Constructor</div> |
| <div class="table-header col-last">Description</div> |
| <div class="col-constructor-name even-row-color"><code><a href="#%3Cinit%3E()" class="member-name-link">TaskContext</a>()</code></div> |
| <div class="col-last even-row-color"> </div> |
| </div> |
| </section> |
| </li> |
| <!-- ========== METHOD SUMMARY =========== --> |
| <li> |
| <section class="method-summary" id="method-summary"> |
| <h2>Method Summary</h2> |
| <div id="method-summary-table"> |
| <div class="table-tabs" role="tablist" aria-orientation="horizontal"><button id="method-summary-table-tab0" role="tab" aria-selected="true" aria-controls="method-summary-table.tabpanel" tabindex="0" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table', 3)" class="active-table-tab">All Methods</button><button id="method-summary-table-tab1" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab1', 3)" class="table-tab">Static Methods</button><button id="method-summary-table-tab2" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab2', 3)" class="table-tab">Instance Methods</button><button id="method-summary-table-tab3" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab3', 3)" class="table-tab">Abstract Methods</button><button id="method-summary-table-tab4" role="tab" aria-selected="false" aria-controls="method-summary-table.tabpanel" tabindex="-1" onkeydown="switchTab(event)" onclick="show('method-summary-table', 'method-summary-table-tab4', 3)" class="table-tab">Concrete Methods</button></div> |
| <div id="method-summary-table.tabpanel" role="tabpanel" aria-labelledby="method-summary-table-tab0"> |
| <div class="summary-table three-column-summary"> |
| <div class="table-header col-first">Modifier and Type</div> |
| <div class="table-header col-second">Method</div> |
| <div class="table-header col-last">Description</div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract <a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#addTaskCompletionListener(org.apache.spark.util.TaskCompletionListener)" class="member-name-link">addTaskCompletionListener</a><wbr>(<a href="util/TaskCompletionListener.html" title="interface in org.apache.spark.util">TaskCompletionListener</a> listener)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Adds a (Java friendly) listener to be executed on task completion.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><U> <a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#addTaskCompletionListener(scala.Function1)" class="member-name-link">addTaskCompletionListener</a><wbr>(scala.Function1<<a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a>,<wbr>U> f)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Adds a listener in the form of a Scala closure to be executed on task completion.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract <a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#addTaskFailureListener(org.apache.spark.util.TaskFailureListener)" class="member-name-link">addTaskFailureListener</a><wbr>(<a href="util/TaskFailureListener.html" title="interface in org.apache.spark.util">TaskFailureListener</a> listener)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Adds a listener to be executed on task failure (which includes completion listener failure, if |
| the task body did not already fail).</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"><code><a href="#addTaskFailureListener(scala.Function2)" class="member-name-link">addTaskFailureListener</a><wbr>(scala.Function2<<a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Throwable.html" title="class or interface in java.lang" class="external-link">Throwable</a>,<wbr>scala.runtime.BoxedUnit> f)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab4"> |
| <div class="block">Adds a listener to be executed on task failure (which includes completion listener failure, if |
| the task body did not already fail).</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract int</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#attemptNumber()" class="member-name-link">attemptNumber</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">How many times this task has been attempted.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract int</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#cpus()" class="member-name-link">cpus</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">CPUs allocated to the task.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static <a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#get()" class="member-name-link">get</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"> |
| <div class="block">Return the currently active TaskContext.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getLocalProperty(java.lang.String)" class="member-name-link">getLocalProperty</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a> key)</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Get a local property set upstream in the driver, or null if it is missing.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract scala.collection.immutable.Seq<<a href="metrics/source/Source.html" title="interface in org.apache.spark.metrics.source">Source</a>></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#getMetricsSources(java.lang.String)" class="member-name-link">getMetricsSources</a><wbr>(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a> sourceName)</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">::DeveloperApi:: |
| Returns all metrics sources with the given name which are associated with the instance |
| which runs the task.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code>static int</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"><code><a href="#getPartitionId()" class="member-name-link">getPartitionId</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab1 method-summary-table-tab4"> |
| <div class="block">Returns the partition id of currently active TaskContext.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract boolean</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#isCompleted()" class="member-name-link">isCompleted</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Returns true if the task has completed.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract boolean</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#isFailed()" class="member-name-link">isFailed</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Returns true if the task has failed.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract boolean</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#isInterrupted()" class="member-name-link">isInterrupted</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Returns true if the task has been killed.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract int</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#numPartitions()" class="member-name-link">numPartitions</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Total number of partitions in the stage that this task belongs to.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract int</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#partitionId()" class="member-name-link">partitionId</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">The ID of the RDD partition that is computed by this task.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract scala.collection.immutable.Map<<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="resource/ResourceInformation.html" title="class in org.apache.spark.resource">ResourceInformation</a>></code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#resources()" class="member-name-link">resources</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">Resources allocated to the task.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a><<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="resource/ResourceInformation.html" title="class in org.apache.spark.resource">ResourceInformation</a>></code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#resourcesJMap()" class="member-name-link">resourcesJMap</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">(java-specific) Resources allocated to the task.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract int</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#stageAttemptNumber()" class="member-name-link">stageAttemptNumber</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">How many times the stage that this task belongs to has been attempted.</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract int</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#stageId()" class="member-name-link">stageId</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">The ID of the stage that this task belong to.</div> |
| </div> |
| <div class="col-first odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract long</code></div> |
| <div class="col-second odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#taskAttemptId()" class="member-name-link">taskAttemptId</a>()</code></div> |
| <div class="col-last odd-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> |
| <div class="block">An ID that is unique to this task attempt (within the same SparkContext, no two task attempts |
| will share the same attempt ID).</div> |
| </div> |
| <div class="col-first even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code>abstract org.apache.spark.executor.TaskMetrics</code></div> |
| <div class="col-second even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"><code><a href="#taskMetrics()" class="member-name-link">taskMetrics</a>()</code></div> |
| <div class="col-last even-row-color method-summary-table method-summary-table-tab2 method-summary-table-tab3"> </div> |
| </div> |
| </div> |
| </div> |
| <div class="inherited-list"> |
| <h3 id="methods-inherited-from-class-Object">Methods inherited from class java.lang.<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html" title="class or interface in java.lang" class="external-link">Object</a></h3> |
| <code><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#equals(java.lang.Object)" title="class or interface in java.lang" class="external-link">equals</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#getClass()" title="class or interface in java.lang" class="external-link">getClass</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#hashCode()" title="class or interface in java.lang" class="external-link">hashCode</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notify()" title="class or interface in java.lang" class="external-link">notify</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#notifyAll()" title="class or interface in java.lang" class="external-link">notifyAll</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#toString()" title="class or interface in java.lang" class="external-link">toString</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait()" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long)" title="class or interface in java.lang" class="external-link">wait</a>, <a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Object.html#wait(long,int)" title="class or interface in java.lang" class="external-link">wait</a></code></div> |
| </section> |
| </li> |
| </ul> |
| </section> |
| <section class="details"> |
| <ul class="details-list"> |
| <!-- ========= CONSTRUCTOR DETAIL ======== --> |
| <li> |
| <section class="constructor-details" id="constructor-detail"> |
| <h2>Constructor Details</h2> |
| <ul class="member-list"> |
| <li> |
| <section class="detail" id="<init>()"> |
| <h3>TaskContext</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="element-name">TaskContext</span>()</div> |
| </section> |
| </li> |
| </ul> |
| </section> |
| </li> |
| <!-- ============ METHOD DETAIL ========== --> |
| <li> |
| <section class="method-details" id="method-detail"> |
| <h2>Method Details</h2> |
| <ul class="member-list"> |
| <li> |
| <section class="detail" id="get()"> |
| <h3>get</h3> |
| <div class="member-signature"><span class="modifiers">public static</span> <span class="return-type"><a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a></span> <span class="element-name">get</span>()</div> |
| <div class="block">Return the currently active TaskContext. This can be called inside of |
| user functions to access contextual information about running tasks.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="getPartitionId()"> |
| <h3>getPartitionId</h3> |
| <div class="member-signature"><span class="modifiers">public static</span> <span class="return-type">int</span> <span class="element-name">getPartitionId</span>()</div> |
| <div class="block">Returns the partition id of currently active TaskContext. It will return 0 |
| if there is no active TaskContext for cases like local execution.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="isCompleted()"> |
| <h3>isCompleted</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">boolean</span> <span class="element-name">isCompleted</span>()</div> |
| <div class="block">Returns true if the task has completed.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="isFailed()"> |
| <h3>isFailed</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">boolean</span> <span class="element-name">isFailed</span>()</div> |
| <div class="block">Returns true if the task has failed.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="isInterrupted()"> |
| <h3>isInterrupted</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">boolean</span> <span class="element-name">isInterrupted</span>()</div> |
| <div class="block">Returns true if the task has been killed.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="addTaskCompletionListener(org.apache.spark.util.TaskCompletionListener)"> |
| <h3>addTaskCompletionListener</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type"><a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a></span> <span class="element-name">addTaskCompletionListener</span><wbr><span class="parameters">(<a href="util/TaskCompletionListener.html" title="interface in org.apache.spark.util">TaskCompletionListener</a> listener)</span></div> |
| <div class="block">Adds a (Java friendly) listener to be executed on task completion. |
| This will be called in all situations - success, failure, or cancellation. Adding a listener |
| to an already completed task will result in that listener being called immediately. |
| <p> |
| Two listeners registered in the same thread will be invoked in reverse order of registration if |
| the task completes after both are registered. There are no ordering guarantees for listeners |
| registered in different threads, or for listeners registered after the task completes. |
| Listeners are guaranteed to execute sequentially. |
| <p> |
| An example use is for HadoopRDD to register a callback to close the input stream. |
| <p> |
| Exceptions thrown by the listener will result in failure of the task.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>listener</code> - (undocumented)</dd> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="addTaskCompletionListener(scala.Function1)"> |
| <h3>addTaskCompletionListener</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="type-parameters"><U></span> <span class="return-type"><a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a></span> <span class="element-name">addTaskCompletionListener</span><wbr><span class="parameters">(scala.Function1<<a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a>,<wbr>U> f)</span></div> |
| <div class="block">Adds a listener in the form of a Scala closure to be executed on task completion. |
| This will be called in all situations - success, failure, or cancellation. Adding a listener |
| to an already completed task will result in that listener being called immediately. |
| <p> |
| An example use is for HadoopRDD to register a callback to close the input stream. |
| <p> |
| Exceptions thrown by the listener will result in failure of the task.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>f</code> - (undocumented)</dd> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="addTaskFailureListener(org.apache.spark.util.TaskFailureListener)"> |
| <h3>addTaskFailureListener</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type"><a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a></span> <span class="element-name">addTaskFailureListener</span><wbr><span class="parameters">(<a href="util/TaskFailureListener.html" title="interface in org.apache.spark.util">TaskFailureListener</a> listener)</span></div> |
| <div class="block">Adds a listener to be executed on task failure (which includes completion listener failure, if |
| the task body did not already fail). Adding a listener to an already failed task will result in |
| that listener being called immediately. |
| <p> |
| Note: Prior to Spark 3.4.0, failure listeners were only invoked if the main task body failed.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>listener</code> - (undocumented)</dd> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="addTaskFailureListener(scala.Function2)"> |
| <h3>addTaskFailureListener</h3> |
| <div class="member-signature"><span class="modifiers">public</span> <span class="return-type"><a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a></span> <span class="element-name">addTaskFailureListener</span><wbr><span class="parameters">(scala.Function2<<a href="TaskContext.html" title="class in org.apache.spark">TaskContext</a>,<wbr><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/Throwable.html" title="class or interface in java.lang" class="external-link">Throwable</a>,<wbr>scala.runtime.BoxedUnit> f)</span></div> |
| <div class="block">Adds a listener to be executed on task failure (which includes completion listener failure, if |
| the task body did not already fail). Adding a listener to an already failed task will result in |
| that listener being called immediately. |
| <p> |
| Note: Prior to Spark 3.4.0, failure listeners were only invoked if the main task body failed.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>f</code> - (undocumented)</dd> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="stageId()"> |
| <h3>stageId</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">int</span> <span class="element-name">stageId</span>()</div> |
| <div class="block">The ID of the stage that this task belong to.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="stageAttemptNumber()"> |
| <h3>stageAttemptNumber</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">int</span> <span class="element-name">stageAttemptNumber</span>()</div> |
| <div class="block">How many times the stage that this task belongs to has been attempted. The first stage attempt |
| will be assigned stageAttemptNumber = 0, and subsequent attempts will have increasing attempt |
| numbers.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="partitionId()"> |
| <h3>partitionId</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">int</span> <span class="element-name">partitionId</span>()</div> |
| <div class="block">The ID of the RDD partition that is computed by this task.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="numPartitions()"> |
| <h3>numPartitions</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">int</span> <span class="element-name">numPartitions</span>()</div> |
| <div class="block">Total number of partitions in the stage that this task belongs to.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="attemptNumber()"> |
| <h3>attemptNumber</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">int</span> <span class="element-name">attemptNumber</span>()</div> |
| <div class="block">How many times this task has been attempted. The first task attempt will be assigned |
| attemptNumber = 0, and subsequent attempts will have increasing attempt numbers.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="taskAttemptId()"> |
| <h3>taskAttemptId</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">long</span> <span class="element-name">taskAttemptId</span>()</div> |
| <div class="block">An ID that is unique to this task attempt (within the same SparkContext, no two task attempts |
| will share the same attempt ID). This is roughly equivalent to Hadoop's TaskAttemptID.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="getLocalProperty(java.lang.String)"> |
| <h3>getLocalProperty</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a></span> <span class="element-name">getLocalProperty</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a> key)</span></div> |
| <div class="block">Get a local property set upstream in the driver, or null if it is missing. See also |
| <code>org.apache.spark.SparkContext.setLocalProperty</code>.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>key</code> - (undocumented)</dd> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="cpus()"> |
| <h3>cpus</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">int</span> <span class="element-name">cpus</span>()</div> |
| <div class="block">CPUs allocated to the task.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="resources()"> |
| <h3>resources</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">scala.collection.immutable.Map<<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="resource/ResourceInformation.html" title="class in org.apache.spark.resource">ResourceInformation</a>></span> <span class="element-name">resources</span>()</div> |
| <div class="block">Resources allocated to the task. The key is the resource name and the value is information |
| about the resource. Please refer to <a href="resource/ResourceInformation.html" title="class in org.apache.spark.resource"><code>ResourceInformation</code></a> for |
| specifics.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="resourcesJMap()"> |
| <h3>resourcesJMap</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type"><a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/Map.html" title="class or interface in java.util" class="external-link">Map</a><<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a>,<wbr><a href="resource/ResourceInformation.html" title="class in org.apache.spark.resource">ResourceInformation</a>></span> <span class="element-name">resourcesJMap</span>()</div> |
| <div class="block">(java-specific) Resources allocated to the task. The key is the resource name and the value |
| is information about the resource. Please refer to |
| <a href="resource/ResourceInformation.html" title="class in org.apache.spark.resource"><code>ResourceInformation</code></a> for specifics.</div> |
| <dl class="notes"> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="taskMetrics()"> |
| <h3>taskMetrics</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">org.apache.spark.executor.TaskMetrics</span> <span class="element-name">taskMetrics</span>()</div> |
| </section> |
| </li> |
| <li> |
| <section class="detail" id="getMetricsSources(java.lang.String)"> |
| <h3>getMetricsSources</h3> |
| <div class="member-signature"><span class="modifiers">public abstract</span> <span class="return-type">scala.collection.immutable.Seq<<a href="metrics/source/Source.html" title="interface in org.apache.spark.metrics.source">Source</a>></span> <span class="element-name">getMetricsSources</span><wbr><span class="parameters">(<a href="https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/lang/String.html" title="class or interface in java.lang" class="external-link">String</a> sourceName)</span></div> |
| <div class="block">::DeveloperApi:: |
| Returns all metrics sources with the given name which are associated with the instance |
| which runs the task. For more information see <code>org.apache.spark.metrics.MetricsSystem</code>.</div> |
| <dl class="notes"> |
| <dt>Parameters:</dt> |
| <dd><code>sourceName</code> - (undocumented)</dd> |
| <dt>Returns:</dt> |
| <dd>(undocumented)</dd> |
| </dl> |
| </section> |
| </li> |
| </ul> |
| </section> |
| </li> |
| </ul> |
| </section> |
| <!-- ========= END OF CLASS DATA ========= --> |
| </main> |
| </div> |
| </div> |
| <script defer="defer" type="text/javascript" src="../../../lib/jquery.js"></script><script defer="defer" type="text/javascript" src="../../../lib/api-javadocs.js"></script></body> |
| </html> |