You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ge...@apache.org on 2020/04/14 00:14:27 UTC

[spark] branch master updated: [SPARK-31411][UI] Show submitted time and duration in job details page

This is an automated email from the ASF dual-hosted git repository.

gengliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 28e1a4f  [SPARK-31411][UI] Show submitted time and duration in job details page
28e1a4f is described below

commit 28e1a4fa93f32bf4b94e25d06c5419f978c6eced
Author: Gengliang Wang <ge...@databricks.com>
AuthorDate: Mon Apr 13 17:12:26 2020 -0700

    [SPARK-31411][UI] Show submitted time and duration in job details page
    
    ### What changes were proposed in this pull request?
    
    Show submitted time and duration of a job in its details page
    
    ### Why are the changes needed?
    
    When we check job details from the SQL execution page, it will be more convenient if we can get the submission time and duration from the job page, instead of finding the info from job list page.
    
    ### Does this PR introduce any user-facing change?
    
    Yes. After changes, the job details page shows the submitted time and duration.
    
    ### How was this patch tested?
    
    Manual check
    ![image](https://user-images.githubusercontent.com/1097932/78974997-0a1de280-7ac8-11ea-8072-ce7a001b1b0c.png)
    
    Closes #28179 from gengliangwang/addSubmittedTimeAndDuration.
    
    Authored-by: Gengliang Wang <ge...@databricks.com>
    Signed-off-by: Gengliang Wang <ge...@databricks.com>
---
 .../org/apache/spark/ui/jobs/AllJobsPage.scala     | 11 ++-----
 .../org/apache/spark/ui/jobs/JobDataUtil.scala     | 38 ++++++++++++++++++++++
 .../scala/org/apache/spark/ui/jobs/JobPage.scala   |  8 +++++
 3 files changed, 49 insertions(+), 8 deletions(-)

diff --git a/core/src/main/scala/org/apache/spark/ui/jobs/AllJobsPage.scala b/core/src/main/scala/org/apache/spark/ui/jobs/AllJobsPage.scala
index 3fa4ecc..68c8d82 100644
--- a/core/src/main/scala/org/apache/spark/ui/jobs/AllJobsPage.scala
+++ b/core/src/main/scala/org/apache/spark/ui/jobs/AllJobsPage.scala
@@ -442,15 +442,10 @@ private[ui] class JobDataSource(
   }
 
   private def jobRow(jobData: v1.JobData): JobTableRowData = {
-    val duration: Option[Long] = {
-      jobData.submissionTime.map { start =>
-        val end = jobData.completionTime.map(_.getTime()).getOrElse(System.currentTimeMillis())
-        end - start.getTime()
-      }
-    }
-    val formattedDuration = duration.map(d => UIUtils.formatDuration(d)).getOrElse("Unknown")
+    val duration: Option[Long] = JobDataUtil.getDuration(jobData)
+    val formattedDuration = JobDataUtil.getFormattedDuration(jobData)
     val submissionTime = jobData.submissionTime
-    val formattedSubmissionTime = submissionTime.map(UIUtils.formatDate).getOrElse("Unknown")
+    val formattedSubmissionTime = JobDataUtil.getFormattedSubmissionTime(jobData)
     val (lastStageName, lastStageDescription) = lastStageNameAndDescription(store, jobData)
 
     val jobDescription =
diff --git a/core/src/main/scala/org/apache/spark/ui/jobs/JobDataUtil.scala b/core/src/main/scala/org/apache/spark/ui/jobs/JobDataUtil.scala
new file mode 100644
index 0000000..f357fec
--- /dev/null
+++ b/core/src/main/scala/org/apache/spark/ui/jobs/JobDataUtil.scala
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.spark.ui.jobs
+
+import org.apache.spark.status.api.v1.JobData
+import org.apache.spark.ui.UIUtils
+
+private[ui] object JobDataUtil {
+  def getDuration(jobData: JobData): Option[Long] = {
+    jobData.submissionTime.map { start =>
+        val end = jobData.completionTime.map(_.getTime()).getOrElse(System.currentTimeMillis())
+        end - start.getTime()
+    }
+  }
+
+  def getFormattedDuration(jobData: JobData): String = {
+    val duration = getDuration(jobData)
+    duration.map(d => UIUtils.formatDuration(d)).getOrElse("Unknown")
+  }
+
+  def getFormattedSubmissionTime(jobData: JobData): String = {
+    jobData.submissionTime.map(UIUtils.formatDate).getOrElse("Unknown")
+  }
+}
diff --git a/core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala b/core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala
index 348baab..eacc6ce 100644
--- a/core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala
+++ b/core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala
@@ -314,6 +314,14 @@ private[ui] class JobPage(parent: JobsTab, store: AppStatusStore) extends WebUIP
             <Strong>Status:</Strong>
             {jobData.status}
           </li>
+          <li>
+            <Strong>Submitted:</Strong>
+            {JobDataUtil.getFormattedSubmissionTime(jobData)}
+          </li>
+          <li>
+            <Strong>Duration:</Strong>
+            {JobDataUtil.getFormattedDuration(jobData)}
+          </li>
           {
             if (sqlExecutionId.isDefined) {
               <li>


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org