Skip to content

Commit

Permalink
[SPARK-19069][CORE] Expose task 'status' and 'duration' in spark hist…
Browse files Browse the repository at this point in the history
…ory server REST API.

## What changes were proposed in this pull request?

Although Spark history server UI shows task ‘status’ and ‘duration’ fields, it does not expose these fields in the REST API response. For the Spark history server API users, it is not possible to determine task status and duration. Spark history server has access to task status and duration from event log, but it is not exposing these in API. This patch is proposed to expose task ‘status’ and ‘duration’ fields in Spark history server REST API.

## How was this patch tested?

Modified existing test cases in org.apache.spark.deploy.history.HistoryServerSuite.

Author: Parag Chaudhari <[email protected]>

Closes apache#16473 from paragpc/expose_task_status.
  • Loading branch information
Parag Chaudhari authored and uzadude committed Jan 27, 2017
1 parent 8b9afe1 commit ccdcec1
Show file tree
Hide file tree
Showing 15 changed files with 360 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ private[v1] object AllStagesResource {
index = uiData.taskInfo.index,
attempt = uiData.taskInfo.attemptNumber,
launchTime = new Date(uiData.taskInfo.launchTime),
duration = uiData.taskDuration,
executorId = uiData.taskInfo.executorId,
host = uiData.taskInfo.host,
status = uiData.taskInfo.status,
taskLocality = uiData.taskInfo.taskLocality.toString(),
speculative = uiData.taskInfo.speculative,
accumulatorUpdates = uiData.taskInfo.accumulables.map { convertAccumulableInfo },
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/org/apache/spark/status/api/v1/api.scala
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,10 @@ class TaskData private[spark](
val index: Int,
val attempt: Int,
val launchTime: Date,
val duration: Option[Long] = None,
val executorId: String,
val host: String,
val status: String,
val taskLocality: String,
val speculative: Boolean,
val accumulatorUpdates: Seq[AccumulableInfo],
Expand Down
6 changes: 2 additions & 4 deletions core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -887,10 +887,8 @@ private[ui] class TaskDataSource(
private def taskRow(taskData: TaskUIData): TaskTableRowData = {
val info = taskData.taskInfo
val metrics = taskData.metrics
val duration = if (info.status == "RUNNING") info.timeRunning(currentTime)
else metrics.map(_.executorRunTime).getOrElse(1L)
val formatDuration = if (info.status == "RUNNING") UIUtils.formatDuration(duration)
else metrics.map(m => UIUtils.formatDuration(m.executorRunTime)).getOrElse("")
val duration = taskData.taskDuration.getOrElse(1L)
val formatDuration = taskData.taskDuration.map(d => UIUtils.formatDuration(d)).getOrElse("")
val schedulerDelay = metrics.map(getSchedulerDelay(info, _, currentTime)).getOrElse(0L)
val gcTime = metrics.map(_.jvmGCTime).getOrElse(0L)
val taskDeserializationTime = metrics.map(_.executorDeserializeTime).getOrElse(0L)
Expand Down
8 changes: 8 additions & 0 deletions core/src/main/scala/org/apache/spark/ui/jobs/UIData.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,14 @@ private[spark] object UIData {
def updateTaskMetrics(metrics: Option[TaskMetrics]): Unit = {
_metrics = TaskUIData.toTaskMetricsUIData(metrics)
}

def taskDuration: Option[Long] = {
if (taskInfo.status == "RUNNING") {
Some(_taskInfo.timeRunning(System.currentTimeMillis))
} else {
_metrics.map(_.executorRunTime)
}
}
}

object TaskUIData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
"index" : 0,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.829GMT",
"duration" : 435,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -73,8 +75,10 @@
"index" : 1,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.830GMT",
"duration" : 436,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -116,8 +120,10 @@
"index" : 2,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.830GMT",
"duration" : 434,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -159,8 +165,10 @@
"index" : 3,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.830GMT",
"duration" : 434,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -202,8 +210,10 @@
"index" : 4,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.831GMT",
"duration" : 434,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -245,8 +255,10 @@
"index" : 5,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.831GMT",
"duration" : 434,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -288,8 +300,10 @@
"index" : 6,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.832GMT",
"duration" : 434,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -331,8 +345,10 @@
"index" : 7,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.833GMT",
"duration" : 435,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@
"index" : 0,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.829GMT",
"duration" : 435,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -73,8 +75,10 @@
"index" : 1,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.830GMT",
"duration" : 436,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -116,8 +120,10 @@
"index" : 2,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.830GMT",
"duration" : 434,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -159,8 +165,10 @@
"index" : 3,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.830GMT",
"duration" : 434,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -202,8 +210,10 @@
"index" : 4,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.831GMT",
"duration" : 434,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -245,8 +255,10 @@
"index" : 5,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.831GMT",
"duration" : 434,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -288,8 +300,10 @@
"index" : 6,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.832GMT",
"duration" : 434,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down Expand Up @@ -331,8 +345,10 @@
"index" : 7,
"attempt" : 0,
"launchTime" : "2015-02-03T16:43:05.833GMT",
"duration" : 435,
"executorId" : "<driver>",
"host" : "localhost",
"status" : "SUCCESS",
"taskLocality" : "PROCESS_LOCAL",
"speculative" : false,
"accumulatorUpdates" : [ ],
Expand Down
Loading

0 comments on commit ccdcec1

Please sign in to comment.