From 3497e76e1956fc742e95753f79138e8e096795d5 Mon Sep 17 00:00:00 2001 From: Jason Darrell Lowe Date: Fri, 24 Jan 2014 18:54:48 +0000 Subject: [PATCH] YARN-1575. Public localizer crashes with "Localized unkown resource". Contributed by Jason Lowe git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1561110 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../localizer/ResourceLocalizationService.java | 12 ++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 828f1f8a33b..f2491aec07b 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -366,6 +366,9 @@ Release 2.4.0 - UNRELEASED YARN-1607. TestRM relies on the scheduler assigning multiple containers in a single node update (Sandy Ryza) + YARN-1575. Public localizer crashes with "Localized unkown resource" + (jlowe) + Release 2.3.0 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/ResourceLocalizationService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/ResourceLocalizationService.java index 4cbc37d5053..97c68aae9e0 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/ResourceLocalizationService.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/ResourceLocalizationService.java @@ -638,8 +638,8 @@ public class ResourceLocalizationService extends CompositeService super("Public Localizer"); this.lfs = getLocalFileContext(conf); this.conf = conf; - this.pending = - new ConcurrentHashMap, LocalizerResourceRequestEvent>(); + this.pending = Collections.synchronizedMap( + new HashMap, LocalizerResourceRequestEvent>()); this.threadPool = createLocalizerExecutor(conf); this.queue = new ExecutorCompletionService(threadPool); } @@ -675,8 +675,12 @@ public class ResourceLocalizationService extends CompositeService publicDirDestPath = new Path(publicDirDestPath, Long.toString(publicRsrc .nextUniqueNumber())); - pending.put(queue.submit(new FSDownload(lfs, null, conf, - publicDirDestPath, resource)), request); + // explicitly synchronize pending here to avoid future task + // completing and being dequeued before pending updated + synchronized (pending) { + pending.put(queue.submit(new FSDownload(lfs, null, conf, + publicDirDestPath, resource)), request); + } } catch (IOException e) { rsrc.unlock(); // TODO Need to Fix IO Exceptions - Notifying resource