You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ji...@apache.org on 2014/11/04 19:16:47 UTC

git commit: HDFS-7340. Make rollingUpgrade start/finalize idempotent. Contributed by Jing Zhao.

Repository: hadoop
Updated Branches:
  refs/heads/trunk 2bb327eb9 -> 3dfd6e68f


HDFS-7340. Make rollingUpgrade start/finalize idempotent. Contributed by Jing Zhao.


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

Branch: refs/heads/trunk
Commit: 3dfd6e68fe5028fe3766ae5056dc175c38cc97e1
Parents: 2bb327e
Author: Jing Zhao <ji...@apache.org>
Authored: Tue Nov 4 10:16:37 2014 -0800
Committer: Jing Zhao <ji...@apache.org>
Committed: Tue Nov 4 10:16:37 2014 -0800

----------------------------------------------------------------------
 hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt          |  2 ++
 .../hadoop/hdfs/server/namenode/FSNamesystem.java    | 15 ++++++++-------
 .../hdfs/server/namenode/NameNodeRpcServer.java      |  3 ++-
 .../java/org/apache/hadoop/hdfs/tools/DFSAdmin.java  |  5 +++--
 .../org/apache/hadoop/hdfs/TestRollingUpgrade.java   |  8 ++++----
 5 files changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hadoop/blob/3dfd6e68/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
index be7b9bf..4bc833f 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
+++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
@@ -996,6 +996,8 @@ Release 2.6.0 - UNRELEASED
     HDFS-7147. Update archival storage user documentation.
     (Tsz Wo Nicholas Sze via wheat9)
 
+    HDFS-7340. Make rollingUpgrade start/finalize idempotent. (jing9)
+
     BREAKDOWN OF HDFS-6134 AND HADOOP-10150 SUBTASKS AND RELATED JIRAS
   
       HDFS-6387. HDFS CLI admin tool for creating & deleting an

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3dfd6e68/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/FSNamesystem.java
----------------------------------------------------------------------
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 93ff63e..2bc4ba0 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
@@ -8293,6 +8293,9 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
     writeLock();
     try {
       checkOperation(OperationCategory.WRITE);
+      if (isRollingUpgrade()) {
+        return rollingUpgradeInfo;
+      }
       long startTime = now();
       if (!haEnabled) { // for non-HA, we require NN to be in safemode
         startRollingUpgradeInternalForNonHA(startTime);
@@ -8401,13 +8404,16 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
     }
   }
 
-  RollingUpgradeInfo finalizeRollingUpgrade() throws IOException {
+  void finalizeRollingUpgrade() throws IOException {
     checkSuperuserPrivilege();
     checkOperation(OperationCategory.WRITE);
     writeLock();
     final RollingUpgradeInfo returnInfo;
     try {
       checkOperation(OperationCategory.WRITE);
+      if (!isRollingUpgrade()) {
+        return;
+      }
       checkNameNodeSafeMode("Failed to finalize rolling upgrade");
 
       returnInfo = finalizeRollingUpgradeInternal(now());
@@ -8431,16 +8437,11 @@ public class FSNamesystem implements Namesystem, FSClusterStats,
     if (auditLog.isInfoEnabled() && isExternalInvocation()) {
       logAuditEvent(true, "finalizeRollingUpgrade", null, null, null);
     }
-    return returnInfo;
+    return;
   }
 
   RollingUpgradeInfo finalizeRollingUpgradeInternal(long finalizeTime)
       throws RollingUpgradeException {
-    if (!isRollingUpgrade()) {
-      throw new RollingUpgradeException(
-          "Failed to finalize rolling upgrade since there is no rolling upgrade in progress.");
-    }
-
     final long startTime = rollingUpgradeInfo.getStartTime();
     rollingUpgradeInfo = null;
     return new RollingUpgradeInfo(blockPoolId, false, startTime, finalizeTime);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3dfd6e68/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java
index 9504883..5b36154 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/NameNodeRpcServer.java
@@ -959,7 +959,8 @@ class NameNodeRpcServer implements NamenodeProtocols {
     case PREPARE:
       return namesystem.startRollingUpgrade();
     case FINALIZE:
-      return namesystem.finalizeRollingUpgrade();
+      namesystem.finalizeRollingUpgrade();
+      return null;
     default:
       throw new UnsupportedActionException(action + " is not yet supported.");
     }

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3dfd6e68/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
index fed516b..484ac12 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
@@ -334,7 +334,8 @@ public class DFSAdmin extends FsShell {
           out.println(info);
         }
       } else {
-        out.println("There is no rolling upgrade in progress.");
+        out.println("There is no rolling upgrade in progress or rolling " +
+            "upgrade has already been finalized.");
       }
     }
 
@@ -356,7 +357,7 @@ public class DFSAdmin extends FsShell {
         Preconditions.checkState(info.isStarted());
         break;
       case FINALIZE:
-        Preconditions.checkState(info.isFinalized());
+        Preconditions.checkState(info == null || info.isFinalized());
         break;
       }
       printMessage(info, System.out);

http://git-wip-us.apache.org/repos/asf/hadoop/blob/3dfd6e68/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgrade.java
----------------------------------------------------------------------
diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgrade.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgrade.java
index 40aa37a..8e7b4b1 100644
--- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgrade.java
+++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestRollingUpgrade.java
@@ -239,9 +239,9 @@ public class TestRollingUpgrade {
       Assert.assertTrue(dfs2.exists(baz));
 
       //finalize rolling upgrade
-      final RollingUpgradeInfo finalize = dfs2.rollingUpgrade(RollingUpgradeAction.FINALIZE);
-      LOG.info("FINALIZE: " + finalize);
-      Assert.assertEquals(info1.getStartTime(), finalize.getStartTime());
+      final RollingUpgradeInfo finalize = dfs2.rollingUpgrade(
+          RollingUpgradeAction.FINALIZE);
+      Assert.assertNull(finalize);
 
       LOG.info("RESTART cluster 2 with regular startup option");
       cluster2.getNameNodeInfos()[0].setStartOpt(StartupOption.REGULAR);
@@ -385,7 +385,7 @@ public class TestRollingUpgrade {
       Assert.assertTrue(fsimage.hasRollbackFSImage());
 
       info = dfs.rollingUpgrade(RollingUpgradeAction.FINALIZE);
-      Assert.assertTrue(info.isFinalized());
+      Assert.assertNull(info);
       Assert.assertTrue(dfs.exists(foo));
 
       // Once finalized, there should be no more fsimage for rollbacks.