Skip to content

Commit 2f44074

Browse files
gengliangwangSeongjin Cho
authored andcommitted
[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 apache#28179 from gengliangwang/addSubmittedTimeAndDuration. Authored-by: Gengliang Wang <gengliang.wang@databricks.com> Signed-off-by: Gengliang Wang <gengliang.wang@databricks.com>
1 parent 59afac5 commit 2f44074

3 files changed

Lines changed: 49 additions & 8 deletions

File tree

core/src/main/scala/org/apache/spark/ui/jobs/AllJobsPage.scala

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,10 @@ private[ui] class JobDataSource(
442442
}
443443

444444
private def jobRow(jobData: v1.JobData): JobTableRowData = {
445-
val duration: Option[Long] = {
446-
jobData.submissionTime.map { start =>
447-
val end = jobData.completionTime.map(_.getTime()).getOrElse(System.currentTimeMillis())
448-
end - start.getTime()
449-
}
450-
}
451-
val formattedDuration = duration.map(d => UIUtils.formatDuration(d)).getOrElse("Unknown")
445+
val duration: Option[Long] = JobDataUtil.getDuration(jobData)
446+
val formattedDuration = JobDataUtil.getFormattedDuration(jobData)
452447
val submissionTime = jobData.submissionTime
453-
val formattedSubmissionTime = submissionTime.map(UIUtils.formatDate).getOrElse("Unknown")
448+
val formattedSubmissionTime = JobDataUtil.getFormattedSubmissionTime(jobData)
454449
val (lastStageName, lastStageDescription) = lastStageNameAndDescription(store, jobData)
455450

456451
val jobDescription =
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.spark.ui.jobs
18+
19+
import org.apache.spark.status.api.v1.JobData
20+
import org.apache.spark.ui.UIUtils
21+
22+
private[ui] object JobDataUtil {
23+
def getDuration(jobData: JobData): Option[Long] = {
24+
jobData.submissionTime.map { start =>
25+
val end = jobData.completionTime.map(_.getTime()).getOrElse(System.currentTimeMillis())
26+
end - start.getTime()
27+
}
28+
}
29+
30+
def getFormattedDuration(jobData: JobData): String = {
31+
val duration = getDuration(jobData)
32+
duration.map(d => UIUtils.formatDuration(d)).getOrElse("Unknown")
33+
}
34+
35+
def getFormattedSubmissionTime(jobData: JobData): String = {
36+
jobData.submissionTime.map(UIUtils.formatDate).getOrElse("Unknown")
37+
}
38+
}

core/src/main/scala/org/apache/spark/ui/jobs/JobPage.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,14 @@ private[ui] class JobPage(parent: JobsTab, store: AppStatusStore) extends WebUIP
314314
<Strong>Status:</Strong>
315315
{jobData.status}
316316
</li>
317+
<li>
318+
<Strong>Submitted:</Strong>
319+
{JobDataUtil.getFormattedSubmissionTime(jobData)}
320+
</li>
321+
<li>
322+
<Strong>Duration:</Strong>
323+
{JobDataUtil.getFormattedDuration(jobData)}
324+
</li>
317325
{
318326
if (sqlExecutionId.isDefined) {
319327
<li>

0 commit comments

Comments
 (0)