Skip to content

Commit 1c0981a

Browse files
committed
Make port in HttpServer configurable
1 parent 14174ab commit 1c0981a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

core/src/main/scala/org/apache/spark/HttpServer.scala

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ private[spark] class ServerStateException(message: String) extends Exception(mes
4141
* as well as classes created by the interpreter when the user types in code. This is just a wrapper
4242
* around a Jetty server.
4343
*/
44-
private[spark] class HttpServer(resourceBase: File, securityManager: SecurityManager)
45-
extends Logging {
44+
private[spark] class HttpServer(resourceBase: File,
45+
securityManager: SecurityManager,
46+
localPort: Int = 0) extends Logging {
4647
private var server: Server = null
47-
private var port: Int = -1
48+
private var port: Int = localPort
4849

4950
def start() {
5051
if (server != null) {
@@ -55,7 +56,7 @@ private[spark] class HttpServer(resourceBase: File, securityManager: SecurityMan
5556
val connector = new SocketConnector
5657
connector.setMaxIdleTime(60*1000)
5758
connector.setSoLingerTime(-1)
58-
connector.setPort(0)
59+
connector.setPort(localPort)
5960
server.addConnector(connector)
6061

6162
val threadPool = new QueuedThreadPool

0 commit comments

Comments
 (0)