reddycharan commented on a change in pull request #1100: Improve decomission 
test
URL: https://github.com/apache/bookkeeper/pull/1100#discussion_r165711899
 
 

 ##########
 File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
 ##########
 @@ -1430,19 +1432,44 @@ public void triggerAudit()
     public void decommissionBookie(BookieSocketAddress bookieAddress)
             throws CompatibilityException, UnavailableException, 
KeeperException, InterruptedException, IOException,
             BKAuditException, TimeoutException, BKException {
+        int maxSleepTimeInBetweenChecks = 10 * 60 * 1000; // 10 minutes
+        int sleepTimePerLedger = 10 * 1000; // 10 secs
+
+        decommissionBookie(
+            bookieAddress,
+            // default wait strategy is to sleep for 30 secs.
+            // so that Auditor gets chance to trigger its
+            // force audittask and let the underreplicationmanager process
+            // to do its replication process
+            () -> {
+                Thread.sleep(30 * 1000);
+                return null;
+            },
+            sleepTimePerLedger,
+            maxSleepTimeInBetweenChecks);
+    }
+
+    @VisibleForTesting
+    public void decommissionBookie(BookieSocketAddress bookieAddress,
+                                   Callable<Void> waitAuditorStrategy,
+                                   int sleepTimePerLedger,
+                                   int maxSleepTimeInBetweenChecks)
+            throws CompatibilityException, UnavailableException, 
KeeperException, InterruptedException, IOException,
+            BKAuditException, TimeoutException, BKException {
         if (getAvailableBookies().contains(bookieAddress) || 
getReadOnlyBookies().contains(bookieAddress)) {
             LOG.error("Bookie: {} is not shutdown yet", bookieAddress);
             throw BKException.create(BKException.Code.IllegalOpException);
         }
 
         triggerAudit();
 
-        /*
-         * Sleep for 30 secs, so that Auditor gets chance to trigger its
-         * force audittask and let the underreplicationmanager process
-         * to do its replication process
-         */
-        Thread.sleep(30 * 1000);
+        try {
+            waitAuditorStrategy.call();
+        } catch (InterruptedException ie) {
+            throw ie;
+        } catch (Exception e) {
+            throw new TimeoutException("Encountered exception on waiting 
auditor auditing the bookies");
 
 Review comment:
   not sure if the TimeoutException is the appropriate one in this case.

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