Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-16 Thread via GitHub


shoothzj commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1603202029


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BookKeeper.java:
##
@@ -81,6 +81,13 @@ static BookKeeperBuilder newBuilder(final 
ClientConfiguration clientConfiguratio
  */
 CompletableFuture getLedgerMetadata(long ledgerId);
 
+/**
+ * Return driver metadata service is available.
+ *
+ * @return the metadata service is available.
+ */
+CompletableFuture isDriverMetadataServiceAvailable();

Review Comment:
   @zymap This default interface might be error prone. I have started a mail 
thread. I think we can continue discuss in 
https://lists.apache.org/thread/fk02bz4lggz086kgwwxdw2yv1ktn7x35 
   



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-16 Thread via GitHub


zymap commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1603023972


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BookKeeper.java:
##
@@ -81,6 +81,13 @@ static BookKeeperBuilder newBuilder(final 
ClientConfiguration clientConfiguratio
  */
 CompletableFuture getLedgerMetadata(long ledgerId);
 
+/**
+ * Return driver metadata service is available.
+ *
+ * @return the metadata service is available.
+ */
+CompletableFuture isDriverMetadataServiceAvailable();

Review Comment:
   Since it is not a required thing for the bookkeeper. I think it should be ok 
to implement a default handle. @shoothzj 



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-07 Thread via GitHub


congbobo184 commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1593328468


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java:
##
@@ -247,6 +256,19 @@ protected void initialize(AbstractConfiguration conf,
 acls);
 }
 
+private synchronized void handleState(Watcher.Event.KeeperState 
zkClientState) {
+switch (zkClientState) {
+case Expired:
+case Disconnected:
+this.metadataServiceAvailable = false;
+break;
+

Review Comment:
   sorry, I thought it was to delete break 



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-07 Thread via GitHub


shoothzj commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1593310578


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java:
##
@@ -247,6 +256,19 @@ protected void initialize(AbstractConfiguration conf,
 acls);
 }
 
+private synchronized void handleState(Watcher.Event.KeeperState 
zkClientState) {
+switch (zkClientState) {
+case Expired:
+case Disconnected:
+this.metadataServiceAvailable = false;
+break;
+

Review Comment:
   @congbobo184 line 256 blank line?



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-07 Thread via GitHub


congbobo184 commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1593307515


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java:
##
@@ -247,6 +256,19 @@ protected void initialize(AbstractConfiguration conf,
 acls);
 }
 
+private synchronized void handleState(Watcher.Event.KeeperState 
zkClientState) {
+switch (zkClientState) {
+case Expired:
+case Disconnected:
+this.metadataServiceAvailable = false;
+break;
+

Review Comment:
   why remove this? change metadataServiceAvailable twice? @shoothzj 
   



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-07 Thread via GitHub


congbobo184 commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1593307515


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java:
##
@@ -247,6 +256,19 @@ protected void initialize(AbstractConfiguration conf,
 acls);
 }
 
+private synchronized void handleState(Watcher.Event.KeeperState 
zkClientState) {
+switch (zkClientState) {
+case Expired:
+case Disconnected:
+this.metadataServiceAvailable = false;
+break;
+

Review Comment:
   why remove this? change metadataServiceAvailable twice?



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-07 Thread via GitHub


congbobo184 commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1592446786


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java:
##
@@ -247,6 +256,19 @@ protected void initialize(AbstractConfiguration conf,
 acls);
 }
 
+private synchronized void handleState(Watcher.Event.KeeperState 
zkClientState) {

Review Comment:
   
https://github.com/apache/bookkeeper/blob/c4fa8c20131fb5e52b7448ee6ee1491bf9e870fa/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataClientDriver.java#L57
   because this line add synchronized
   
https://github.com/apache/bookkeeper/blob/c4fa8c20131fb5e52b7448ee6ee1491bf9e870fa/bookkeeper-server/src/main/java/org/apache/bookkeeper/zookeeper/ZooKeeperClient.java#L260
   this line is sync method, so I remove the synchronized.
   this interface is not a consistent method, I think add volatile is enough
   
   what do you think? @eolivelli 



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-07 Thread via GitHub


congbobo184 commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1592446786


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java:
##
@@ -247,6 +256,19 @@ protected void initialize(AbstractConfiguration conf,
 acls);
 }
 
+private synchronized void handleState(Watcher.Event.KeeperState 
zkClientState) {

Review Comment:
   
https://github.com/apache/bookkeeper/blob/c4fa8c20131fb5e52b7448ee6ee1491bf9e870fa/bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataClientDriver.java#L57
   because this line add synchronized
   
https://github.com/apache/bookkeeper/blob/c4fa8c20131fb5e52b7448ee6ee1491bf9e870fa/bookkeeper-server/src/main/java/org/apache/bookkeeper/zookeeper/ZooKeeperClient.java#L260
   this line is sync method, so I remove the synchronized.
   this interface is not a consistent method, I think add volatile is enough 



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-07 Thread via GitHub


congbobo184 commented on PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#issuecomment-2098209516

   rerun failure checks


-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-07 Thread via GitHub


congbobo184 commented on PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#issuecomment-2098192763

   rerun failure checks


-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-06 Thread via GitHub


shoothzj commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1591777510


##
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/api/DriverMetadataServiceAvailableTest.java:
##
@@ -0,0 +1,53 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.bookkeeper.client.api;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.bookkeeper.conf.ClientConfiguration;
+import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
+import org.awaitility.Awaitility;
+import org.junit.Test;
+
+/**
+ * Bookkeeper Client API driver metadata service available test.
+ */
+public class DriverMetadataServiceAvailableTest extends 
BookKeeperClusterTestCase {
+

Review Comment:
   nit: we only need one blank space here.



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-06 Thread via GitHub


shoothzj commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r159148


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BookKeeper.java:
##
@@ -81,6 +81,13 @@ static BookKeeperBuilder newBuilder(final 
ClientConfiguration clientConfiguratio
  */
 CompletableFuture getLedgerMetadata(long ledgerId);
 
+/**
+ * Return driver metadata service is available.
+ *
+ * @return the metadata service is available.
+ */
+CompletableFuture isDriverMetadataServiceAvailable();

Review Comment:
   I doubt that add default implementation is a good idea. First, we don't 
guarantee/make ABI comptabile between minor releases; Second, People whole 
implement metadata driver should implement this.
   
   cc @eolivelli @dlg99 
   



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-06 Thread via GitHub


zymap commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1591761669


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BookKeeper.java:
##
@@ -81,6 +81,13 @@ static BookKeeperBuilder newBuilder(final 
ClientConfiguration clientConfiguratio
  */
 CompletableFuture getLedgerMetadata(long ledgerId);
 
+/**
+ * Return driver metadata service is available.
+ *
+ * @return the metadata service is available.
+ */
+CompletableFuture isDriverMetadataServiceAvailable();

Review Comment:
   Add a default implementation to avoid breaking the interface



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-06 Thread via GitHub


shoothzj commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1590949030


##
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/api/DriverMetadataServiceAvailableTest.java:
##
@@ -0,0 +1,54 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ */
+package org.apache.bookkeeper.client.api;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import org.apache.bookkeeper.conf.ClientConfiguration;
+import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
+import org.awaitility.Awaitility;
+import org.junit.Test;
+
+/**
+ * Bookkeeper Client API driver metadata service available test.
+ */
+public class DriverMetadataServiceAvailableTest extends 
BookKeeperClusterTestCase {
+
+
+public DriverMetadataServiceAvailableTest() {
+super(3);
+}
+
+@Test
+public void testDriverMetadataServiceAvailable()
+throws Exception {
+

Review Comment:
   nits: redundant blank line



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-06 Thread via GitHub


shoothzj commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1590948516


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java:
##
@@ -64,6 +66,8 @@
 public class ZKMetadataDriverBase implements AutoCloseable {
 
 protected static final String SCHEME = "zk";
+
+protected volatile boolean metadataServiceAvailable;

Review Comment:
   nits: add blank line after



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-06 Thread via GitHub


shoothzj commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1590948279


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/zk/ZKMetadataDriverBase.java:
##
@@ -247,6 +256,19 @@ protected void initialize(AbstractConfiguration conf,
 acls);
 }
 
+private synchronized void handleState(Watcher.Event.KeeperState 
zkClientState) {
+switch (zkClientState) {
+case Expired:
+case Disconnected:
+this.metadataServiceAvailable = false;
+break;
+

Review Comment:
   @congbobo184 looks like line break is not removed?



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



Re: [PR] [client] new API to check if Bookkeeper client is connected to metadata service [bookkeeper]

2024-05-06 Thread via GitHub


shoothzj commented on code in PR #4342:
URL: https://github.com/apache/bookkeeper/pull/4342#discussion_r1590947324


##
bookkeeper-server/src/main/java/org/apache/bookkeeper/client/api/BookKeeper.java:
##
@@ -81,6 +81,12 @@ static BookKeeperBuilder newBuilder(final 
ClientConfiguration clientConfiguratio
  */
 CompletableFuture getLedgerMetadata(long ledgerId);
 
+/**
+ * Return driver metadata service is available.
+ *
+ * @return the metadata service is available.
+ */
+CompletableFuture isDriverMetadataServiceAvailable();

Review Comment:
   nits: add a blank line



-- 
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: commits-unsubscr...@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org