diff options
author | Sandy Ryza <sandy@cloudera.com> | 2015-01-22 13:49:35 -0600 |
---|---|---|
committer | Thomas Graves <tgraves@apache.org> | 2015-01-22 13:49:35 -0600 |
commit | 820ce03597350257abe0c5c96435c555038e3e6c (patch) | |
tree | 11aa16014fec9c7869ed0e0e49e7b15ae19783ca /yarn/src | |
parent | 246111d179a2f3f6b97a5c2b121d8ddbfd1c9aad (diff) | |
download | spark-820ce03597350257abe0c5c96435c555038e3e6c.tar.gz spark-820ce03597350257abe0c5c96435c555038e3e6c.tar.bz2 spark-820ce03597350257abe0c5c96435c555038e3e6c.zip |
SPARK-5370. [YARN] Remove some unnecessary synchronization in YarnAlloca...
...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
Diffstat (limited to 'yarn/src')
-rw-r--r-- | yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala b/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala index 4c35b60c57..d00f29665a 100644 --- a/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala +++ b/yarn/src/main/scala/org/apache/spark/deploy/yarn/YarnAllocator.scala @@ -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]] @@ -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) } } } |