sijie commented on a change in pull request #1027: ISSUE #1026: initbookie cmd
URL: https://github.com/apache/bookkeeper/pull/1027#discussion_r162799940
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
##########
@@ -1154,6 +1159,73 @@ public static boolean format(ServerConfiguration conf,
}
}
+ /**
+ * Initializes bookie, by making sure that the journalDir, ledgerDirs and
+ * indexDirs are empty and there is no registered Bookie with this
BookieId.
+ *
+ * @param conf
+ * @return
+ * @throws Exception
+ */
+ public static boolean initBookie(ServerConfiguration conf) throws
Exception {
+ try (RegistrationManager rm =
RegistrationManager.instantiateRegistrationManager(conf)) {
+ /*
+ * make sure that journalDir, ledgerDirs and indexDirs are empty
+ */
+ File[] journalDirs = conf.getJournalDirs();
+ for (File journalDir : journalDirs) {
Review comment:
line 1176-1182, 1185-1192, 1196-1204 are having duplicated the logic. is it
better to abstract this logic into a util function, rather than duplicating the
code?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services