HDFS-2974. MiniDFSCluster does not delete standby NN name dirs during format. Contributed by Aaron T. Myers.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-1623@1291126 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Aaron Myers 2012-02-20 04:12:01 +00:00
parent 41e56dfece
commit d03dac7432
3 changed files with 14 additions and 2 deletions

View File

@ -218,3 +218,5 @@ HDFS-2937. TestDFSHAAdmin needs tests with MiniDFSCluster. (Brandon Li via sures
HDFS-2586. Add protobuf service and implementation for HAServiceProtocol. (suresh via atm) HDFS-2586. Add protobuf service and implementation for HAServiceProtocol. (suresh via atm)
HDFS-2952. NN should not start with upgrade option or with a pending an unfinalized upgrade. (atm) HDFS-2952. NN should not start with upgrade option or with a pending an unfinalized upgrade. (atm)
HDFS-2974. MiniDFSCluster does not delete standby NN name dirs during format. (atm)

View File

@ -626,6 +626,15 @@ private void createNameNodesAndSetConf(MiniDFSNNTopology nnTopology,
for (NNConf nn : nameservice.getNNs()) { for (NNConf nn : nameservice.getNNs()) {
initNameNodeConf(conf, nsId, nn.getNnId(), manageNameDfsDirs, initNameNodeConf(conf, nsId, nn.getNnId(), manageNameDfsDirs,
nnCounterForFormat); nnCounterForFormat);
Collection<URI> namespaceDirs = FSNamesystem.getNamespaceDirs(conf);
if (format) {
for (URI nameDirUri : namespaceDirs) {
File nameDir = new File(nameDirUri);
if (nameDir.exists() && !FileUtil.fullyDelete(nameDir)) {
throw new IOException("Could not fully delete " + nameDir);
}
}
}
boolean formatThisOne = format; boolean formatThisOne = format;
if (format && i++ > 0) { if (format && i++ > 0) {
@ -635,14 +644,14 @@ private void createNameNodesAndSetConf(MiniDFSNNTopology nnTopology,
// from the first one. // from the first one.
formatThisOne = false; formatThisOne = false;
assert (null != prevNNDirs); assert (null != prevNNDirs);
copyNameDirs(prevNNDirs, FSNamesystem.getNamespaceDirs(conf), conf); copyNameDirs(prevNNDirs, namespaceDirs, conf);
} }
nnCounterForFormat++; nnCounterForFormat++;
if (formatThisOne) { if (formatThisOne) {
DFSTestUtil.formatNameNode(conf); DFSTestUtil.formatNameNode(conf);
} }
prevNNDirs = FSNamesystem.getNamespaceDirs(conf); prevNNDirs = namespaceDirs;
} }
// Start all Namenodes // Start all Namenodes

View File

@ -655,6 +655,7 @@ private static void assertClusterStartFailsWhenDirLocked(
sdToLock.lock(); sdToLock.lock();
try { try {
MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf) MiniDFSCluster cluster = new MiniDFSCluster.Builder(conf)
.format(false)
.manageNameDfsDirs(false) .manageNameDfsDirs(false)
.numDataNodes(0) .numDataNodes(0)
.build(); .build();