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

 ##########
 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 out of curiosity - any reason that you don't do 
"initialWritableBookiesFuture = ...watchWritableBookies"?
   

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