From 7110499817300cb9fcfec5376ce8575028a3b6db Mon Sep 17 00:00:00 2001 From: Jason Lowe Date: Fri, 24 Apr 2015 22:02:53 +0000 Subject: [PATCH] YARN-3537. NPE when NodeManager.serviceInit fails and stopRecoveryStore invoked. Contributed by Brahma Reddy Battula (cherry picked from commit 5e093f0d400f82f67d9b2d24253c79e4a5abacf9) --- hadoop-yarn-project/CHANGES.txt | 3 +++ .../yarn/server/nodemanager/NodeManager.java | 26 ++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/hadoop-yarn-project/CHANGES.txt b/hadoop-yarn-project/CHANGES.txt index 8f2a85e2e6a..7c81cca0a05 100644 --- a/hadoop-yarn-project/CHANGES.txt +++ b/hadoop-yarn-project/CHANGES.txt @@ -89,6 +89,9 @@ Release 2.7.1 - UNRELEASED YARN-3457. NPE when NodeManager.serviceInit fails and stopRecoveryStore called. (Bibin A Chundatt via ozawa) + YARN-3537. NPE when NodeManager.serviceInit fails and stopRecoveryStore + invoked (Brahma Reddy Battula via jlowe) + Release 2.7.0 - 2015-04-20 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/NodeManager.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java index 2abf62b3dff..950031ff68f 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-server/hadoop-yarn-server-nodemanager/src/main/java/org/apache/hadoop/yarn/server/nodemanager/NodeManager.java @@ -158,18 +158,20 @@ public class NodeManager extends CompositeService } private void stopRecoveryStore() throws IOException { - nmStore.stop(); - 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); + if (null != nmStore) { + nmStore.stop(); + 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); + } } } }