HDFS-3013. HA: NameNode format doesn't pick up dfs.namenode.name.dir.NameServiceId configuration. Contributed by Mingjie Lai.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1294425 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
5fd47e77ab
commit
da9aa34bec
@ -232,3 +232,5 @@ HDFS-2922. HA: close out operation categories (eli)
|
|||||||
HDFS-2993. HA: BackupNode#checkOperation should permit CHECKPOINT operations (eli)
|
HDFS-2993. HA: BackupNode#checkOperation should permit CHECKPOINT operations (eli)
|
||||||
|
|
||||||
HDFS-2904. Client support for getting delegation tokens. (todd)
|
HDFS-2904. Client support for getting delegation tokens. (todd)
|
||||||
|
|
||||||
|
HDFS-3013. HA: NameNode format doesn't pick up dfs.namenode.name.dir.NameServiceId configuration (Mingjie Lai via todd)
|
||||||
|
@ -649,6 +649,10 @@ public InetSocketAddress getHttpAddress() {
|
|||||||
private static boolean format(Configuration conf,
|
private static boolean format(Configuration conf,
|
||||||
boolean isConfirmationNeeded)
|
boolean isConfirmationNeeded)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
String nsId = DFSUtil.getNamenodeNameServiceId(conf);
|
||||||
|
String namenodeId = HAUtil.getNameNodeId(conf, nsId);
|
||||||
|
initializeGenericKeys(conf, nsId, namenodeId);
|
||||||
|
|
||||||
if (!conf.getBoolean(DFS_NAMENODE_SUPPORT_ALLOW_FORMAT_KEY,
|
if (!conf.getBoolean(DFS_NAMENODE_SUPPORT_ALLOW_FORMAT_KEY,
|
||||||
DFS_NAMENODE_SUPPORT_ALLOW_FORMAT_DEFAULT)) {
|
DFS_NAMENODE_SUPPORT_ALLOW_FORMAT_DEFAULT)) {
|
||||||
throw new IOException("The option " + DFS_NAMENODE_SUPPORT_ALLOW_FORMAT_KEY
|
throw new IOException("The option " + DFS_NAMENODE_SUPPORT_ALLOW_FORMAT_KEY
|
||||||
@ -693,6 +697,10 @@ private static boolean format(Configuration conf,
|
|||||||
private static boolean finalize(Configuration conf,
|
private static boolean finalize(Configuration conf,
|
||||||
boolean isConfirmationNeeded
|
boolean isConfirmationNeeded
|
||||||
) throws IOException {
|
) throws IOException {
|
||||||
|
String nsId = DFSUtil.getNamenodeNameServiceId(conf);
|
||||||
|
String namenodeId = HAUtil.getNameNodeId(conf, nsId);
|
||||||
|
initializeGenericKeys(conf, nsId, namenodeId);
|
||||||
|
|
||||||
FSNamesystem nsys = new FSNamesystem(conf, new FSImage(conf));
|
FSNamesystem nsys = new FSNamesystem(conf, new FSImage(conf));
|
||||||
System.err.print(
|
System.err.print(
|
||||||
"\"finalize\" will remove the previous state of the files system.\n"
|
"\"finalize\" will remove the previous state of the files system.\n"
|
||||||
|
@ -19,10 +19,12 @@
|
|||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
import org.apache.hadoop.conf.Configuration;
|
import org.apache.hadoop.conf.Configuration;
|
||||||
import org.apache.hadoop.fs.FileSystem;
|
import org.apache.hadoop.fs.FileSystem;
|
||||||
|
import org.apache.hadoop.fs.FileUtil;
|
||||||
import org.apache.hadoop.hdfs.DFSTestUtil;
|
import org.apache.hadoop.hdfs.DFSTestUtil;
|
||||||
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
import org.apache.hadoop.hdfs.HdfsConfiguration;
|
||||||
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
import org.apache.hadoop.hdfs.DFSConfigKeys;
|
||||||
@ -71,4 +73,25 @@ public void testThatDifferentRPCandHttpPortsAreOK()
|
|||||||
DFSTestUtil.formatNameNode(conf);
|
DFSTestUtil.formatNameNode(conf);
|
||||||
NameNode nameNode = new NameNode(conf); // should be OK!
|
NameNode nameNode = new NameNode(conf); // should be OK!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HDFS-3013: NameNode format command doesn't pick up
|
||||||
|
* dfs.namenode.name.dir.NameServiceId configuration.
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testGenericKeysForNameNodeFormat()
|
||||||
|
throws IOException {
|
||||||
|
Configuration conf = new HdfsConfiguration();
|
||||||
|
FileSystem.setDefaultUri(conf, "hdfs://localhost:8070");
|
||||||
|
conf.set(DFSConfigKeys.DFS_FEDERATION_NAMESERVICES, "ns1");
|
||||||
|
String nameDir = System.getProperty("java.io.tmpdir") + "/test.dfs.name";
|
||||||
|
File dir = new File(nameDir);
|
||||||
|
if (dir.exists()) {
|
||||||
|
FileUtil.fullyDelete(dir);
|
||||||
|
}
|
||||||
|
conf.set(DFSConfigKeys.DFS_NAMENODE_NAME_DIR_KEY + ".ns1", nameDir);
|
||||||
|
DFSTestUtil.formatNameNode(conf);
|
||||||
|
NameNode nameNode = new NameNode(conf);
|
||||||
|
FileUtil.fullyDelete(dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user