From 61c432b31ec71679b08aa4abba9540086e5b2cd4 Mon Sep 17 00:00:00 2001 From: Konstantin Shvachko Date: Wed, 7 Nov 2012 18:07:18 +0000 Subject: [PATCH] HDFS-4138. BackupNode startup fails due to uninitialized edit log. Contributed by Kihwal Lee. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1406743 13f79535-47bb-0310-9956-ffa450edef68 --- hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt | 3 +++ .../hdfs/server/namenode/BackupNode.java | 18 ++---------------- .../hdfs/server/namenode/FSNamesystem.java | 2 +- 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt index 9caff1d66ad..8d9e03229a0 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt +++ b/hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt @@ -1686,6 +1686,9 @@ Release 0.23.5 - UNRELEASED HDFS-3625. Fix TestBackupNode by properly initializing edit log during startup. (Junping Du via todd) + HDFS-4138. BackupNode startup fails due to uninitialized edit log. + (Kihwal Lee via shv) + Release 0.23.4 - UNRELEASED INCOMPATIBLE CHANGES diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java index 61c00cc5659..4a7626418a6 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java @@ -77,10 +77,6 @@ public class BackupNode extends NameNode { String nnHttpAddress; /** Checkpoint manager */ Checkpointer checkpointManager; - /** ClusterID to which BackupNode belongs to */ - String clusterId; - /** Block pool Id of the peer namenode of this BackupNode */ - String blockPoolId; BackupNode(Configuration conf, NamenodeRole role) throws IOException { super(conf, role); @@ -144,6 +140,7 @@ public class BackupNode extends NameNode { CommonConfigurationKeys.FS_TRASH_INTERVAL_DEFAULT); NamespaceInfo nsInfo = handshake(conf); super.initialize(conf); + namesystem.setBlockPoolId(nsInfo.getBlockPoolID()); if (false == namesystem.isInSafeMode()) { namesystem.setSafeMode(SafeModeAction.SAFEMODE_ENTER); @@ -153,9 +150,6 @@ public class BackupNode extends NameNode { // therefore lease hard limit should never expire. namesystem.leaseManager.setLeasePeriod( HdfsConstants.LEASE_SOFTLIMIT_PERIOD, Long.MAX_VALUE); - - clusterId = nsInfo.getClusterID(); - blockPoolId = nsInfo.getBlockPoolID(); // register with the active name-node registerWith(nsInfo); @@ -209,7 +203,7 @@ public class BackupNode extends NameNode { } /* @Override */// NameNode - public boolean setSafeMode(@SuppressWarnings("unused") SafeModeAction action) + public boolean setSafeMode(SafeModeAction action) throws IOException { throw new UnsupportedActionException("setSafeMode"); } @@ -405,14 +399,6 @@ public class BackupNode extends NameNode { return nsInfo; } - String getBlockPoolId() { - return blockPoolId; - } - - String getClusterId() { - return clusterId; - } - @Override protected NameNodeHAContext createHAContext() { return new BNHAContext(); 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 1849c189e0a..3d8c0dea2ef 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 @@ -3483,7 +3483,7 @@ public class FSNamesystem implements Namesystem, FSClusterStats, @Metric({"TransactionsSinceLastLogRoll", "Number of transactions since last edit log roll"}) public long getTransactionsSinceLastLogRoll() { - if (isInStandbyState()) { + if (isInStandbyState() || !getEditLog().isSegmentOpen()) { return 0; } else { return getEditLog().getLastWrittenTxId() -