diff options
author | Sean Owen <sowen@cloudera.com> | 2016-08-09 09:38:12 +0100 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-08-09 09:38:12 +0100 |
commit | 801e4d097f45b269a9c6b25723d925f3e24ba498 (patch) | |
tree | 52129df2031ef9ff4a1e2197c9c487e36ff4d976 /core/src/main | |
parent | bb2b9d0a428b86bf366ee9916e26402f8c00912f (diff) | |
download | spark-801e4d097f45b269a9c6b25723d925f3e24ba498.tar.gz spark-801e4d097f45b269a9c6b25723d925f3e24ba498.tar.bz2 spark-801e4d097f45b269a9c6b25723d925f3e24ba498.zip |
[SPARK-16606][CORE] Misleading warning for SparkContext.getOrCreate "WARN SparkContext: Use an existing SparkContext, some configuration may not take effect."
## What changes were proposed in this pull request?
SparkContext.getOrCreate shouldn't warn about ignored config if
- it wasn't ignored because a new context is created with it or
- no config was actually provided
## How was this patch tested?
Jenkins + existing tests.
Author: Sean Owen <sowen@cloudera.com>
Closes #14533 from srowen/SPARK-16606.
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/scala/org/apache/spark/SparkContext.scala | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala index fc7ea51ab0..4f3bb1c877 100644 --- a/core/src/main/scala/org/apache/spark/SparkContext.scala +++ b/core/src/main/scala/org/apache/spark/SparkContext.scala @@ -2262,9 +2262,10 @@ object SparkContext extends Logging { SPARK_CONTEXT_CONSTRUCTOR_LOCK.synchronized { if (activeContext.get() == null) { setActiveContext(new SparkContext(config), allowMultipleContexts = false) - } - if (config.getAll.nonEmpty) { - logWarning("Use an existing SparkContext, some configuration may not take effect.") + } else { + if (config.getAll.nonEmpty) { + logWarning("Using an existing SparkContext; some configuration may not take effect.") + } } activeContext.get() } @@ -2281,7 +2282,12 @@ object SparkContext extends Logging { * even if multiple contexts are allowed. */ def getOrCreate(): SparkContext = { - getOrCreate(new SparkConf()) + SPARK_CONTEXT_CONSTRUCTOR_LOCK.synchronized { + if (activeContext.get() == null) { + setActiveContext(new SparkContext(), allowMultipleContexts = false) + } + activeContext.get() + } } /** |