eolivelli commented on a change in pull request #2947:
URL: https://github.com/apache/bookkeeper/pull/2947#discussion_r783737778
##########
File path:
bookkeeper-common/src/main/java/org/apache/bookkeeper/common/util/SafeRunnable.java
##########
@@ -39,7 +40,7 @@ default void run() {
}
}
- void safeRun();
+ void safeRun() throws ExecutionException, InterruptedException;
Review comment:
please don't change safeRun this way.
it is a core utility, there is no need to change this here:in any case you
can catch your exception and handle them properly. This code is generic and the
caller could not react correctly to exceptions, so it is useless to say that
the method may throw checked exceptions
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
##########
@@ -606,16 +607,26 @@ void
scheduleBookieHealthCheckIfEnabled(ClientConfiguration conf) {
scheduler.scheduleAtFixedRate(new SafeRunnable() {
@Override
- public void safeRun() {
+ public void safeRun() throws ExecutionException,
InterruptedException {
checkForFaultyBookies();
}
}, conf.getBookieHealthCheckIntervalSeconds(),
conf.getBookieHealthCheckIntervalSeconds(),
TimeUnit.SECONDS);
}
}
- void checkForFaultyBookies() {
+ void checkForFaultyBookies() throws ExecutionException,
InterruptedException {
List<BookieId> faultyBookies = bookieClient.getFaultyBookies();
+ if (faultyBookies.isEmpty()) {
+ return;
+ }
+
+ boolean isEnable = metadataDriver.isHealthCheckEnabled().get();
Review comment:
you can catch "ExecutionException, InterruptedException" here and do not
add the throws clause to checkForFaultyBookies()
##########
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() throws Exception {
Review comment:
methods that return CompletableFuture should not throw Exceptions.
you have to return a failed CompletableFuture
--
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]