From 6c0cb4d15179103d4f83fe5b2f8d8f6a05f3a789 Mon Sep 17 00:00:00 2001 From: Suresh Srinivas Date: Tue, 19 Jul 2011 01:32:59 +0000 Subject: [PATCH] HDFS-2141. Remove NameNode roles Active and Standby (they become states of the namenode). Contributed by Suresh Srinivas. git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1148125 13f79535-47bb-0310-9956-ffa450edef68 --- hdfs/CHANGES.txt | 3 +++ .../apache/hadoop/hdfs/server/common/HdfsConstants.java | 7 +++---- .../apache/hadoop/hdfs/server/namenode/BackupNode.java | 2 +- .../org/apache/hadoop/hdfs/server/namenode/FSImage.java | 2 +- .../org/apache/hadoop/hdfs/server/namenode/NameNode.java | 8 ++++---- .../hadoop/hdfs/server/namenode/TestEditLogRace.java | 4 ++-- .../hadoop/hdfs/server/namenode/TestSaveNamespace.java | 8 ++++---- .../hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java | 2 +- 8 files changed, 19 insertions(+), 17 deletions(-) diff --git a/hdfs/CHANGES.txt b/hdfs/CHANGES.txt index 0c3be6a77e..2c7f4cdf3d 100644 --- a/hdfs/CHANGES.txt +++ b/hdfs/CHANGES.txt @@ -572,6 +572,9 @@ Trunk (unreleased changes) HDFS-2147. Move cluster network topology to block management and fix some javac warnings. (szetszwo) + HDFS-2141. Remove NameNode roles Active and Standby (they become + states of the namenode). (suresh) + OPTIMIZATIONS HDFS-1458. Improve checkpoint performance by avoiding unnecessary image diff --git a/hdfs/src/java/org/apache/hadoop/hdfs/server/common/HdfsConstants.java b/hdfs/src/java/org/apache/hadoop/hdfs/server/common/HdfsConstants.java index 94a86c421b..755ecc6935 100644 --- a/hdfs/src/java/org/apache/hadoop/hdfs/server/common/HdfsConstants.java +++ b/hdfs/src/java/org/apache/hadoop/hdfs/server/common/HdfsConstants.java @@ -65,7 +65,7 @@ public NamenodeRole toNodeRole() { case CHECKPOINT: return NamenodeRole.CHECKPOINT; default: - return NamenodeRole.ACTIVE; + return NamenodeRole.NAMENODE; } } @@ -89,10 +89,9 @@ public String getClusterId() { * Defines the NameNode role. */ static public enum NamenodeRole { - ACTIVE ("NameNode"), + NAMENODE ("NameNode"), BACKUP ("Backup Node"), - CHECKPOINT("Checkpoint Node"), - STANDBY ("Standby Node"); + CHECKPOINT("Checkpoint Node"); private String description = null; private NamenodeRole(String arg) {this.description = arg;} diff --git a/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java b/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java index 484be2e0ec..906d869682 100644 --- a/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java +++ b/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/BackupNode.java @@ -327,7 +327,7 @@ else if(bnImage.getStorage().getNamespaceID() != nsInfo.getNamespaceID()) String msg = null; if(nnReg == null) // consider as a rejection msg = "Registration rejected by " + nnRpcAddress; - else if(!nnReg.isRole(NamenodeRole.ACTIVE)) { + else if(!nnReg.isRole(NamenodeRole.NAMENODE)) { msg = "Name-node " + nnRpcAddress + " is not active"; } if(msg != null) { diff --git a/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java b/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java index bce5db1d6a..f81ee730f5 100644 --- a/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java +++ b/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/FSImage.java @@ -1142,7 +1142,7 @@ NamenodeCommand startCheckpoint(NamenodeRegistration bnReg, // backup node msg = "Name node " + bnReg.getAddress() + " has incompatible namespace id: " + bnReg.getNamespaceID() + " expected: " + storage.getNamespaceID(); - else if(bnReg.isRole(NamenodeRole.ACTIVE)) + else if(bnReg.isRole(NamenodeRole.NAMENODE)) msg = "Name node " + bnReg.getAddress() + " role " + bnReg.getRole() + ": checkpoint is not allowed."; else if(bnReg.getLayoutVersion() < storage.getLayoutVersion() diff --git a/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java b/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java index 0756e9c582..e8293c470b 100644 --- a/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java +++ b/hdfs/src/java/org/apache/hadoop/hdfs/server/namenode/NameNode.java @@ -480,7 +480,7 @@ protected void validateConfigurationSettings(final Configuration conf) * Activate name-node servers and threads. */ void activate(Configuration conf) throws IOException { - if ((isRole(NamenodeRole.ACTIVE)) + if ((isRole(NamenodeRole.NAMENODE)) && (UserGroupInformation.isSecurityEnabled())) { namesystem.activateSecretManager(); } @@ -646,7 +646,7 @@ public HttpServer run() throws IOException, InterruptedException { * @throws IOException */ public NameNode(Configuration conf) throws IOException { - this(conf, NamenodeRole.ACTIVE); + this(conf, NamenodeRole.NAMENODE); } protected NameNode(Configuration conf, NamenodeRole role) @@ -752,7 +752,7 @@ public NamenodeRegistration register(NamenodeRegistration registration) public NamenodeCommand startCheckpoint(NamenodeRegistration registration) throws IOException { verifyRequest(registration); - if(!isRole(NamenodeRole.ACTIVE)) + if(!isRole(NamenodeRole.NAMENODE)) throw new IOException("Only an ACTIVE node can invoke startCheckpoint."); return namesystem.startCheckpoint(registration, setRegistration()); } @@ -761,7 +761,7 @@ public NamenodeCommand startCheckpoint(NamenodeRegistration registration) public void endCheckpoint(NamenodeRegistration registration, CheckpointSignature sig) throws IOException { verifyRequest(registration); - if(!isRole(NamenodeRole.ACTIVE)) + if(!isRole(NamenodeRole.NAMENODE)) throw new IOException("Only an ACTIVE node can invoke endCheckpoint."); namesystem.endCheckpoint(registration, sig); } diff --git a/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestEditLogRace.java b/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestEditLogRace.java index d4edbd5fa2..227dc95fdb 100644 --- a/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestEditLogRace.java +++ b/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestEditLogRace.java @@ -320,7 +320,7 @@ private Configuration getConf() { @Test public void testSaveImageWhileSyncInProgress() throws Exception { Configuration conf = getConf(); - NameNode.initMetrics(conf, NamenodeRole.ACTIVE); + NameNode.initMetrics(conf, NamenodeRole.NAMENODE); DFSTestUtil.formatNameNode(conf); final FSNamesystem namesystem = new FSNamesystem(conf); @@ -410,7 +410,7 @@ public Void answer(InvocationOnMock invocation) throws Throwable { @Test public void testSaveRightBeforeSync() throws Exception { Configuration conf = getConf(); - NameNode.initMetrics(conf, NamenodeRole.ACTIVE); + NameNode.initMetrics(conf, NamenodeRole.NAMENODE); DFSTestUtil.formatNameNode(conf); final FSNamesystem namesystem = new FSNamesystem(conf); diff --git a/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java b/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java index 6007b6f90f..862906196b 100644 --- a/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java +++ b/hdfs/src/test/hdfs/org/apache/hadoop/hdfs/server/namenode/TestSaveNamespace.java @@ -101,7 +101,7 @@ private enum Fault { private void saveNamespaceWithInjectedFault(Fault fault) throws IOException { Configuration conf = getConf(); - NameNode.initMetrics(conf, NamenodeRole.ACTIVE); + NameNode.initMetrics(conf, NamenodeRole.NAMENODE); DFSTestUtil.formatNameNode(conf); FSNamesystem fsn = new FSNamesystem(conf); @@ -178,7 +178,7 @@ public void testReinsertnamedirsInSavenamespace() throws Exception { Configuration conf = getConf(); conf.setBoolean(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_RESTORE_KEY, true); - NameNode.initMetrics(conf, NamenodeRole.ACTIVE); + NameNode.initMetrics(conf, NamenodeRole.NAMENODE); DFSTestUtil.formatNameNode(conf); FSNamesystem fsn = new FSNamesystem(conf); @@ -295,7 +295,7 @@ public void testFailedSaveNamespaceWithRecovery() throws Exception { public void doTestFailedSaveNamespace(boolean restoreStorageAfterFailure) throws Exception { Configuration conf = getConf(); - NameNode.initMetrics(conf, NamenodeRole.ACTIVE); + NameNode.initMetrics(conf, NamenodeRole.NAMENODE); DFSTestUtil.formatNameNode(conf); FSNamesystem fsn = new FSNamesystem(conf); @@ -356,7 +356,7 @@ public void doTestFailedSaveNamespace(boolean restoreStorageAfterFailure) @Test public void testSaveWhileEditsRolled() throws Exception { Configuration conf = getConf(); - NameNode.initMetrics(conf, NamenodeRole.ACTIVE); + NameNode.initMetrics(conf, NamenodeRole.NAMENODE); DFSTestUtil.formatNameNode(conf); FSNamesystem fsn = new FSNamesystem(conf); diff --git a/hdfs/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java b/hdfs/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java index bcf4d0235e..ca91724abf 100644 --- a/hdfs/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java +++ b/hdfs/src/test/unit/org/apache/hadoop/hdfs/server/namenode/TestNNLeaseRecovery.java @@ -79,7 +79,7 @@ public void startUp() throws IOException { conf.set(DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY, NAME_DIR); // avoid stubbing access control conf.setBoolean(DFSConfigKeys.DFS_PERMISSIONS_ENABLED_KEY, false); - NameNode.initMetrics(conf, NamenodeRole.ACTIVE); + NameNode.initMetrics(conf, NamenodeRole.NAMENODE); FileSystem.setDefaultUri(conf, "hdfs://localhost:0"); conf.set(DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY, "0.0.0.0:0");