Get current task id in Spark in Java

I need to get the id of the current task in Spark. I searched on Google and the official API, but the only identifiers I can find are the artist ID and the RDD ID. Does anyone know how to get a unique task id? I saw that the TaskInfo class has exactly what I am looking for, but I do not know how to get an instance of this class.

+6
source share
1 answer

To get the identifier of a specific task, you can use TaskContext :

 import org.apache.spark.TaskContext; textFile.map( x -> { TaskContext tc = TaskContext.get(); System.out.println(tc.taskAttemptId()); }); 

Keep in mind that a particular println will be printed on the node that is currently running, and not on the driver console.

+5
source

Source: https://habr.com/ru/post/976670/


All Articles