HDFS-17315. Optimize the namenode format code logic. (#6400)
Signed-off-by: Takanobu Asanuma <tasanuma@apache.org>
This commit is contained in:
parent
5f9932acc4
commit
08713665c0
@ -1380,7 +1380,6 @@ private static boolean format(Configuration conf, boolean force,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Collection<URI> nameDirsToFormat = FSNamesystem.getNamespaceDirs(conf);
|
Collection<URI> nameDirsToFormat = FSNamesystem.getNamespaceDirs(conf);
|
||||||
List<URI> sharedDirs = FSNamesystem.getSharedEditsDirs(conf);
|
|
||||||
List<URI> editDirsToFormat =
|
List<URI> editDirsToFormat =
|
||||||
FSNamesystem.getNamespaceEditsDirs(conf);
|
FSNamesystem.getNamespaceEditsDirs(conf);
|
||||||
|
|
||||||
@ -1392,10 +1391,8 @@ private static boolean format(Configuration conf, boolean force,
|
|||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("Formatting using clusterid: {}", clusterId);
|
LOG.info("Formatting using clusterid: {}", clusterId);
|
||||||
|
|
||||||
FSImage fsImage = new FSImage(conf, nameDirsToFormat, editDirsToFormat);
|
|
||||||
FSNamesystem fsn = null;
|
FSNamesystem fsn = null;
|
||||||
try {
|
try (FSImage fsImage = new FSImage(conf, nameDirsToFormat, editDirsToFormat)) {
|
||||||
fsn = new FSNamesystem(conf, fsImage);
|
fsn = new FSNamesystem(conf, fsImage);
|
||||||
fsImage.getEditLog().initJournalsForWrite();
|
fsImage.getEditLog().initJournalsForWrite();
|
||||||
|
|
||||||
@ -1423,7 +1420,6 @@ private static boolean format(Configuration conf, boolean force,
|
|||||||
LOG.warn("Encountered exception during format", ioe);
|
LOG.warn("Encountered exception during format", ioe);
|
||||||
throw ioe;
|
throw ioe;
|
||||||
} finally {
|
} finally {
|
||||||
fsImage.close();
|
|
||||||
if (fsn != null) {
|
if (fsn != null) {
|
||||||
fsn.close();
|
fsn.close();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user