Skip to content

Commit

Permalink
Automatically expand DAG viz if from job page
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Or committed May 7, 2015
1 parent 14502d5 commit 03cd157
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ function renderDagVizForJob(svgContainer) {
var stageId = metadata.attr("stage-id");
var containerId = VizConstants.graphPrefix + stageId;
// Link each graph to the corresponding stage page (TODO: handle stage attempts)
var stageLink =
"/stages/stage/?id=" + stageId.replace(VizConstants.stagePrefix, "") + "&attempt=0";
var stageLink = "/stages/stage/?id=" +
stageId.replace(VizConstants.stagePrefix, "") + "&attempt=0&expandDagViz=true";
var container = svgContainer
.append("a")
.attr("xlink:href", stageLink)
Expand Down
10 changes: 9 additions & 1 deletion core/src/main/scala/org/apache/spark/ui/UIUtils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ package org.apache.spark.ui
import java.text.SimpleDateFormat
import java.util.{Locale, Date}

import scala.xml.{Node, Text}
import scala.xml.{Node, Text, Unparsed}

import org.apache.spark.Logging
import org.apache.spark.ui.scope.RDDOperationGraph
Expand Down Expand Up @@ -371,4 +371,12 @@ private[spark] object UIUtils extends Logging {
</div>
</div>
}

/** Return a script element that automatically expands the DAG visualization on page load. */
def expandDagVizOnLoad(forJob: Boolean): Seq[Node] = {
<script type="text/javascript">
{Unparsed("$(document).ready(function() { toggleDagViz(" + forJob + ") });")}
</script>
}

}
12 changes: 12 additions & 0 deletions core/src/main/scala/org/apache/spark/ui/jobs/StagePage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ private[ui] class StagePage(parent: StagesTab) extends WebUIPage("stage") {
val parameterAttempt = request.getParameter("attempt")
require(parameterAttempt != null && parameterAttempt.nonEmpty, "Missing attempt parameter")

// If this is set, expand the dag visualization by default
val expandDagVizParam = request.getParameter("expandDagViz")
val expandDagViz = expandDagVizParam != null && expandDagVizParam.toBoolean

val stageId = parameterId.toInt
val stageAttemptId = parameterAttempt.toInt
val stageDataOption = progressListener.stageIdToData.get((stageId, stageAttemptId))
Expand Down Expand Up @@ -174,6 +178,13 @@ private[ui] class StagePage(parent: StagesTab) extends WebUIPage("stage") {
val dagViz = UIUtils.showDagVizForStage(
stageId, operationGraphListener.getOperationGraphForStage(stageId))

val maybeExpandDagViz: Seq[Node] =
if (expandDagViz) {
UIUtils.expandDagVizOnLoad(forJob = false)
} else {
Seq.empty
}

val accumulableHeaders: Seq[String] = Seq("Accumulable", "Value")
def accumulableRow(acc: AccumulableInfo): Elem =
<tr><td>{acc.name}</td><td>{acc.value}</td></tr>
Expand Down Expand Up @@ -440,6 +451,7 @@ private[ui] class StagePage(parent: StagesTab) extends WebUIPage("stage") {
summary ++
showAdditionalMetrics ++
dagViz ++
maybeExpandDagViz ++
<h4>Summary Metrics for {numCompleted} Completed Tasks</h4> ++
<div>{summaryTable.getOrElse("No tasks have reported metrics yet.")}</div> ++
<h4>Aggregated Metrics by Executor</h4> ++ executorTable.toNodeSeq ++
Expand Down

0 comments on commit 03cd157

Please sign in to comment.