From 6f622672b62aa8d719060063ef0e47480cdc8655 Mon Sep 17 00:00:00 2001 From: Kihwal Lee Date: Fri, 8 May 2015 09:30:38 -0500 Subject: [PATCH] HDFS-7894. Rolling upgrade readiness is not updated in jmx until query command is issued. Contributed by Brahma Reddy Battula. --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/server/namenode/FSNamesystem.java | 23 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 60825a2be8..a83b8a79e9 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -765,6 +765,9 @@ Release 2.7.1 - UNRELEASED HDFS-8226. Non-HA rollback compatibility broken (J.Andreina via vinayakumarb) + HDFS-7894. Rolling upgrade readiness is not updated in jmx until query + command is issued. (Brahma Reddy Battula via kihwal) + Release 2.7.0 - 2015-04-20 INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java index 120812bc96..60495af9da 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java @@ -7608,11 +7608,30 @@ public void setNeedRollbackFsImage(boolean needRollbackFsImage) { @Override // NameNodeMXBean public RollingUpgradeInfo.Bean getRollingUpgradeStatus() { + if (!isRollingUpgrade()) { + return null; + } RollingUpgradeInfo upgradeInfo = getRollingUpgradeInfo(); - if (upgradeInfo != null) { + if (upgradeInfo.createdRollbackImages()) { return new RollingUpgradeInfo.Bean(upgradeInfo); } - return null; + readLock(); + try { + // check again after acquiring the read lock. + upgradeInfo = getRollingUpgradeInfo(); + if (upgradeInfo == null) { + return null; + } + if (!upgradeInfo.createdRollbackImages()) { + boolean hasRollbackImage = this.getFSImage().hasRollbackFSImage(); + upgradeInfo.setCreatedRollbackImages(hasRollbackImage); + } + } catch (IOException ioe) { + LOG.warn("Encountered exception setting Rollback Image", ioe); + } finally { + readUnlock(); + } + return new RollingUpgradeInfo.Bean(upgradeInfo); } /** Is rolling upgrade in progress? */