|
@@ -134,6 +134,7 @@ public class MiniDFSCluster {
|
|
|
private boolean format = true;
|
|
|
private boolean manageNameDfsDirs = true;
|
|
|
private boolean manageNameDfsSharedDirs = true;
|
|
|
+ private boolean enableManagedDfsDirsRedundancy = true;
|
|
|
private boolean manageDataDfsDirs = true;
|
|
|
private StartupOption option = null;
|
|
|
private String[] racks = null;
|
|
@@ -198,6 +199,14 @@ public class MiniDFSCluster {
|
|
|
return this;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Default: true
|
|
|
+ */
|
|
|
+ public Builder enableManagedDfsDirsRedundancy(boolean val) {
|
|
|
+ this.enableManagedDfsDirsRedundancy = val;
|
|
|
+ return this;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Default: true
|
|
|
*/
|
|
@@ -316,6 +325,7 @@ public class MiniDFSCluster {
|
|
|
builder.format,
|
|
|
builder.manageNameDfsDirs,
|
|
|
builder.manageNameDfsSharedDirs,
|
|
|
+ builder.enableManagedDfsDirsRedundancy,
|
|
|
builder.manageDataDfsDirs,
|
|
|
builder.option,
|
|
|
builder.racks,
|
|
@@ -558,7 +568,8 @@ public class MiniDFSCluster {
|
|
|
long[] simulatedCapacities) throws IOException {
|
|
|
this.nameNodes = new NameNodeInfo[1]; // Single namenode in the cluster
|
|
|
initMiniDFSCluster(conf, numDataNodes, format,
|
|
|
- manageNameDfsDirs, true, manageDataDfsDirs, operation, racks, hosts,
|
|
|
+ manageNameDfsDirs, true, true, manageDataDfsDirs,
|
|
|
+ operation, racks, hosts,
|
|
|
simulatedCapacities, null, true, false,
|
|
|
MiniDFSNNTopology.simpleSingleNN(nameNodePort, 0), true, false);
|
|
|
}
|
|
@@ -566,8 +577,8 @@ public class MiniDFSCluster {
|
|
|
private void initMiniDFSCluster(
|
|
|
Configuration conf,
|
|
|
int numDataNodes, boolean format, boolean manageNameDfsDirs,
|
|
|
- boolean manageNameDfsSharedDirs, boolean manageDataDfsDirs,
|
|
|
- StartupOption operation, String[] racks,
|
|
|
+ boolean manageNameDfsSharedDirs, boolean enableManagedDfsDirsRedundancy,
|
|
|
+ boolean manageDataDfsDirs, StartupOption operation, String[] racks,
|
|
|
String[] hosts, long[] simulatedCapacities, String clusterId,
|
|
|
boolean waitSafeMode, boolean setupHostsFile,
|
|
|
MiniDFSNNTopology nnTopology, boolean checkExitOnShutdown,
|
|
@@ -613,6 +624,7 @@ public class MiniDFSCluster {
|
|
|
federation = nnTopology.isFederated();
|
|
|
createNameNodesAndSetConf(
|
|
|
nnTopology, manageNameDfsDirs, manageNameDfsSharedDirs,
|
|
|
+ enableManagedDfsDirsRedundancy,
|
|
|
format, operation, clusterId, conf);
|
|
|
|
|
|
if (format) {
|
|
@@ -635,7 +647,8 @@ public class MiniDFSCluster {
|
|
|
|
|
|
private void createNameNodesAndSetConf(MiniDFSNNTopology nnTopology,
|
|
|
boolean manageNameDfsDirs, boolean manageNameDfsSharedDirs,
|
|
|
- boolean format, StartupOption operation, String clusterId,
|
|
|
+ boolean enableManagedDfsDirsRedundancy, boolean format,
|
|
|
+ StartupOption operation, String clusterId,
|
|
|
Configuration conf) throws IOException {
|
|
|
Preconditions.checkArgument(nnTopology.countNameNodes() > 0,
|
|
|
"empty NN topology: no namenodes specified!");
|
|
@@ -692,7 +705,7 @@ public class MiniDFSCluster {
|
|
|
int nnCounterForFormat = nnCounter;
|
|
|
for (NNConf nn : nameservice.getNNs()) {
|
|
|
initNameNodeConf(conf, nsId, nn.getNnId(), manageNameDfsDirs,
|
|
|
- nnCounterForFormat);
|
|
|
+ enableManagedDfsDirsRedundancy, nnCounterForFormat);
|
|
|
Collection<URI> namespaceDirs = FSNamesystem.getNamespaceDirs(conf);
|
|
|
if (format) {
|
|
|
for (URI nameDirUri : namespaceDirs) {
|
|
@@ -723,7 +736,8 @@ public class MiniDFSCluster {
|
|
|
|
|
|
// Start all Namenodes
|
|
|
for (NNConf nn : nameservice.getNNs()) {
|
|
|
- initNameNodeConf(conf, nsId, nn.getNnId(), manageNameDfsDirs, nnCounter);
|
|
|
+ initNameNodeConf(conf, nsId, nn.getNnId(), manageNameDfsDirs,
|
|
|
+ enableManagedDfsDirsRedundancy, nnCounter);
|
|
|
createNameNode(nnCounter++, conf, numDataNodes, false, operation,
|
|
|
clusterId, nsId, nn.getNnId());
|
|
|
}
|
|
@@ -748,8 +762,8 @@ public class MiniDFSCluster {
|
|
|
|
|
|
private void initNameNodeConf(Configuration conf,
|
|
|
String nameserviceId, String nnId,
|
|
|
- boolean manageNameDfsDirs, int nnIndex)
|
|
|
- throws IOException {
|
|
|
+ boolean manageNameDfsDirs, boolean enableManagedDfsDirsRedundancy,
|
|
|
+ int nnIndex) throws IOException {
|
|
|
if (nameserviceId != null) {
|
|
|
conf.set(DFS_NAMESERVICE_ID, nameserviceId);
|
|
|
}
|
|
@@ -758,12 +772,21 @@ public class MiniDFSCluster {
|
|
|
}
|
|
|
|
|
|
if (manageNameDfsDirs) {
|
|
|
- conf.set(DFS_NAMENODE_NAME_DIR_KEY,
|
|
|
- fileAsURI(new File(base_dir, "name" + (2*nnIndex + 1)))+","+
|
|
|
- fileAsURI(new File(base_dir, "name" + (2*nnIndex + 2))));
|
|
|
- conf.set(DFS_NAMENODE_CHECKPOINT_DIR_KEY,
|
|
|
- fileAsURI(new File(base_dir, "namesecondary" + (2*nnIndex + 1)))+","+
|
|
|
- fileAsURI(new File(base_dir, "namesecondary" + (2*nnIndex + 2))));
|
|
|
+ if (enableManagedDfsDirsRedundancy) {
|
|
|
+ conf.set(DFS_NAMENODE_NAME_DIR_KEY,
|
|
|
+ fileAsURI(new File(base_dir, "name" + (2*nnIndex + 1)))+","+
|
|
|
+ fileAsURI(new File(base_dir, "name" + (2*nnIndex + 2))));
|
|
|
+ conf.set(DFS_NAMENODE_CHECKPOINT_DIR_KEY,
|
|
|
+ fileAsURI(new File(base_dir, "namesecondary" + (2*nnIndex + 1)))+","+
|
|
|
+ fileAsURI(new File(base_dir, "namesecondary" + (2*nnIndex + 2))));
|
|
|
+ } else {
|
|
|
+ conf.set(DFS_NAMENODE_NAME_DIR_KEY,
|
|
|
+ fileAsURI(new File(base_dir, "name" + (2*nnIndex + 1))).
|
|
|
+ toString());
|
|
|
+ conf.set(DFS_NAMENODE_CHECKPOINT_DIR_KEY,
|
|
|
+ fileAsURI(new File(base_dir, "namesecondary" + (2*nnIndex + 1))).
|
|
|
+ toString());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -2188,7 +2211,7 @@ public class MiniDFSCluster {
|
|
|
String nnId = null;
|
|
|
initNameNodeAddress(conf, nameserviceId,
|
|
|
new NNConf(nnId).setIpcPort(namenodePort));
|
|
|
- initNameNodeConf(conf, nameserviceId, nnId, true, nnIndex);
|
|
|
+ initNameNodeConf(conf, nameserviceId, nnId, true, true, nnIndex);
|
|
|
createNameNode(nnIndex, conf, numDataNodes, true, null, null,
|
|
|
nameserviceId, nnId);
|
|
|
|