HDFS-15906. Close FSImage and FSNamesystem after formatting is complete (#2800)
(cherry picked from commit d05d15620e
)
This commit is contained in:
parent
c1b25422a5
commit
75f2d47ff5
|
@ -1200,8 +1200,9 @@ public class NameNode extends ReconfigurableBase implements
|
|||
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
|
||||
|
@ -1226,8 +1227,14 @@ public class NameNode extends ReconfigurableBase implements
|
|||
fsImage.format(fsn, clusterId);
|
||||
} 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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue