ivankelly commented on a change in pull request #775: Tests wait for client to 
see started bookie
URL: https://github.com/apache/bookkeeper/pull/775#discussion_r153082706
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookieWatcher.java
 ##########
 @@ -138,17 +142,36 @@ private synchronized void 
processReadOnlyBookiesChanged(Set<BookieSocketAddress>
      *
      * @throws BKException when failed to read bookies
      */
-    public void readBookiesBlocking() throws BKException {
-        this.registrationClient.watchReadOnlyBookies(bookies -> 
processReadOnlyBookiesChanged(bookies.getValue()));
-        this.registrationClient.watchWritableBookies(bookies -> 
processWritableBookiesChanged(bookies.getValue()));
+    public void initialBlockingBookieRead() throws BKException {
+        synchronized (this) {
+            if (initialReadonlyBookiesFuture == null
+                && initialWritableBookiesFuture == null) {
+                CompletableFuture<?> writable
+                    = this.registrationClient.watchWritableBookies(
+                            bookies -> 
processWritableBookiesChanged(bookies.getValue()));
+
+                CompletableFuture<?> readonly
+                    = this.registrationClient.watchReadOnlyBookies(
+                            bookies -> 
processReadOnlyBookiesChanged(bookies.getValue()));
+                initialWritableBookiesFuture = writable;
 
 Review comment:
   Just being defensive. I want to either assign either both or neither. Also, 
I need readonly and writable in any case to avoid hitting synchronization 
errors in findbugs.

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

Reply via email to