Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1204,8 +1204,9 @@ private static boolean format(Configuration conf, boolean force,
System.out.println("Formatting using clusterid: " + clusterId);

FSImage fsImage = new FSImage(conf, nameDirsToFormat, editDirsToFormat);
FSNamesystem fsn = null;
try {
FSNamesystem fsn = new FSNamesystem(conf, fsImage);
fsn = new FSNamesystem(conf, fsImage);
fsImage.getEditLog().initJournalsForWrite();

// Abort NameNode format if reformat is disabled and if
Expand All @@ -1230,8 +1231,14 @@ private static boolean format(Configuration conf, boolean force,
fsImage.format(fsn, clusterId, force);
} catch (IOException ioe) {
LOG.warn("Encountered exception during format: ", ioe);
fsImage.close();
throw ioe;
} finally {
if (fsImage != null) {
fsImage.close();
}
if (fsn != null) {
fsn.close();
}
}
return false;
}
Expand Down