Skip to content

Commit

Permalink
HDFS-17315. Optimize the namenode format code logic. (apache#6400)
Browse files Browse the repository at this point in the history
Signed-off-by: Takanobu Asanuma <[email protected]>
  • Loading branch information
huangzhaobo99 authored Jan 5, 2024
1 parent 5f9932a commit 0871366
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1380,7 +1380,6 @@ private static boolean format(Configuration conf, boolean force,
}

Collection<URI> nameDirsToFormat = FSNamesystem.getNamespaceDirs(conf);
List<URI> sharedDirs = FSNamesystem.getSharedEditsDirs(conf);
List<URI> editDirsToFormat =
FSNamesystem.getNamespaceEditsDirs(conf);

Expand All @@ -1392,10 +1391,8 @@ private static boolean format(Configuration conf, boolean force,
}

LOG.info("Formatting using clusterid: {}", clusterId);

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

Expand Down Expand Up @@ -1423,7 +1420,6 @@ private static boolean format(Configuration conf, boolean force,
LOG.warn("Encountered exception during format", ioe);
throw ioe;
} finally {
fsImage.close();
if (fsn != null) {
fsn.close();
}
Expand Down

0 comments on commit 0871366

Please sign in to comment.