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 @@ -28,6 +28,7 @@ import org.eclipse.jetty.servlet.{ServletContextHandler, ServletHolder}

import org.apache.spark.{SecurityManager, SparkConf}
import org.apache.spark.deploy.SparkHadoopUtil
import org.apache.spark.deploy.history.config.HISTORY_SERVER_UI_PORT
import org.apache.spark.internal.Logging
import org.apache.spark.internal.config._
import org.apache.spark.status.api.v1.{ApiRootResource, ApplicationInfo, UIRoot}
Expand Down Expand Up @@ -276,7 +277,7 @@ object HistoryServer extends Logging {
.newInstance(conf)
.asInstanceOf[ApplicationHistoryProvider]

val port = conf.getInt("spark.history.ui.port", 18080)
val port = conf.get(HISTORY_SERVER_UI_PORT)

val server = new HistoryServer(conf, provider, securityManager, port)
server.bind()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,9 @@ private[spark] object config {
.bytesConf(ByteUnit.BYTE)
.createWithDefaultString("10g")

val HISTORY_SERVER_UI_PORT = ConfigBuilder("spark.history.ui.port")
.doc("Web UI port to bind Spark History Server")
.intConf
.createWithDefault(18080)

}
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,8 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends
uiAddress: Option[String]) = {
val appId = client.getAttemptId().getApplicationId().toString()
val attemptId = client.getAttemptId().getAttemptId().toString()
val historyAddress =
_sparkConf.get(HISTORY_SERVER_ADDRESS)
.map { text => SparkHadoopUtil.get.substituteHadoopVariables(text, yarnConf) }
.map { address => s"${address}${HistoryServer.UI_PATH_PREFIX}/${appId}/${attemptId}" }
.getOrElse("")
val historyAddress = ApplicationMaster
.getHistoryServerAddress(_sparkConf, yarnConf, appId, attemptId)

val driverUrl = RpcEndpointAddress(
_sparkConf.get("spark.driver.host"),
Expand Down Expand Up @@ -834,6 +831,16 @@ object ApplicationMaster extends Logging {
master.getAttemptId
}

private[spark] def getHistoryServerAddress(
sparkConf: SparkConf,
yarnConf: YarnConfiguration,
appId: String,
attemptId: String): String = {
sparkConf.get(HISTORY_SERVER_ADDRESS)
.map { text => SparkHadoopUtil.get.substituteHadoopVariables(text, yarnConf) }
.map { address => s"${address}${HistoryServer.UI_PATH_PREFIX}/${appId}/${attemptId}" }
.getOrElse("")
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.spark.deploy.yarn

import org.apache.hadoop.yarn.conf.YarnConfiguration

import org.apache.spark.{SparkConf, SparkFunSuite}

class ApplicationMasterSuite extends SparkFunSuite {

test("history url with hadoop and spark substitutions") {
val host = "rm.host.com"
val port = 18080
val sparkConf = new SparkConf()

sparkConf.set("spark.yarn.historyServer.address",
"http://${hadoopconf-yarn.resourcemanager.hostname}:${spark.history.ui.port}")
val yarnConf = new YarnConfiguration()
yarnConf.set("yarn.resourcemanager.hostname", host)
val appId = "application_123_1"
val attemptId = appId + "_1"

val shsAddr = ApplicationMaster
.getHistoryServerAddress(sparkConf, yarnConf, appId, attemptId)

assert(shsAddr === s"http://${host}:${port}/history/${appId}/${attemptId}")
}
}