Repository: spark
Updated Branches:
  refs/heads/master 373a376c0 -> e0dd1309a


[SPARK-10119] [CORE] Fix isDynamicAllocationEnabled when config is expliticly 
disabled.

Author: Marcelo Vanzin <[email protected]>

Closes #8316 from vanzin/SPARK-10119.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/e0dd1309
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/e0dd1309
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/e0dd1309

Branch: refs/heads/master
Commit: e0dd1309ac248375f429639801923570f14de18d
Parents: 373a376
Author: Marcelo Vanzin <[email protected]>
Authored: Wed Aug 19 14:33:32 2015 -0700
Committer: Marcelo Vanzin <[email protected]>
Committed: Wed Aug 19 14:33:32 2015 -0700

----------------------------------------------------------------------
 core/src/main/scala/org/apache/spark/util/Utils.scala |  2 +-
 .../test/scala/org/apache/spark/util/UtilsSuite.scala | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/e0dd1309/core/src/main/scala/org/apache/spark/util/Utils.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala 
b/core/src/main/scala/org/apache/spark/util/Utils.scala
index fddc24d..8313312 100644
--- a/core/src/main/scala/org/apache/spark/util/Utils.scala
+++ b/core/src/main/scala/org/apache/spark/util/Utils.scala
@@ -2141,7 +2141,7 @@ private[spark] object Utils extends Logging {
    * the latter should override the former (SPARK-9092).
    */
   def isDynamicAllocationEnabled(conf: SparkConf): Boolean = {
-    conf.contains("spark.dynamicAllocation.enabled") &&
+    conf.getBoolean("spark.dynamicAllocation.enabled", false) &&
       conf.getInt("spark.executor.instances", 0) == 0
   }
 

http://git-wip-us.apache.org/repos/asf/spark/blob/e0dd1309/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala 
b/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala
index 8f7e402..1fb81ad 100644
--- a/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala
+++ b/core/src/test/scala/org/apache/spark/util/UtilsSuite.scala
@@ -720,4 +720,18 @@ class UtilsSuite extends SparkFunSuite with 
ResetSystemProperties with Logging {
     assert(Utils.nanSafeCompareFloats(Float.PositiveInfinity, Float.NaN) === 
-1)
     assert(Utils.nanSafeCompareFloats(Float.NegativeInfinity, Float.NaN) === 
-1)
   }
+
+  test("isDynamicAllocationEnabled") {
+    val conf = new SparkConf()
+    assert(Utils.isDynamicAllocationEnabled(conf) === false)
+    assert(Utils.isDynamicAllocationEnabled(
+      conf.set("spark.dynamicAllocation.enabled", "false")) === false)
+    assert(Utils.isDynamicAllocationEnabled(
+      conf.set("spark.dynamicAllocation.enabled", "true")) === true)
+    assert(Utils.isDynamicAllocationEnabled(
+      conf.set("spark.executor.instances", "1")) === false)
+    assert(Utils.isDynamicAllocationEnabled(
+      conf.set("spark.executor.instances", "0")) === true)
+  }
+
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to