Github user vanzin commented on a diff in the pull request:
https://github.com/apache/spark/pull/2379#discussion_r17743439
--- Diff:
core/src/main/scala/org/apache/spark/deploy/worker/WorkerArguments.scala ---
@@ -47,14 +48,25 @@ private[spark] class WorkerArguments(args:
Array[String], conf: SparkConf) {
if (System.getenv("SPARK_WORKER_WEBUI_PORT") != null) {
webUiPort = System.getenv("SPARK_WORKER_WEBUI_PORT").toInt
}
- if (conf.contains("spark.worker.ui.port")) {
- webUiPort = conf.get("spark.worker.ui.port").toInt
- }
if (System.getenv("SPARK_WORKER_DIR") != null) {
workDir = System.getenv("SPARK_WORKER_DIR")
}
parse(args.toList)
+ propertiesFile =
Option(propertiesFile).getOrElse(Utils.getDefaultConfigFile)
+
+ Option(propertiesFile).foreach { file =>
+ Utils.getPropertiesFromFile(file).filter { case (k, v) =>
+ k.startsWith("spark.")
+ }.foreach { case (k, v) =>
+ conf.setIfMissing(k, v)
+ sys.props.getOrElseUpdate(k, v)
+ }
+ }
--- End diff --
This whole block (from L56) is repeated three times in your patch. Could
you add a helper method for this instead?
You could have something like:
def loadPropertiesFile(file: Option[String], conf: SparkConf):
Map[String, String] = {
val path = file.getOrElse(getDefaultConfigFile()))
getPropertiesFromFile(file)
.filter { case (k, v) =>
k.startsWith("spark.")
}
.foreach { case (k, v) =>
conf.setIfMissing(k, v)
sys.props.getOrElseUpdate(k, v)
}
}
And this whole block becomes a single method call. If you're creative you
could even come up with an API that could be used by the SparkSubmit code too.
---
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]