HDFS-2934. Allow configs to be scoped to all NNs in the nameservice. Contributed by Todd Lipcon.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1244759 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Todd Lipcon 2012-02-15 22:19:12 +00:00
parent 3c145d3492
commit 05151ecf79
3 changed files with 44 additions and 1 deletions

View File

@ -204,3 +204,5 @@ HDFS-2942. TestActiveStandbyElectorRealZK fails if build dir does not exist. (at
HDFS-2948. NN throws NPE during shutdown if it fails to startup (todd) 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-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)

View File

@ -746,7 +746,10 @@ public class DFSUtil {
/** /**
* Sets the node specific setting into generic configuration key. Looks up * Sets the node specific setting into generic configuration key. Looks up
* value of "key.nameserviceId.namenodeId" and if found sets that value into * 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 * @param conf
* Configuration object to lookup specific key and to set the value * Configuration object to lookup specific key and to set the value
@ -764,6 +767,11 @@ public class DFSUtil {
String nameserviceId, String nnId, String... keys) { String nameserviceId, String nnId, String... keys) {
for (String key : keys) { for (String key : keys) {
String value = conf.get(addKeySuffixes(key, nameserviceId, nnId)); 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) { if (value != null) {
conf.set(key, value); conf.set(key, value);
} }

View File

@ -325,6 +325,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 * Tests for empty configuration, an exception is thrown from
* {@link DFSUtil#getNNServiceRpcAddresses(Configuration)} * {@link DFSUtil#getNNServiceRpcAddresses(Configuration)}