Skip to content

Commit

Permalink
SPARK-5370. [YARN] Remove some unnecessary synchronization in YarnAll…
Browse files Browse the repository at this point in the history
…oca...

...tor

Author: Sandy Ryza <sandy@cloudera.com>

Closes #4164 from sryza/sandy-spark-5370 and squashes the following commits:

0c8d736 [Sandy Ryza] SPARK-5370. [YARN] Remove some unnecessary synchronization in YarnAllocator
  • Loading branch information
sryza authored and tgravescs committed Jan 22, 2015
1 parent 246111d commit 820ce03
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ private[yarn] class YarnAllocator(

import YarnAllocator._

// These two complementary data structures are locked on allocatedHostToContainersMap.
// Visible for testing.
val allocatedHostToContainersMap =
new HashMap[String, collection.mutable.Set[ContainerId]]
Expand Down Expand Up @@ -355,20 +354,18 @@ private[yarn] class YarnAllocator(
}
}

allocatedHostToContainersMap.synchronized {
if (allocatedContainerToHostMap.containsKey(containerId)) {
val host = allocatedContainerToHostMap.get(containerId).get
val containerSet = allocatedHostToContainersMap.get(host).get
if (allocatedContainerToHostMap.containsKey(containerId)) {
val host = allocatedContainerToHostMap.get(containerId).get
val containerSet = allocatedHostToContainersMap.get(host).get

containerSet.remove(containerId)
if (containerSet.isEmpty) {
allocatedHostToContainersMap.remove(host)
} else {
allocatedHostToContainersMap.update(host, containerSet)
}

allocatedContainerToHostMap.remove(containerId)
containerSet.remove(containerId)
if (containerSet.isEmpty) {
allocatedHostToContainersMap.remove(host)
} else {
allocatedHostToContainersMap.update(host, containerSet)
}

allocatedContainerToHostMap.remove(containerId)
}
}
}
Expand Down

0 comments on commit 820ce03

Please sign in to comment.