hadoop-hdfs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t...@apache.org
Subject svn commit: r1244759 - in /hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs: CHANGES.HDFS-1623.txt src/main/java/org/apache/hadoop/hdfs/DFSUtil.java src/test/java/org/apache/hadoop/hdfs/TestDFSUtil.java
Date Wed, 15 Feb 2012 22:19:13 GMT
Author: todd
Date: Wed Feb 15 22:19:12 2012
New Revision: 1244759

URL: http://svn.apache.org/viewvc?rev=1244759&view=rev
Log:
HDFS-2934. Allow configs to be scoped to all NNs in the nameservice. Contributed by Todd Lipcon.

Modified:
    hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt
    hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java
    hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUtil.java

Modified: hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt?rev=1244759&r1=1244758&r2=1244759&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/CHANGES.HDFS-1623.txt
Wed Feb 15 22:19:12 2012
@@ -204,3 +204,5 @@ HDFS-2942. TestActiveStandbyElectorRealZ
 HDFS-2948. NN throws NPE during shutdown if it fails to startup (todd)
 
 HDFS-2909. HA: Inaccessible shared edits dir not getting removed from FSImage storage dirs
upon error. (Bikas Saha via jitendra)
+
+HDFS-2934. Allow configs to be scoped to all NNs in the nameservice. (todd)

Modified: hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java?rev=1244759&r1=1244758&r2=1244759&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/DFSUtil.java
Wed Feb 15 22:19:12 2012
@@ -746,7 +746,10 @@ public class DFSUtil {
   /**
    * Sets the node specific setting into generic configuration key. Looks up
    * value of "key.nameserviceId.namenodeId" and if found sets that value into 
-   * generic key in the conf. Note that this only modifies the runtime conf.
+   * generic key in the conf. If this is not found, falls back to
+   * "key.nameserviceId" and then the unmodified key.
+   *
+   * Note that this only modifies the runtime conf.
    * 
    * @param conf
    *          Configuration object to lookup specific key and to set the value
@@ -766,6 +769,11 @@ public class DFSUtil {
       String value = conf.get(addKeySuffixes(key, nameserviceId, nnId));
       if (value != null) {
         conf.set(key, value);
+        continue;
+      }
+      value = conf.get(addKeySuffixes(key, nameserviceId));
+      if (value != null) {
+        conf.set(key, value);
       }
     }
   }

Modified: hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUtil.java
URL: http://svn.apache.org/viewvc/hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUtil.java?rev=1244759&r1=1244758&r2=1244759&view=diff
==============================================================================
--- hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUtil.java
(original)
+++ hadoop/common/branches/HDFS-1623/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/TestDFSUtil.java
Wed Feb 15 22:19:12 2012
@@ -326,6 +326,39 @@ public class TestDFSUtil {
   }
 
   /**
+   * Regression test for HDFS-2934.
+   */
+  @Test
+  public void testSomeConfsNNSpecificSomeNSSpecific() {
+    final HdfsConfiguration conf = new HdfsConfiguration();
+
+    String key = DFSConfigKeys.DFS_NAMENODE_SHARED_EDITS_DIR_KEY;
+    conf.set(key, "global-default");
+    conf.set(key + ".ns1", "ns1-override");
+    conf.set(key + ".ns1.nn1", "nn1-override");
+
+    // A namenode in another nameservice should get the global default.
+    Configuration newConf = new Configuration(conf);
+    NameNode.initializeGenericKeys(newConf, "ns2", "nn1");
+    assertEquals("global-default", newConf.get(key));
+    
+    // A namenode in another non-HA nameservice should get global default.
+    newConf = new Configuration(conf);
+    NameNode.initializeGenericKeys(newConf, "ns2", null);
+    assertEquals("global-default", newConf.get(key));    
+    
+    // A namenode in the same nameservice should get the ns setting
+    newConf = new Configuration(conf);
+    NameNode.initializeGenericKeys(newConf, "ns1", "nn2");
+    assertEquals("ns1-override", newConf.get(key));    
+
+    // The nn with the nn-specific setting should get its own override
+    newConf = new Configuration(conf);
+    NameNode.initializeGenericKeys(newConf, "ns1", "nn1");
+    assertEquals("nn1-override", newConf.get(key));    
+  }
+  
+  /**
    * Tests for empty configuration, an exception is thrown from
    * {@link DFSUtil#getNNServiceRpcAddresses(Configuration)}
    * {@link DFSUtil#getBackupNodeAddresses(Configuration)}



Mime
View raw message