diff options
author | Mosharaf Chowdhury <mosharaf@mosharaf-ubuntu.(none)> | 2010-10-28 15:09:58 -0700 |
---|---|---|
committer | Mosharaf Chowdhury <mosharaf@mosharaf-ubuntu.(none)> | 2010-10-28 15:09:58 -0700 |
commit | 03d73dea9f6faa8b3a94500bcfe6fc646b3bd72c (patch) | |
tree | 6e5d51cf25b2ba9dec9a37fc8eca91e0e7d171d2 | |
parent | 681dba1373c9cf6ab2cc7ff9d6f467b49238ff0d (diff) | |
download | spark-03d73dea9f6faa8b3a94500bcfe6fc646b3bd72c.tar.gz spark-03d73dea9f6faa8b3a94500bcfe6fc646b3bd72c.tar.bz2 spark-03d73dea9f6faa8b3a94500bcfe6fc646b3bd72c.zip |
Refactoring...
-rw-r--r-- | src/scala/spark/Broadcast.scala | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/scala/spark/Broadcast.scala b/src/scala/spark/Broadcast.scala index 78aa1601fc..64027d4ece 100644 --- a/src/scala/spark/Broadcast.scala +++ b/src/scala/spark/Broadcast.scala @@ -286,8 +286,19 @@ extends BroadcastRecipe with Logging { } listOfSources = listOfSources + newSourceInfo } - } + } + private def addToListOfSources (newSourceInfos: ListBuffer[SourceInfo]) = { + listOfSources.synchronized { + newSourceInfos.foreach { srcInfo => + if (listOfSources.contains(srcInfo)) { + listOfSources = listOfSources - srcInfo + } + listOfSources = listOfSources + srcInfo + } + } + } + class TalkToGuide (gInfo: SourceInfo) extends Thread with Logging { override def run = { @@ -308,21 +319,10 @@ extends BroadcastRecipe with Logging { // Receive source information from Guide var suitableSources = - oisGuide.readObject.asInstanceOf[ListBuffer[SourceInfo]] - + oisGuide.readObject.asInstanceOf[ListBuffer[SourceInfo]] logInfo("Received suitableSources from Master " + suitableSources) - // Update local list of known sources by adding or replacing - listOfSources.synchronized { - suitableSources.foreach { srcInfo => - // Removing old copy of srcInfo to be replaced with a new one - // It works because case clases are compared by constructor params - if (listOfSources.contains(srcInfo)) { - listOfSources = listOfSources - srcInfo - } - listOfSources = listOfSources + srcInfo - } - } + addToListOfSources (suitableSources) oisGuide.close oosGuide.close |