Skip to content

Commit d4da80b

Browse files
specify range for port retry
1 parent fdea6d8 commit d4da80b

File tree

45 files changed

+145
-154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+145
-154
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.apache.spark.util.Utils
2626
private[spark] class HttpFileServer(
2727
conf: SparkConf,
2828
securityManager: SecurityManager,
29-
requestedPort: Int = 0)
29+
requestedPort: String = "0")
3030
extends Logging {
3131

3232
var baseDir : File = null

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ private[spark] class HttpServer(
4646
conf: SparkConf,
4747
resourceBase: File,
4848
securityManager: SecurityManager,
49-
requestedPort: Int = 0,
49+
requestedPort: String = "0",
5050
serverName: String = "HTTP server")
5151
extends Logging {
5252

5353
private var server: Server = null
54-
private var port: Int = requestedPort
54+
private var port: Int = 0
5555

5656
def start() {
5757
if (server != null) {

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ object SparkEnv extends Logging {
182182
assert(conf.contains("spark.driver.host"), "spark.driver.host is not set on the driver!")
183183
assert(conf.contains("spark.driver.port"), "spark.driver.port is not set on the driver!")
184184
val hostname = conf.get("spark.driver.host")
185-
val port = conf.get("spark.driver.port").toInt
185+
val port = conf.get("spark.driver.port")
186186
create(
187187
conf,
188188
SparkContext.DRIVER_IDENTIFIER,
@@ -203,7 +203,7 @@ object SparkEnv extends Logging {
203203
conf: SparkConf,
204204
executorId: String,
205205
hostname: String,
206-
port: Int,
206+
port: String,
207207
numCores: Int,
208208
isLocal: Boolean): SparkEnv = {
209209
val env = create(
@@ -226,7 +226,7 @@ object SparkEnv extends Logging {
226226
conf: SparkConf,
227227
executorId: String,
228228
hostname: String,
229-
port: Int,
229+
port: String,
230230
isDriver: Boolean,
231231
isLocal: Boolean,
232232
listenerBus: LiveListenerBus = null,
@@ -342,7 +342,7 @@ object SparkEnv extends Logging {
342342

343343
val httpFileServer =
344344
if (isDriver) {
345-
val fileServerPort = conf.getInt("spark.fileserver.port", 0)
345+
val fileServerPort = conf.get("spark.fileserver.port", "0")
346346
val server = new HttpFileServer(conf, securityManager, fileServerPort)
347347
server.initialize()
348348
conf.set("spark.fileserver.uri", server.serverUri)

core/src/main/scala/org/apache/spark/broadcast/HttpBroadcast.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ private[broadcast] object HttpBroadcast extends Logging {
152152

153153
private def createServer(conf: SparkConf) {
154154
broadcastDir = Utils.createTempDir(Utils.getLocalDir(conf), "broadcast")
155-
val broadcastPort = conf.getInt("spark.broadcast.port", 0)
155+
val broadcastPort = conf.get("spark.broadcast.port", "0")
156156
server =
157157
new HttpServer(conf, broadcastDir, securityManager, broadcastPort, "HTTP broadcast server")
158158
server.start()

core/src/main/scala/org/apache/spark/deploy/Client.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ object Client {
160160
Logger.getRootLogger.setLevel(driverArgs.logLevel)
161161

162162
val (actorSystem, _) = AkkaUtils.createActorSystem(
163-
"driverClient", Utils.localHostName(), 0, conf, new SecurityManager(conf))
163+
"driverClient", Utils.localHostName(), "0", conf, new SecurityManager(conf))
164164

165165
// Verify driverArgs.master is a valid url so that we can use it in ClientActor safely
166166
Master.toAkkaUrl(driverArgs.master, AkkaUtils.protocol(actorSystem))

core/src/main/scala/org/apache/spark/deploy/LocalSparkCluster.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ class LocalSparkCluster(
5151
val _conf = conf.clone().setIfMissing("spark.master.rest.enabled", "false")
5252

5353
/* Start the Master */
54-
val (masterSystem, masterPort, _, _) = Master.startSystemAndActor(localHostname, 0, 0, _conf)
54+
val (masterSystem, masterPort, _, _) = Master.startSystemAndActor(localHostname, "0", "0", _conf)
5555
masterActorSystems += masterSystem
5656
val masterUrl = "spark://" + Utils.localHostNameForURI() + ":" + masterPort
5757
val masters = Array(masterUrl)
5858

5959
/* Start the Workers */
6060
for (workerNum <- 1 to numWorkers) {
61-
val (workerSystem, _) = Worker.startSystemAndActor(localHostname, 0, 0, coresPerWorker,
61+
val (workerSystem, _) = Worker.startSystemAndActor(localHostname, "0", "0", coresPerWorker,
6262
memoryPerWorker, masters, null, Some(workerNum), _conf)
6363
workerActorSystems += workerSystem
6464
}

core/src/main/scala/org/apache/spark/deploy/client/TestClient.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ private[spark] object TestClient {
4646
def main(args: Array[String]) {
4747
val url = args(0)
4848
val conf = new SparkConf
49-
val (actorSystem, _) = AkkaUtils.createActorSystem("spark", Utils.localHostName(), 0,
49+
val (actorSystem, _) = AkkaUtils.createActorSystem("spark", Utils.localHostName(), "0",
5050
conf = conf, securityManager = new SecurityManager(conf))
5151
val desc = new ApplicationDescription("TestClient", Some(1), 512,
5252
Command("spark.deploy.client.TestExecutor", Seq(), Map(), Seq(), Seq(), Seq()), "ignored")

core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class HistoryServer(
4444
conf: SparkConf,
4545
provider: ApplicationHistoryProvider,
4646
securityManager: SecurityManager,
47-
port: Int)
47+
port: String)
4848
extends WebUI(securityManager, port, conf) with Logging {
4949

5050
// How many applications to retain
@@ -189,7 +189,7 @@ object HistoryServer extends Logging {
189189
.newInstance(conf)
190190
.asInstanceOf[ApplicationHistoryProvider]
191191

192-
val port = conf.getInt("spark.history.ui.port", 18080)
192+
val port = conf.get("spark.history.ui.port", "18080")
193193

194194
val server = new HistoryServer(conf, provider, securityManager, port)
195195
server.bind()

core/src/main/scala/org/apache/spark/deploy/master/Master.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import org.apache.spark.util.{ActorLogReceive, AkkaUtils, RpcUtils, SignalLogger
5252
private[master] class Master(
5353
host: String,
5454
port: Int,
55-
webUiPort: Int,
55+
webUiPort: String,
5656
val securityMgr: SecurityManager,
5757
val conf: SparkConf)
5858
extends Actor with ActorLogReceive with Logging with LeaderElectable {
@@ -129,7 +129,7 @@ private[master] class Master(
129129
private val restServerEnabled = conf.getBoolean("spark.master.rest.enabled", true)
130130
private val restServer =
131131
if (restServerEnabled) {
132-
val port = conf.getInt("spark.master.rest.port", 6066)
132+
val port = conf.get("spark.master.rest.port", "6066")
133133
Some(new StandaloneRestServer(host, port, self, masterUrl, conf))
134134
} else {
135135
None
@@ -923,8 +923,8 @@ private[deploy] object Master extends Logging {
923923
*/
924924
def startSystemAndActor(
925925
host: String,
926-
port: Int,
927-
webUiPort: Int,
926+
port: String,
927+
webUiPort: String,
928928
conf: SparkConf): (ActorSystem, Int, Int, Option[Int]) = {
929929
val securityMgr = new SecurityManager(conf)
930930
val (actorSystem, boundPort) = AkkaUtils.createActorSystem(systemName, host, port, conf = conf,

core/src/main/scala/org/apache/spark/deploy/master/MasterArguments.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ import org.apache.spark.util.{IntParam, Utils}
2525
*/
2626
private[master] class MasterArguments(args: Array[String], conf: SparkConf) {
2727
var host = Utils.localHostName()
28-
var port = 7077
29-
var webUiPort = 8080
28+
var port = "7077"
29+
var webUiPort = "8080"
3030
var propertiesFile: String = null
3131

3232
// Check for settings in environment variables
3333
if (System.getenv("SPARK_MASTER_HOST") != null) {
3434
host = System.getenv("SPARK_MASTER_HOST")
3535
}
3636
if (System.getenv("SPARK_MASTER_PORT") != null) {
37-
port = System.getenv("SPARK_MASTER_PORT").toInt
37+
port = System.getenv("SPARK_MASTER_PORT")
3838
}
3939
if (System.getenv("SPARK_MASTER_WEBUI_PORT") != null) {
40-
webUiPort = System.getenv("SPARK_MASTER_WEBUI_PORT").toInt
40+
webUiPort = System.getenv("SPARK_MASTER_WEBUI_PORT")
4141
}
4242

4343
parse(args.toList)
@@ -46,7 +46,7 @@ private[master] class MasterArguments(args: Array[String], conf: SparkConf) {
4646
propertiesFile = Utils.loadDefaultSparkProperties(conf, propertiesFile)
4747

4848
if (conf.contains("spark.master.ui.port")) {
49-
webUiPort = conf.get("spark.master.ui.port").toInt
49+
webUiPort = conf.get("spark.master.ui.port")
5050
}
5151

5252
private def parse(args: List[String]): Unit = args match {
@@ -60,11 +60,11 @@ private[master] class MasterArguments(args: Array[String], conf: SparkConf) {
6060
host = value
6161
parse(tail)
6262

63-
case ("--port" | "-p") :: IntParam(value) :: tail =>
63+
case ("--port" | "-p") :: value :: tail =>
6464
port = value
6565
parse(tail)
6666

67-
case "--webui-port" :: IntParam(value) :: tail =>
67+
case "--webui-port" :: value :: tail =>
6868
webUiPort = value
6969
parse(tail)
7070

0 commit comments

Comments
 (0)