Skip to content

Commit 03e0e27

Browse files
committed
addressing comments
1 parent 624acbc commit 03e0e27

File tree

2 files changed

+14
-19
lines changed

2 files changed

+14
-19
lines changed

resource-managers/yarn/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ private[spark] class ApplicationMaster(args: ApplicationMasterArguments) extends
427427
uiAddress: Option[String]) = {
428428
val appId = client.getAttemptId().getApplicationId().toString()
429429
val attemptId = client.getAttemptId().getAttemptId().toString()
430-
val historyAddress = ApplicationMasterUtil
430+
val historyAddress = ApplicationMaster
431431
.getHistoryServerAddress(_sparkConf, yarnConf, appId, attemptId)
432432

433433
val driverUrl = RpcEndpointAddress(
@@ -831,15 +831,11 @@ object ApplicationMaster extends Logging {
831831
master.getAttemptId
832832
}
833833

834-
}
835-
836-
object ApplicationMasterUtil {
837-
def getHistoryServerAddress(
838-
sparkConf: SparkConf,
839-
yarnConf: YarnConfiguration,
840-
appId: String,
841-
attemptId: String): String = {
842-
834+
private[spark] def getHistoryServerAddress(
835+
sparkConf: SparkConf,
836+
yarnConf: YarnConfiguration,
837+
appId: String,
838+
attemptId: String): String = {
843839
sparkConf.get(HISTORY_SERVER_ADDRESS)
844840
.map { text => SparkHadoopUtil.get.substituteHadoopVariables(text, yarnConf) }
845841
.map { address => s"${address}${HistoryServer.UI_PATH_PREFIX}/${appId}/${attemptId}" }
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,27 +18,26 @@
1818
package org.apache.spark.deploy.yarn
1919

2020
import org.apache.hadoop.yarn.conf.YarnConfiguration
21+
2122
import org.apache.spark.{SparkConf, SparkFunSuite}
22-
import org.apache.spark.internal.Logging
23-
import org.apache.spark.util.ResetSystemProperties
24-
import org.scalatest.Matchers
2523

26-
class ApplicationMasterUtilSuite extends SparkFunSuite with Matchers with Logging
27-
with ResetSystemProperties {
24+
class ApplicationMasterSuite extends SparkFunSuite {
2825

2926
test("history url with hadoop and spark substitutions") {
27+
val host = "rm.host.com"
28+
val port = 18080
3029
val sparkConf = new SparkConf()
30+
3131
sparkConf.set("spark.yarn.historyServer.address",
3232
"http://${hadoopconf-yarn.resourcemanager.hostname}:${spark.history.ui.port}")
33-
3433
val yarnConf = new YarnConfiguration()
35-
yarnConf.set("yarn.resourcemanager.hostname", "rm.host.com")
34+
yarnConf.set("yarn.resourcemanager.hostname", host)
3635
val appId = "application_123_1"
3736
val attemptId = appId + "_1"
3837

39-
val shsAddr = ApplicationMasterUtil
38+
val shsAddr = ApplicationMaster
4039
.getHistoryServerAddress(sparkConf, yarnConf, appId, attemptId)
4140

42-
shsAddr shouldEqual "http://rm.host.com:18080/history/application_123_1/application_123_1_1"
41+
assert(shsAddr === s"http://${host}:${port}/history/${appId}/${attemptId}")
4342
}
4443
}

0 commit comments

Comments
 (0)