HDFS-3853. Port MiniDFSCluster enableManagedDfsDirsRedundancy. Contributed by Colin Patrick McCabe
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1377545 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6cac9aa7f9
commit
804c45867a
|
@ -233,6 +233,9 @@ Release 2.0.1-alpha - UNRELEASED
|
|||
HDFS-3844. Add @Override and remove {@inheritdoc} and unnecessary
|
||||
imports. (Jing Zhao via suresh)
|
||||
|
||||
HDFS-3853. Port MiniDFSCluster enableManagedDfsDirsRedundancy
|
||||
option to branch-2. (Colin Patrick McCabe via eli)
|
||||
|
||||
OPTIMIZATIONS
|
||||
|
||||
HDFS-2982. Startup performance suffers when there are many edit log
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ public class TestFSEditLogLoader {
|
|||
MiniDFSCluster cluster = null;
|
||||
FileSystem fileSys = null;
|
||||
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(NUM_DATA_NODES)
|
||||
.build();
|
||||
.enableManagedDfsDirsRedundancy(false).build();
|
||||
cluster.waitActive();
|
||||
fileSys = cluster.getFileSystem();
|
||||
final FSNamesystem namesystem = cluster.getNamesystem();
|
||||
|
@ -100,7 +100,7 @@ public class TestFSEditLogLoader {
|
|||
bld.append("Recent opcode offsets: (\\d+\\s*){4}$");
|
||||
try {
|
||||
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(NUM_DATA_NODES)
|
||||
.format(false).build();
|
||||
.enableManagedDfsDirsRedundancy(false).format(false).build();
|
||||
fail("should not be able to start");
|
||||
} catch (IOException e) {
|
||||
assertTrue("error message contains opcodes message",
|
||||
|
|
|
@ -347,7 +347,7 @@ public class TestNameNodeRecovery {
|
|||
StorageDirectory sd = null;
|
||||
try {
|
||||
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0)
|
||||
.build();
|
||||
.enableManagedDfsDirsRedundancy(false).build();
|
||||
cluster.waitActive();
|
||||
if (!finalize) {
|
||||
// Normally, the in-progress edit log would be finalized by
|
||||
|
@ -383,7 +383,7 @@ public class TestNameNodeRecovery {
|
|||
try {
|
||||
LOG.debug("trying to start normally (this should fail)...");
|
||||
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0)
|
||||
.format(false).build();
|
||||
.enableManagedDfsDirsRedundancy(false).format(false).build();
|
||||
cluster.waitActive();
|
||||
cluster.shutdown();
|
||||
if (needRecovery) {
|
||||
|
@ -408,7 +408,8 @@ public class TestNameNodeRecovery {
|
|||
try {
|
||||
LOG.debug("running recovery...");
|
||||
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0)
|
||||
.format(false).startupOption(recoverStartOpt).build();
|
||||
.enableManagedDfsDirsRedundancy(false).format(false)
|
||||
.startupOption(recoverStartOpt).build();
|
||||
} catch (IOException e) {
|
||||
fail("caught IOException while trying to recover. " +
|
||||
"message was " + e.getMessage() +
|
||||
|
@ -424,7 +425,7 @@ public class TestNameNodeRecovery {
|
|||
try {
|
||||
LOG.debug("starting cluster normally after recovery...");
|
||||
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(0)
|
||||
.format(false).build();
|
||||
.enableManagedDfsDirsRedundancy(false).format(false).build();
|
||||
LOG.debug("successfully recovered the " + corruptor.getName() +
|
||||
" corrupted edit log");
|
||||
cluster.waitActive();
|
||||
|
|
Loading…
Reference in New Issue