You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by ma...@apache.org on 2013/10/04 19:55:23 UTC

[36/50] git commit: Add barrier for local properties unit test and fix some styles

Add barrier for local properties unit test and fix some styles


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

Branch: refs/heads/scala-2.10
Commit: aa0c29f74779bc5af70250c7481dbd7052ee39cf
Parents: ffa5f8e
Author: jerryshao <sa...@intel.com>
Authored: Sun Sep 22 09:40:40 2013 +0800
Committer: jerryshao <sa...@intel.com>
Committed: Sun Sep 22 09:53:11 2013 +0800

----------------------------------------------------------------------
 core/src/main/scala/org/apache/spark/SparkContext.scala  |  3 ++-
 .../src/test/scala/org/apache/spark/ThreadingSuite.scala | 11 +++++++++--
 2 files changed, 11 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/aa0c29f7/core/src/main/scala/org/apache/spark/SparkContext.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/spark/SparkContext.scala b/core/src/main/scala/org/apache/spark/SparkContext.scala
index 3922e9a..6bab1f3 100644
--- a/core/src/main/scala/org/apache/spark/SparkContext.scala
+++ b/core/src/main/scala/org/apache/spark/SparkContext.scala
@@ -275,7 +275,8 @@ class SparkContext(
     }
   }
 
-  def getLocalProperty(key: String): String = Option(localProperties.get).map(_.getProperty(key)).getOrElse(null)
+  def getLocalProperty(key: String): String =
+    Option(localProperties.get).map(_.getProperty(key)).getOrElse(null)
 
   /** Set a human readable description of the current job. */
   def setJobDescription(value: String) {

http://git-wip-us.apache.org/repos/asf/incubator-spark/blob/aa0c29f7/core/src/test/scala/org/apache/spark/ThreadingSuite.scala
----------------------------------------------------------------------
diff --git a/core/src/test/scala/org/apache/spark/ThreadingSuite.scala b/core/src/test/scala/org/apache/spark/ThreadingSuite.scala
index 331f79d..75d6493 100644
--- a/core/src/test/scala/org/apache/spark/ThreadingSuite.scala
+++ b/core/src/test/scala/org/apache/spark/ThreadingSuite.scala
@@ -152,36 +152,43 @@ class ThreadingSuite extends FunSuite with LocalSparkContext {
 
   test("set local properties in different thread") {
     sc = new SparkContext("local", "test")
+    val sem = new Semaphore(0)
 
-    val threads = (1 to 5).map{ i =>
+    val threads = (1 to 5).map { i =>
       new Thread() {
         override def run() {
           sc.setLocalProperty("test", i.toString)
           assert(sc.getLocalProperty("test") === i.toString)
+          sem.release()
         }
       }
     }
 
     threads.foreach(_.start())
 
+    sem.acquire(5)
     assert(sc.getLocalProperty("test") === null)
   }
 
   test("set and get local properties in parent-children thread") {
     sc = new SparkContext("local", "test")
     sc.setLocalProperty("test", "parent")
+    val sem = new Semaphore(0)
 
-    val threads = (1 to 5).map{ i =>
+    val threads = (1 to 5).map { i =>
       new Thread() {
         override def run() {
           assert(sc.getLocalProperty("test") === "parent")
           sc.setLocalProperty("test", i.toString)
           assert(sc.getLocalProperty("test") === i.toString)
+          sem.release()
         }
       }
     }
 
     threads.foreach(_.start())
+
+    sem.acquire(5)
     assert(sc.getLocalProperty("test") === "parent")
     assert(sc.getLocalProperty("Foo") === null)
   }