-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-4411][UI]Add kill link for jobs in the UI #4823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
af461cc
7f52874
7a6143a
584240a
25fc0fd
ba16839
a0eee0c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,7 @@ private[ui] class AllJobsPage(parent: JobsTab) extends WebUIPage("") { | |
| private val startTime: Option[Long] = parent.sc.map(_.startTime) | ||
| private val listener = parent.listener | ||
|
|
||
| private def jobsTable(jobs: Seq[JobUIData]): Seq[Node] = { | ||
| private def jobsTable(jobs: Seq[JobUIData], killEnabled: Boolean): Seq[Node] = { | ||
| val someJobHasJobGroup = jobs.exists(_.jobGroup.isDefined) | ||
|
|
||
| val columns: Seq[Node] = { | ||
|
|
@@ -42,6 +42,18 @@ private[ui] class AllJobsPage(parent: JobsTab) extends WebUIPage("") { | |
| } | ||
|
|
||
| def makeRow(job: JobUIData): Seq[Node] = { | ||
| // scalastyle:off | ||
| val killLink = if (killEnabled) { | ||
| val killLinkUri = "%s/jobs/job/kill?id=%s&terminate=true" | ||
| .format(UIUtils.prependBaseUri(parent.basePath), job.jobId) | ||
| val confirm = "return window.confirm('Are you sure you want to kill job %s ?');" | ||
| .format(job.jobId) | ||
| <span class="kill-link"> | ||
| (<a href={killLinkUri} onclick={confirm}>kill</a>) | ||
| </span> | ||
| } | ||
| // scalastyle:on | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do you need to disable scalastyle here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, I'm not sure what the type of
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, if killEnabled = false, the type of killLink is Any. |
||
|
|
||
| val lastStageInfo = Option(job.stageIds) | ||
| .filter(_.nonEmpty) | ||
| .flatMap { ids => listener.stageIdToInfo.get(ids.max) } | ||
|
|
@@ -68,6 +80,7 @@ private[ui] class AllJobsPage(parent: JobsTab) extends WebUIPage("") { | |
| <td> | ||
| <span class="description-input" title={lastStageDescription}>{lastStageDescription}</span> | ||
| <a href={detailUrl}>{lastStageName}</a> | ||
| {killLink} | ||
| </td> | ||
| <td sorttable_customkey={job.submissionTime.getOrElse(-1).toString}> | ||
| {formattedSubmissionTime} | ||
|
|
@@ -102,11 +115,14 @@ private[ui] class AllJobsPage(parent: JobsTab) extends WebUIPage("") { | |
| val now = System.currentTimeMillis | ||
|
|
||
| val activeJobsTable = | ||
| jobsTable(activeJobs.sortBy(_.submissionTime.getOrElse(-1L)).reverse) | ||
| jobsTable(activeJobs.sortBy(_.submissionTime.getOrElse(-1L)).reverse, | ||
| killEnabled = parent.killEnabled) | ||
| val completedJobsTable = | ||
| jobsTable(completedJobs.sortBy(_.completionTime.getOrElse(-1L)).reverse) | ||
| jobsTable(completedJobs.sortBy(_.completionTime.getOrElse(-1L)).reverse, | ||
| killEnabled = false) | ||
| val failedJobsTable = | ||
| jobsTable(failedJobs.sortBy(_.completionTime.getOrElse(-1L)).reverse) | ||
| jobsTable(failedJobs.sortBy(_.completionTime.getOrElse(-1L)).reverse, | ||
| killEnabled = false) | ||
|
|
||
| val shouldShowActiveJobs = activeJobs.nonEmpty | ||
| val shouldShowCompletedJobs = completedJobs.nonEmpty | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
|
|
||
| package org.apache.spark.ui.jobs | ||
|
|
||
| import javax.servlet.http.HttpServletRequest | ||
|
|
||
| import org.apache.spark.scheduler.SchedulingMode | ||
| import org.apache.spark.ui.{SparkUI, SparkUITab} | ||
|
|
||
|
|
@@ -29,4 +31,18 @@ private[ui] class JobsTab(parent: SparkUI) extends SparkUITab(parent, "jobs") { | |
|
|
||
| attachPage(new AllJobsPage(this)) | ||
| attachPage(new JobPage(this)) | ||
|
|
||
| def handleKillRequest(request: HttpServletRequest) = { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: extra space before brace, and extra parens around |
||
| if ((killEnabled) && (parent.securityManager.checkModifyPermissions(request.getRemoteUser))) { | ||
| val killFlag = Option(request.getParameter("terminate")).getOrElse("false").toBoolean | ||
| val jobId = Option(request.getParameter("id")).getOrElse("-1").toInt | ||
| if (jobId >= 0 && killFlag && listener.activeJobs.contains(jobId)) { | ||
| sc.get.cancelJob(jobId) | ||
| } | ||
| // Do a quick pause here to give Spark time to kill the job so it shows up as | ||
| // killed after the refresh. Note that this will block the serving thread so the | ||
| // time should be limited in duration. | ||
| Thread.sleep(100) | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few tiny comments to consider, if you have to otherwise make changes to this PR: this might be easier to read with string interpolation