Github user andrewor14 commented on a diff in the pull request:
https://github.com/apache/spark/pull/1256#discussion_r17457393
--- Diff: core/src/main/scala/org/apache/spark/SparkConf.scala ---
@@ -307,6 +317,27 @@ class SparkConf(loadDefaults: Boolean) extends
Cloneable with Logging {
def toDebugString: String = {
settings.toArray.sorted.map{case (k, v) => k + "=" + v}.mkString("\n")
}
+
+ /** Load properties from file. */
+ private[spark] def loadPropertiesFromFile(fileName: String, isOverride:
Boolean = false) {
+ val file = new File(fileName)
+ if (file.isFile()) {
+ loadProperties(Utils.getPropertiesFromFile(file.getAbsolutePath),
isOverride)
+ }
+ }
+
+ /** Load any spark.* system properties */
+ private[spark] def loadSystemProperties() {
+ loadProperties(sys.props.toSeq, true)
+ }
+
+ private def loadProperties(seq: Seq[(String, String)], isOverride:
Boolean) {
+ for ((k, v) <- seq if k.startsWith("spark.")) {
+ if (isOverride || settings.get(k).isEmpty) {
+ settings(k) = v
+ }
+ }
+ }
--- End diff --
Hm, I actually don't think any of this logic should exist in `SparkConf`.
The current model is that by the time we get here all the properties from the
file are already loaded into `sys.props` so we can just load those. This is a
nice abstraction because `SparkConf` doesn't have to be concerned with where
the properties file is.
---
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]