ivankelly 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_r150923743
 
 

 ##########
 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);
 
 Review comment:
   Say you have bookie, ip is 10.0.0.1, hostname is foobar.
   
   First boot it comes up with setUseHostNameAsBookieID(false), writes its 
cookie to /ledgers/cookies/10.0.0.1:3181.
   On second boot, some disks are added, allow expansion is enabled and 
setUseHostNameAsBookieID is set to true. In this case, it reads a cookie from 
/ledgers/cookies/10.0.0.1:3181, updates the cookie for the new storage, writes 
to all the dirs and then tries to write the cookie to 
/ledgers/cookies/foobar:3181. However, this last write, it will use the version 
it read from  /ledgers/cookies/10.0.0.1:3181, which is wrong (it shouldn't even 
be a setData, it should be a create).

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to