sijie commented on a change in pull request #712: Issue 544: Bootup cookie
validation considers an empty journal to signify a new bookie
URL: https://github.com/apache/bookkeeper/pull/712#discussion_r150787234
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/Bookie.java
##########
@@ -441,117 +335,187 @@ private void checkIfDirsOnSameDiskPartition(List<File>
dirs) throws DiskPartitio
}
}
+ static Versioned<Cookie> readAndVerifyCookieFromRegistrationManager(Cookie
masterCookie,
+
ServerConfiguration conf,
+
RegistrationManager rm)
+ throws BookieException {
+ // we need to loop through all possible bookie identifiers to ensure
it is treated as a new environment
+ // just because of bad configuration
+ List<BookieSocketAddress> addresses =
Lists.newArrayListWithExpectedSize(3);
+ try {
+ // ip address
+ addresses.add(getBookieAddress(
+ new
ServerConfiguration(conf).setUseHostNameAsBookieID(false).setAdvertisedAddress(null)));
+ // host name
+ addresses.add(getBookieAddress(
+ new
ServerConfiguration(conf).setUseHostNameAsBookieID(true).setAdvertisedAddress(null)));
+ // advertised address
+ if (null != conf.getAdvertisedAddress()) {
+ addresses.add(getBookieAddress(conf));
+ }
+ } catch (UnknownHostException e) {
+ throw new UnknownBookieIdException(e);
+ }
+ Versioned<Cookie> rmCookie = null;
+ for (BookieSocketAddress address : addresses) {
+ try {
+ rmCookie = Cookie.readFromRegistrationManager(rm, address);
+ // If allowStorageExpansion option is set, we should
+ // make sure that the new set of ledger/index dirs
+ // is a super set of the old; else, we fail the cookie check
+ if (conf.getAllowStorageExpansion()) {
+ masterCookie.verifyIsSuperSet(rmCookie.getValue());
+ } else {
+ masterCookie.verify(rmCookie.getValue());
+ }
+ } catch (CookieNotFoundException e) {
+ continue;
+ }
+ }
+ return rmCookie;
+ }
+
+ private static Pair<List<File>, List<Cookie>>
verifyAndGetMissingDirs(Cookie masterCookie,
Review comment:
if a new directory was not written with a cookie during storage expansion.
the storage expansion will continue to fix it eventually. if an existing dir's
cookie is not updated during storage expansion, there are two cases : 1) a
bookie starts again without expansion, that the verification will fail 2) a
bookie starts again with expansion, it is okay to continue as well because the
master cookie and rm cookie validation is still valid (because of the
superset). that's still a healthy environment.
----------------------------------------------------------------
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