eolivelli commented on a change in pull request #2947:
URL: https://github.com/apache/bookkeeper/pull/2947#discussion_r774907915
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java
##########
@@ -260,6 +268,46 @@ public synchronized LedgerManagerFactory
getLedgerManagerFactory()
return lmFactory;
}
+ public CompletableFuture<Void> disableHealthCheck() {
+ CompletableFuture<Void> createResult = new CompletableFuture<>();
+ try {
+ zk.create(disableHealthCheckPath,
BookKeeperConstants.EMPTY_BYTE_ARRAY, acls, CreateMode.PERSISTENT);
Review comment:
it is better to use the async API of ZooKeeper, this is why I told you
about using CompletableFuture
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java
##########
@@ -260,6 +268,46 @@ public synchronized LedgerManagerFactory
getLedgerManagerFactory()
return lmFactory;
}
+ public CompletableFuture<Void> disableHealthCheck() {
+ CompletableFuture<Void> createResult = new CompletableFuture<>();
+ try {
+ zk.create(disableHealthCheckPath,
BookKeeperConstants.EMPTY_BYTE_ARRAY, acls, CreateMode.PERSISTENT);
+ createResult.complete(null);
+ } catch (KeeperException.NodeExistsException nodeExistsException) {
+ log.debug("health check already disable!");
+ createResult.complete(null);
+ } catch (Exception e) {
+ createResult.completeExceptionally(e);
+ }
+ return createResult;
+ }
+
+ public CompletableFuture<Void> enableHealthCheck() {
+ CompletableFuture<Void> deleteResult = new CompletableFuture<>();
+
+ try {
+ zk.delete(disableHealthCheckPath, -1);
+ deleteResult.complete(null);
+ } catch (KeeperException.NoNodeException noNodeException) {
+ log.debug("health check already enabled!");
+ deleteResult.complete(null);
+ } catch (Exception e) {
+ deleteResult.completeExceptionally(e);
+ }
+ return deleteResult;
+ }
+
+ public CompletableFuture<Boolean> isHealthCheckEnabled() {
+ CompletableFuture<Boolean> enableResult = new CompletableFuture<>();
+ try {
+ boolean isEnable = (null == zk.exists(disableHealthCheckPath,
false));
Review comment:
please use the async API
##########
File path:
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java
##########
@@ -260,6 +268,46 @@ public synchronized LedgerManagerFactory
getLedgerManagerFactory()
return lmFactory;
}
+ public CompletableFuture<Void> disableHealthCheck() {
+ CompletableFuture<Void> createResult = new CompletableFuture<>();
+ try {
+ zk.create(disableHealthCheckPath,
BookKeeperConstants.EMPTY_BYTE_ARRAY, acls, CreateMode.PERSISTENT);
+ createResult.complete(null);
+ } catch (KeeperException.NodeExistsException nodeExistsException) {
+ log.debug("health check already disable!");
+ createResult.complete(null);
+ } catch (Exception e) {
+ createResult.completeExceptionally(e);
+ }
+ return createResult;
+ }
+
+ public CompletableFuture<Void> enableHealthCheck() {
+ CompletableFuture<Void> deleteResult = new CompletableFuture<>();
+
+ try {
+ zk.delete(disableHealthCheckPath, -1);
Review comment:
please use the async API
--
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]