Explorar o código

YARN-3457. NPE when NodeManager.serviceInit fails and stopRecoveryStore called. Contributed by Bibin A Chundatt.

(cherry picked from commit ac32fa187cf37e5a51fd579e052105662ab3c411)

Conflicts:

	hadoop-yarn-project/CHANGES.txt
Jason Lowe %!s(int64=10) %!d(string=hai) anos
pai
achega
bfd28d6f7e

+ 3 - 0
hadoop-yarn-project/CHANGES.txt

@@ -86,6 +86,9 @@ Release 2.7.1 - UNRELEASED
     YARN-3626. On Windows localized resources are not moved to the front
     YARN-3626. On Windows localized resources are not moved to the front
     of the classpath when they should be. (Craig Welch via xgong)
     of the classpath when they should be. (Craig Welch via xgong)
 
 
+    YARN-3457. NPE when NodeManager.serviceInit fails and stopRecoveryStore called.
+    (Bibin A Chundatt via ozawa)
+
 Release 2.7.0 - 2015-04-20
 Release 2.7.0 - 2015-04-20
 
 
   INCOMPATIBLE CHANGES
   INCOMPATIBLE CHANGES

+ 12 - 10
hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java

@@ -159,16 +159,18 @@ public class NodeManager extends CompositeService
 
 
   private void stopRecoveryStore() throws IOException {
   private void stopRecoveryStore() throws IOException {
     nmStore.stop();
     nmStore.stop();
-    if (context.getDecommissioned() && nmStore.canRecover()) {
-      LOG.info("Removing state store due to decommission");
-      Configuration conf = getConfig();
-      Path recoveryRoot = new Path(
-          conf.get(YarnConfiguration.NM_RECOVERY_DIR));
-      LOG.info("Removing state store at " + recoveryRoot
-          + " due to decommission");
-      FileSystem recoveryFs = FileSystem.getLocal(conf);
-      if (!recoveryFs.delete(recoveryRoot, true)) {
-        LOG.warn("Unable to delete " + recoveryRoot);
+    if (null != context) {
+      if (context.getDecommissioned() && nmStore.canRecover()) {
+        LOG.info("Removing state store due to decommission");
+        Configuration conf = getConfig();
+        Path recoveryRoot =
+            new Path(conf.get(YarnConfiguration.NM_RECOVERY_DIR));
+        LOG.info("Removing state store at " + recoveryRoot
+            + " due to decommission");
+        FileSystem recoveryFs = FileSystem.getLocal(conf);
+        if (!recoveryFs.delete(recoveryRoot, true)) {
+          LOG.warn("Unable to delete " + recoveryRoot);
+        }
       }
       }
     }
     }
   }
   }