HDFS-9718. HAUtil#getConfForOtherNodes should unset independent generic keys before initialize (Contributed by DENG FEI)
(cherry picked from commit4d7055e0c8
) Conflicts: hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/HAUtil.java hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/server/namenode/ha/TestHAConfiguration.java (cherry picked from commit80dd039b6e
)
This commit is contained in:
parent
aeea77ce14
commit
94950c15c2
|
@ -1695,6 +1695,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
|
|
||||||
HDFS-9701. DN may deadlock when hot-swapping under load. (Xiao Chen via lei)
|
HDFS-9701. DN may deadlock when hot-swapping under load. (Xiao Chen via lei)
|
||||||
|
|
||||||
|
HDFS-9718. HAUtil#getConfForOtherNodes should unset independent generic keys
|
||||||
|
before initialize (DENG FEI via vinayakumarb)
|
||||||
|
|
||||||
Release 2.7.3 - UNRELEASED
|
Release 2.7.3 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -18,7 +18,16 @@
|
||||||
package org.apache.hadoop.hdfs;
|
package org.apache.hadoop.hdfs;
|
||||||
|
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HA_NAMENODE_ID_KEY;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_HA_NAMENODE_ID_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HTTPS_ADDRESS_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HTTPS_BIND_HOST_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HTTP_ADDRESS_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_HTTP_BIND_HOST_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_LIFELINE_RPC_ADDRESS_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_LIFELINE_RPC_BIND_HOST_KEY;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_RPC_BIND_HOST_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY;
|
||||||
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_BIND_HOST_KEY;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SHARED_EDITS_DIR_KEY;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SHARED_EDITS_DIR_KEY;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -64,6 +73,19 @@ public class HAUtil {
|
||||||
private static final DelegationTokenSelector tokenSelector =
|
private static final DelegationTokenSelector tokenSelector =
|
||||||
new DelegationTokenSelector();
|
new DelegationTokenSelector();
|
||||||
|
|
||||||
|
private static final String[] HA_SPECIAL_INDEPENDENT_KEYS = new String []{
|
||||||
|
DFS_NAMENODE_RPC_ADDRESS_KEY,
|
||||||
|
DFS_NAMENODE_RPC_BIND_HOST_KEY,
|
||||||
|
DFS_NAMENODE_LIFELINE_RPC_ADDRESS_KEY,
|
||||||
|
DFS_NAMENODE_LIFELINE_RPC_BIND_HOST_KEY,
|
||||||
|
DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY,
|
||||||
|
DFS_NAMENODE_SERVICE_RPC_BIND_HOST_KEY,
|
||||||
|
DFS_NAMENODE_HTTP_ADDRESS_KEY,
|
||||||
|
DFS_NAMENODE_HTTPS_ADDRESS_KEY,
|
||||||
|
DFS_NAMENODE_HTTP_BIND_HOST_KEY,
|
||||||
|
DFS_NAMENODE_HTTPS_BIND_HOST_KEY
|
||||||
|
};
|
||||||
|
|
||||||
private HAUtil() { /* Hidden constructor */ }
|
private HAUtil() { /* Hidden constructor */ }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -188,6 +210,10 @@ public class HAUtil {
|
||||||
|
|
||||||
// Look up the address of the active NN.
|
// Look up the address of the active NN.
|
||||||
Configuration confForOtherNode = new Configuration(myConf);
|
Configuration confForOtherNode = new Configuration(myConf);
|
||||||
|
// unset independent properties
|
||||||
|
for (String idpKey : HA_SPECIAL_INDEPENDENT_KEYS) {
|
||||||
|
confForOtherNode.unset(idpKey);
|
||||||
|
}
|
||||||
NameNode.initializeGenericKeys(confForOtherNode, nsId, otherNn);
|
NameNode.initializeGenericKeys(confForOtherNode, nsId, otherNn);
|
||||||
return confForOtherNode;
|
return confForOtherNode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,8 @@ package org.apache.hadoop.hdfs.server.namenode.ha;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_EDITS_DIR_KEY;
|
||||||
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SHARED_EDITS_DIR_KEY;
|
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_NAMENODE_SHARED_EDITS_DIR_KEY;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -30,6 +32,7 @@ import java.util.Collection;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||||
import org.apache.hadoop.hdfs.DFSUtil;
|
import org.apache.hadoop.hdfs.DFSUtil;
|
||||||
|
import org.apache.hadoop.hdfs.HAUtil;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
|
import org.apache.hadoop.hdfs.server.namenode.FSNamesystem;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
import org.apache.hadoop.hdfs.server.namenode.NameNode;
|
||||||
import org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode;
|
import org.apache.hadoop.hdfs.server.namenode.SecondaryNameNode;
|
||||||
|
@ -127,4 +130,23 @@ public class TestHAConfiguration {
|
||||||
"Cannot use SecondaryNameNode in an HA cluster", ioe);
|
"Cannot use SecondaryNameNode in an HA cluster", ioe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetOtherNNGenericConf() throws IOException {
|
||||||
|
String nsId = "ns1";
|
||||||
|
String host1 = "1.2.3.1";
|
||||||
|
String host2 = "1.2.3.2";
|
||||||
|
Configuration conf = getHAConf(nsId, host1, host2);
|
||||||
|
conf.set(DFSUtil.addKeySuffixes(
|
||||||
|
DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY, nsId, "nn1"), host1
|
||||||
|
+ ":54321");
|
||||||
|
conf.set(DFSConfigKeys.DFS_NAMESERVICE_ID, "ns1");
|
||||||
|
NameNode.initializeGenericKeys(conf, "ns1", "nn1");
|
||||||
|
|
||||||
|
Configuration nn2Conf = HAUtil.getConfForOtherNode(conf);
|
||||||
|
assertEquals(nn2Conf.get(DFSConfigKeys.DFS_HA_NAMENODE_ID_KEY), "nn2");
|
||||||
|
assertTrue(!conf.get(DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY).equals(
|
||||||
|
nn2Conf.get(DFSConfigKeys.DFS_NAMENODE_RPC_ADDRESS_KEY)));
|
||||||
|
assertNull(nn2Conf.get(DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_ADDRESS_KEY));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue