Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/9287#discussion_r44054114
--- Diff:
core/src/main/scala/org/apache/spark/deploy/master/MasterArguments.scala ---
@@ -24,30 +24,35 @@ import org.apache.spark.util.{IntParam, Utils}
* Command-line parser for the master.
*/
private[master] class MasterArguments(args: Array[String], conf:
SparkConf) {
+ import Master._
+
var host = Utils.localHostName()
- var port = 7077
- var webUiPort = 8080
+ var port = DefaultRpcPort
+ var webUiPort = DefaultWebUIPort
+ var rpcSubmissionPort = DefaultRpcSubmissionPort
+ var restSubmissionPort = DefaultRestSubmissionPort
var propertiesFile: String = null
// Check for settings in environment variables
- if (System.getenv("SPARK_MASTER_HOST") != null) {
- host = System.getenv("SPARK_MASTER_HOST")
- }
- if (System.getenv("SPARK_MASTER_PORT") != null) {
- port = System.getenv("SPARK_MASTER_PORT").toInt
- }
- if (System.getenv("SPARK_MASTER_WEBUI_PORT") != null) {
- webUiPort = System.getenv("SPARK_MASTER_WEBUI_PORT").toInt
- }
+ sys.env.get("SPARK_MASTER_HOST").foreach(v => host = v)
+ sys.env.get("SPARK_MASTER_PORT").foreach(v => port = v.toInt)
+ sys.env.get("SPARK_MASTER_WEBUI_PORT").foreach(v => webUiPort = v.toInt)
+
+
sys.env.get("SPARK_MASTER_SUBMISSION_RPC_PORT").orElse(sys.env.get("SPARK_MASTER_PORT"))
+ .foreach(v => rpcSubmissionPort = v.toInt)
+
sys.env.get("SPARK_MASTER_SUBMISSION_REST_PORT").orElse(sys.env.get("SPARK_MASTER_REST_PORT"))
+ .foreach(v => restSubmissionPort = v.toInt)
parse(args.toList)
// This mutates the SparkConf, so all accesses to it must be made after
this line
propertiesFile = Utils.loadDefaultSparkProperties(conf, propertiesFile)
- if (conf.contains("spark.master.ui.port")) {
- webUiPort = conf.get("spark.master.ui.port").toInt
- }
+ conf.getOption("spark.master.host").foreach(v => host = v)
+ conf.getOption("spark.master.ui.port").foreach(v => webUiPort = v.toInt)
+ conf.getOption("spark.master.rpc.port").foreach(v => port = v.toInt)
+ conf.getOption("spark.master.submission.rest.port").foreach(v =>
restSubmissionPort = v.toInt)
+ conf.getOption("spark.master.submission.rpc.port").foreach(v =>
rpcSubmissionPort = v.toInt)
--- End diff --
It's really confusing to have conf split like this. You should merge the
two pieces of code setting `rpcSubmissionPort` into one statement.
I'd also recommend declaring `vals` and using `getOrElse` instead of
`foreach`.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]