diff options
author | Davies Liu <davies@databricks.com> | 2015-01-21 16:51:42 -0800 |
---|---|---|
committer | Josh Rosen <joshrosen@databricks.com> | 2015-01-21 16:52:46 -0800 |
commit | dd184290fde6101fdafa0aeae790661ccfca9db4 (patch) | |
tree | cc6759e3a39ae408c9c0b32ed7a2a30143ffed84 /core/src/main | |
parent | 079b3be81264b446f927739f26ed9f426611d83f (diff) | |
download | spark-dd184290fde6101fdafa0aeae790661ccfca9db4.tar.gz spark-dd184290fde6101fdafa0aeae790661ccfca9db4.tar.bz2 spark-dd184290fde6101fdafa0aeae790661ccfca9db4.zip |
[SPARK-5355] make SparkConf thread-safe
The SparkConf is not thread-safe, but is accessed by many threads. The getAll() could return parts of the configs if another thread is access it.
This PR changes SparkConf.settings to a thread-safe TrieMap.
Author: Davies Liu <davies@databricks.com>
Closes #4143 from davies/safe-conf and squashes the following commits:
f8fa1cf [Davies Liu] change to TrieMap
a1d769a [Davies Liu] make SparkConf thread-safe
(cherry picked from commit 9bad062268676aaa66dcbddd1e0ab7f2d7742425)
Signed-off-by: Josh Rosen <joshrosen@databricks.com>
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/scala/org/apache/spark/SparkConf.scala | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/core/src/main/scala/org/apache/spark/SparkConf.scala b/core/src/main/scala/org/apache/spark/SparkConf.scala index dae170f942..dd80013757 100644 --- a/core/src/main/scala/org/apache/spark/SparkConf.scala +++ b/core/src/main/scala/org/apache/spark/SparkConf.scala @@ -18,6 +18,7 @@ package org.apache.spark import scala.collection.JavaConverters._ +import scala.collection.concurrent.TrieMap import scala.collection.mutable.{HashMap, LinkedHashSet} import org.apache.spark.serializer.KryoSerializer @@ -46,7 +47,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging { /** Create a SparkConf that loads defaults from system properties and the classpath */ def this() = this(true) - private[spark] val settings = new HashMap[String, String]() + private[spark] val settings = new TrieMap[String, String]() if (loadDefaults) { // Load any spark.* system properties @@ -177,7 +178,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging { } /** Get all parameters as a list of pairs */ - def getAll: Array[(String, String)] = settings.clone().toArray + def getAll: Array[(String, String)] = settings.toArray /** Get a parameter as an integer, falling back to a default if not set */ def getInt(key: String, defaultValue: Int): Int = { |