Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ import org.apache.spark.deploy.DeployMessages.{KillDriverResponse, MasterStateRe
import org.apache.spark.deploy.JsonProtocol
import org.apache.spark.deploy.StandaloneResourceUtils._
import org.apache.spark.deploy.master._
import org.apache.spark.internal.config.UI.MASTER_UI_TITLE
import org.apache.spark.ui.{UIUtils, WebUIPage}
import org.apache.spark.util.Utils

private[ui] class MasterPage(parent: MasterWebUI) extends WebUIPage("") {
private val master = parent.masterEndpointRef
private val title = parent.master.conf.get(MASTER_UI_TITLE)
private val jsonFieldPattern = "/json/([a-zA-Z]+).*".r

def getMasterState: MasterStateResponse = {
Expand Down Expand Up @@ -266,7 +268,7 @@ private[ui] class MasterPage(parent: MasterWebUI) extends WebUIPage("") {
}
</div>;

UIUtils.basicSparkPage(request, content, "Spark Master at " + state.uri)
UIUtils.basicSparkPage(request, content, title.getOrElse("Spark Master at " + state.uri))
}

private def workerRow(showResourceColumn: Boolean): WorkerInfo => Seq[Node] = worker => {
Expand Down
7 changes: 7 additions & 0 deletions core/src/main/scala/org/apache/spark/internal/config/UI.scala
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,13 @@ private[spark] object UI {
.checkValues(Set("ALLOW", "LOCAL", "DENY"))
.createWithDefault("LOCAL")

val MASTER_UI_TITLE = ConfigBuilder("spark.master.ui.title")
.version("4.0.0")
.doc("Specifies the title of the Master UI page. If unset, `Spark Master at <MasterURL>` " +
"is used by default.")
.stringConf
.createOptional

val UI_SQL_GROUP_SUB_EXECUTION_ENABLED = ConfigBuilder("spark.ui.groupSQLSubExecutionEnabled")
.doc("Whether to group sub executions together in SQL UI when they belong to the same " +
"root execution")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,22 @@ class MasterWorkerUISuite extends MasterSuiteBase {
System.getProperties().remove("spark.ui.proxyBase")
}
}

test("SPARK-49007: Support custom master web ui title") {
implicit val formats = org.json4s.DefaultFormats
val title = "Spark Custom Title"
val conf = new SparkConf().set(MASTER_UI_TITLE, title)
val localCluster = LocalSparkCluster(2, 2, 512, conf)
localCluster.start()
val masterUrl = s"http://${Utils.localHostNameForURI()}:${localCluster.masterWebUIPort}"
try {
eventually(timeout(50.seconds), interval(100.milliseconds)) {
val html = Utils
.tryWithResource(Source.fromURL(s"$masterUrl/"))(_.getLines().mkString("\n"))
html should include (title)
}
} finally {
localCluster.stop()
}
}
}