File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed
core/src/main/scala/org/apache/spark
examples/src/main/scala/org/apache/spark/examples Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ import scala.collection.JavaConverters._
23
23
import scala .collection .mutable .LinkedHashSet
24
24
25
25
import org .apache .spark .serializer .KryoSerializer
26
+ import org .apache .spark .util .Utils
26
27
27
28
/**
28
29
* Configuration for a Spark application. Used to set various Spark parameters as key-value pairs.
@@ -53,9 +54,8 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
53
54
54
55
if (loadDefaults) {
55
56
// Load any spark.* system properties
56
- val propNames = System .getProperties.stringPropertyNames().asScala
57
- for (k <- propNames if k.startsWith(" spark." )) {
58
- set(k, System .getProperty(k))
57
+ for ((key, value) <- Utils .getSystemProperties if key.startsWith(" spark." )) {
58
+ set(key, value)
59
59
}
60
60
}
61
61
Original file line number Diff line number Diff line change @@ -1312,9 +1312,14 @@ private[spark] object Utils extends Logging {
1312
1312
hashAbs
1313
1313
}
1314
1314
1315
- /** Returns a copy of the system properties that is thread-safe to iterator over. */
1316
- def getSystemProperties (): Map [String , String ] = {
1317
- System .getProperties.clone().asInstanceOf [java.util.Properties ].toMap[String , String ]
1315
+ /** Returns the system properties map that is thread-safe to iterator over. It gets the
1316
+ * properties which have been set explicitly, as well as those for which only a default value
1317
+ * has been defined. */
1318
+ def getSystemProperties : Map [String , String ] = {
1319
+ val sysProps = for (key <- System .getProperties.stringPropertyNames()) yield
1320
+ (key, System .getProperty(key))
1321
+
1322
+ sysProps.toMap
1318
1323
}
1319
1324
1320
1325
/**
Original file line number Diff line number Diff line change @@ -19,6 +19,8 @@ package org.apache.spark.examples
19
19
20
20
import scala .collection .JavaConversions ._
21
21
22
+ import org .apache .spark .util .Utils
23
+
22
24
/** Prints out environmental information, sleeps, and then exits. Made to
23
25
* test driver submission in the standalone scheduler. */
24
26
object DriverSubmissionTest {
@@ -30,7 +32,7 @@ object DriverSubmissionTest {
30
32
val numSecondsToSleep = args(0 ).toInt
31
33
32
34
val env = System .getenv()
33
- val properties = System .getProperties()
35
+ val properties = Utils .getSystemProperties
34
36
35
37
println(" Environment variables containing SPARK_TEST:" )
36
38
env.filter{case (k, v) => k.contains(" SPARK_TEST" )}.foreach(println)
You can’t perform that action at this time.
0 commit comments