Repository: hadoop
Updated Branches:
  refs/heads/branch-3.0 5db733fb0 -> 7c224656c


YARN-7511. NPE in ContainerLocalizer when localization failed for running 
container. Contributed by Tao Yang

(cherry picked from commit 83798f15f8602ef580a7885876de114b2425da89)


Project: http://git-wip-us.apache.org/repos/asf/hadoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/hadoop/commit/7c224656
Tree: http://git-wip-us.apache.org/repos/asf/hadoop/tree/7c224656
Diff: http://git-wip-us.apache.org/repos/asf/hadoop/diff/7c224656

Branch: refs/heads/branch-3.0
Commit: 7c224656ce1d448f67503528bde5d92708f816a6
Parents: 5db733f
Author: Jason Lowe <jl...@apache.org>
Authored: Fri Mar 2 09:59:46 2018 -0600
Committer: Jason Lowe <jl...@apache.org>
Committed: Fri Mar 2 10:03:51 2018 -0600

----------------------------------------------------------------------
 .../containermanager/localizer/ResourceSet.java |  4 +++
 .../container/TestContainer.java                | 26 ++++++++++++++++++++
 2 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/7c224656/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/localizer/ResourceSet.java
----------------------------------------------------------------------
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/ResourceSet.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/ResourceSet.java
index 6df1073..745f8a8 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/ResourceSet.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/ResourceSet.java
@@ -136,6 +136,10 @@ public class ResourceSet {
   }
 
   public void resourceLocalizationFailed(LocalResourceRequest request) {
+    // Skip null request when localization failed for running container
+    if (request == null) {
+      return;
+    }
     pendingResources.remove(request);
     resourcesFailedToBeLocalized.add(request);
   }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/7c224656/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java
----------------------------------------------------------------------
diff --git 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java
 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java
index 64e6cf0..3b34a87 100644
--- 
a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java
+++ 
b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/test/java/org/apache/hadoop/yarn/server/nodemanager/containermanager/container/TestContainer.java
@@ -379,6 +379,27 @@ public class TestContainer {
   }
   
   @Test
+  @SuppressWarnings("unchecked")
+  public void testLocalizationFailureWhileRunning()
+      throws Exception {
+    WrappedContainer wc = null;
+    try {
+      wc = new WrappedContainer(6, 314159265358979L, 4344, "yak");
+      wc.initContainer();
+      wc.localizeResources();
+      wc.launchContainer();
+      reset(wc.localizerBus);
+      assertEquals(ContainerState.RUNNING, wc.c.getContainerState());
+      // Now in RUNNING, handle ContainerResourceFailedEvent, cause NPE before
+      wc.handleContainerResourceFailedEvent();
+    } finally {
+      if (wc != null) {
+        wc.finished();
+      }
+    }
+  }
+
+  @Test
   @SuppressWarnings("unchecked") // mocked generic
   public void testCleanupOnKillRequest() throws Exception {
     WrappedContainer wc = null;
@@ -1132,6 +1153,11 @@ public class TestContainer {
       drainDispatcherEvents();
     }
 
+    public void handleContainerResourceFailedEvent() {
+      c.handle(new ContainerResourceFailedEvent(cId, null, null));
+      drainDispatcherEvents();
+    }
+
     // Localize resources 
     // Skip some resources so as to consider them failed
     public Map<Path, List<String>> doLocalizeResources(


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscr...@hadoop.apache.org
For additional commands, e-mail: common-commits-h...@hadoop.apache.org

Reply via email to