Skip to content

Commit 9e90c46

Browse files
committed
SPARK-1417: Spark on Yarn - spark UI link from resourcemanager is broken
Author: Thomas Graves <tgraves@apache.org> Closes #344 from tgravescs/SPARK-1417 and squashes the following commits: c450b5f [Thomas Graves] fix test e1c1d7e [Thomas Graves] add missing $ to appUIAddress e982ddb [Thomas Graves] use appUIHostPort in appUIAddress 0803ec2 [Thomas Graves] Review comment updates - remove extra newline, simplify assert in test 658a8ec [Thomas Graves] Add a appUIHostPort routine 0614208 [Thomas Graves] Fix test 2a6b1b7 [Thomas Graves] SPARK-1417: Spark on Yarn - spark UI link from resourcemanager is broken
1 parent a1bb4c6 commit 9e90c46

File tree

4 files changed

+43
-3
lines changed

4 files changed

+43
-3
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,12 @@ private[spark] class SparkUI(
113113
logInfo("Stopped Spark Web UI at %s".format(appUIAddress))
114114
}
115115

116-
private[spark] def appUIAddress = "http://" + publicHost + ":" + boundPort
116+
/**
117+
* Return the application UI host:port. This does not include the scheme (http://).
118+
*/
119+
private[spark] def appUIHostPort = publicHost + ":" + boundPort
120+
121+
private[spark] def appUIAddress = s"http://$appUIHostPort"
117122

118123
}
119124

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark
19+
20+
import java.net.URI
21+
22+
import org.scalatest.FunSuite
23+
24+
class SparkUISuite extends FunSuite with SharedSparkContext {
25+
26+
test("verify appUIAddress contains the scheme") {
27+
val uiAddress = sc.ui.appUIAddress
28+
assert(uiAddress.equals("http://" + sc.ui.appUIHostPort))
29+
}
30+
31+
test("verify appUIAddress contains the port") {
32+
val splitUIAddress = sc.ui.appUIAddress.split(':')
33+
assert(splitUIAddress(2).toInt == sc.ui.boundPort)
34+
}
35+
}

yarn/alpha/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ class ApplicationMaster(args: ApplicationMasterArguments, conf: Configuration,
234234
assert(sparkContext != null || count >= numTries)
235235

236236
if (null != sparkContext) {
237-
uiAddress = sparkContext.ui.appUIAddress
237+
uiAddress = sparkContext.ui.appUIHostPort
238238
this.yarnAllocator = YarnAllocationHandler.newAllocator(
239239
yarnConf,
240240
resourceManager,

yarn/stable/src/main/scala/org/apache/spark/deploy/yarn/ApplicationMaster.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ class ApplicationMaster(args: ApplicationMasterArguments, conf: Configuration,
220220
assert(sparkContext != null || numTries >= maxNumTries)
221221

222222
if (sparkContext != null) {
223-
uiAddress = sparkContext.ui.appUIAddress
223+
uiAddress = sparkContext.ui.appUIHostPort
224224
this.yarnAllocator = YarnAllocationHandler.newAllocator(
225225
yarnConf,
226226
amClient,

0 commit comments

Comments
 (0)