diff options
author | Parag Chaudhari <paragpc@amazon.com> | 2017-01-20 10:49:05 -0600 |
---|---|---|
committer | Imran Rashid <irashid@cloudera.com> | 2017-01-20 10:49:05 -0600 |
commit | e20d9b15655ffaf1c220fbad1a2aa1c2d45137ba (patch) | |
tree | 50c275cf7c067510af7cea700fb8b958e77ea4e8 /core/src/main | |
parent | d50d12b49f98e18abd1c0b054b23a64fefd92ea2 (diff) | |
download | spark-e20d9b15655ffaf1c220fbad1a2aa1c2d45137ba.tar.gz spark-e20d9b15655ffaf1c220fbad1a2aa1c2d45137ba.tar.bz2 spark-e20d9b15655ffaf1c220fbad1a2aa1c2d45137ba.zip |
[SPARK-19069][CORE] Expose task 'status' and 'duration' in spark history 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 <paragpc@amazon.com>
Closes #16473 from paragpc/expose_task_status.
Diffstat (limited to 'core/src/main')
4 files changed, 14 insertions, 4 deletions
diff --git a/core/src/main/scala/org/apache/spark/status/api/v1/AllStagesResource.scala b/core/src/main/scala/org/apache/spark/status/api/v1/AllStagesResource.scala index acb7c23079..1818935392 100644 --- a/core/src/main/scala/org/apache/spark/status/api/v1/AllStagesResource.scala +++ b/core/src/main/scala/org/apache/spark/status/api/v1/AllStagesResource.scala @@ -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 }, diff --git a/core/src/main/scala/org/apache/spark/status/api/v1/api.scala b/core/src/main/scala/org/apache/spark/status/api/v1/api.scala index 7d035b11fa..c509398db1 100644 --- a/core/src/main/scala/org/apache/spark/status/api/v1/api.scala +++ b/core/src/main/scala/org/apache/spark/status/api/v1/api.scala @@ -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], diff --git a/core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala b/core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala index 412ddfa9fa..ff17775008 100644 --- a/core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala +++ b/core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala @@ -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) diff --git a/core/src/main/scala/org/apache/spark/ui/jobs/UIData.scala b/core/src/main/scala/org/apache/spark/ui/jobs/UIData.scala index 371dad966d..201e6197ba 100644 --- a/core/src/main/scala/org/apache/spark/ui/jobs/UIData.scala +++ b/core/src/main/scala/org/apache/spark/ui/jobs/UIData.scala @@ -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 { |