eolivelli commented on a change in pull request #2947:
URL: https://github.com/apache/bookkeeper/pull/2947#discussion_r777217174



##########
File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MetadataBookieDriver.java
##########
@@ -68,6 +71,29 @@ LedgerManagerFactory getLedgerManagerFactory()
      */
     LayoutManager getLayoutManager();
 
+    /**
+     * Return health check is enable or disable.
+     *
+     * @return true if health check is enable, otherwise false.
+     */
+    default CompletableFuture<Boolean>  isHealthCheckEnabled() {
+        return FutureUtils.value(true);
+    }
+
+    /**
+     * Disable health check.
+     */
+    default CompletableFuture<Void> disableHealthCheck() {

Review comment:
       Why do we need this method on the bookie driver?

##########
File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/MetadataClientDriver.java
##########
@@ -103,4 +105,28 @@ LedgerManagerFactory getLedgerManagerFactory()
      *            listener listening on metadata client session states.
      */
     void setSessionStateListener(SessionStateListener sessionStateListener);
+
+    /**
+     * Return health check is enable or disable.
+     *
+     * @return true if health check is enable, otherwise false.
+     */
+    default CompletableFuture<Boolean> isHealthCheckEnabled() {
+        return FutureUtils.value(true);
+    }
+
+    /**
+     * Disable health check.
+     */
+    default CompletableFuture<Void> disableHealthCheck() {
+        return FutureUtils.Void();

Review comment:
       I thought  more about this.
   Probably it is better to report an error by default in this method for 
drivers that do not support this feature.
   Otherwise people will think that they disabled the health check but they 
actually didn't 

##########
File path: 
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
##########
@@ -614,8 +614,24 @@ public void safeRun() {
         }
     }
 
-    void checkForFaultyBookies() {
+    void checkForFaultyBookies()  {
         List<BookieId> faultyBookies = bookieClient.getFaultyBookies();
+        if (faultyBookies.isEmpty()) {
+            return;
+        }
+
+        boolean isEnable = true;
+        try {
+            isEnable = metadataDriver.isHealthCheckEnabled().get();
+        } catch (Exception e) {

Review comment:
       Please don't catch raw Exception.
   If reading from ZK fails it is likely that we won't be able to move forward 
in the following lines, so it is better to easly exist.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to