Skip to content

Commit 762b541

Browse files
author
Andrew Or
committed
Use special prefix for stage clusters to avoid collisions
Right now stage clusters assume the ID space of integers. This is not valid, however, after we merge with dag-viz-streaming, where the cluster ID may just be the operation ID. The result is that certain stage clusters disappear on the UI. This patch by itself doesn't fix anything noticeable. However, it does guard against the potential of collision in future changes.
1 parent 51c95b9 commit 762b541

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

core/src/main/resources/org/apache/spark/ui/static/spark-dag-viz.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,10 @@ function renderDagVizForJob(svgContainer) {
190190
.attr("skipped", "true");
191191
} else {
192192
// Link each graph to the corresponding stage page (TODO: handle stage attempts)
193+
// Use the link from the stage table so it also works for the history server
193194
var attemptId = 0
194-
var stageLink = $("#stage-" + stageId + "-" + attemptId)
195-
.find("a")
195+
var stageLink = d3.select("#stage-" + stageId + "-" + attemptId)
196+
.select("a")
196197
.attr("href") + "&expandDagViz=true";
197198
container = svgContainer
198199
.append("a")

core/src/main/scala/org/apache/spark/ui/UIUtils.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,9 @@ private[spark] object UIUtils extends Logging {
355355
<div id="dag-viz-metadata" style="display:none">
356356
{
357357
graphs.map { g =>
358+
val stageId = g.rootCluster.id.replaceAll(RDDOperationGraph.STAGE_CLUSTER_PREFIX, "")
358359
val skipped = g.rootCluster.name.contains("skipped").toString
359-
<div class="stage-metadata" stage-id={g.rootCluster.id} skipped={skipped}>
360+
<div class="stage-metadata" stage-id={stageId} skipped={skipped}>
360361
<div class="dot-file">{RDDOperationGraph.makeDotFile(g)}</div>
361362
{ g.incomingEdges.map { e => <div class="incoming-edge">{e.fromId},{e.toId}</div> } }
362363
{ g.outgoingEdges.map { e => <div class="outgoing-edge">{e.fromId},{e.toId}</div> } }

core/src/main/scala/org/apache/spark/ui/scope/RDDOperationGraph.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ private[ui] class RDDOperationCluster(val id: String, private var _name: String)
7474

7575
private[ui] object RDDOperationGraph extends Logging {
7676

77+
val STAGE_CLUSTER_PREFIX = "stage_"
78+
7779
/**
7880
* Construct a RDDOperationGraph for a given stage.
7981
*
@@ -91,7 +93,8 @@ private[ui] object RDDOperationGraph extends Logging {
9193
val clusters = new mutable.HashMap[String, RDDOperationCluster] // indexed by cluster ID
9294

9395
// Root cluster is the stage cluster
94-
val stageClusterId = stage.stageId.toString
96+
// Use a special prefix here to differentiate this cluster from other operation clusters
97+
val stageClusterId = STAGE_CLUSTER_PREFIX + stage.stageId
9598
val stageClusterName = s"Stage ${stage.stageId}" +
9699
{ if (stage.attemptId == 0) "" else s" (attempt ${stage.attemptId})" }
97100
val rootCluster = new RDDOperationCluster(stageClusterId, stageClusterName)

core/src/main/scala/org/apache/spark/ui/scope/RDDOperationGraphListener.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,12 @@ private[ui] class RDDOperationGraphListener(conf: SparkConf) extends SparkListen
5757
.getOrElse(Seq.empty)
5858
.flatMap { sid => stageIdToGraph.get(sid) }
5959
// Mark any skipped stages as such
60-
graphs
61-
.filter { g => skippedStageIds.contains(g.rootCluster.id.toInt) }
62-
.filter { g => !g.rootCluster.name.contains("skipped") }
63-
.foreach { g => g.rootCluster.setName(g.rootCluster.name + " (skipped)") }
60+
graphs.foreach { g =>
61+
val stageId = g.rootCluster.id.replaceAll(RDDOperationGraph.STAGE_CLUSTER_PREFIX, "").toInt
62+
if (skippedStageIds.contains(stageId) && !g.rootCluster.name.contains("skipped")) {
63+
g.rootCluster.setName(g.rootCluster.name + " (skipped)")
64+
}
65+
}
6466
graphs
6567
}
6668

0 commit comments

Comments
 (0)