You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2020/04/19 14:23:38 UTC

[GitHub] [bookkeeper] mino181295 opened a new pull request #2314: BP-38: Publish Bookie Service Info on Metadata Service

mino181295 opened a new pull request #2314: BP-38: Publish Bookie Service Info on Metadata Service
URL: https://github.com/apache/bookkeeper/pull/2314
 
 
   Starting from the implementation of the #2213 PR 
   
   ### Changes
   
   - Adding the ability for the Bookie to advertise on the Metadata Service (ZooKeeper) the exposed ports/services, like the HTTP service, Metrics
   - Implemented the Protobuf serialization of the BookieServiceInfo
   - Added the command EndpointInfoCommand
   
   Master Issue: #2215 
   Proposal Doc: https://bookkeeper.apache.org/bps/BP-38-bookie-endpoint-discovery

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [bookkeeper] eolivelli commented on a change in pull request #2314: BP-38: Publish Bookie Service Info on Metadata Service

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #2314: BP-38: Publish Bookie Service Info on Metadata Service
URL: https://github.com/apache/bookkeeper/pull/2314#discussion_r410923116
 
 

 ##########
 File path: bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationClient.java
 ##########
 @@ -212,6 +219,90 @@ public ZooKeeper getZk() {
         return getChildren(bookieReadonlyRegistrationPath, null);
     }
 
+    @Override
+    public CompletableFuture<Versioned<BookieServiceInfo>> getBookieServiceInfo(String bookieId) {
+        String pathAsWritable = bookieRegistrationPath + "/" + bookieId;
+        String pathAsReadonly = bookieReadonlyRegistrationPath + "/" + bookieId;
+
+        CompletableFuture<Versioned<BookieServiceInfo>> promise = new CompletableFuture<>();
+        zk.getData(pathAsWritable, false, (int rc, String path, Object o, byte[] bytes, Stat stat) -> {
+            if (KeeperException.Code.OK.intValue() == rc) {
+                try {
+                    BookieServiceInfo bookieServiceInfo = deserializeBookieService(bytes);
+                    promise.complete(new Versioned<>(bookieServiceInfo, new LongVersion(stat.getCversion())));
+                } catch (IOException ex) {
+                    promise.completeExceptionally(KeeperException.create(KeeperException.Code.get(rc), path));
+                    return;
+                }
+            } else if (KeeperException.Code.NONODE.intValue() == rc) {
+                // not found, looking for a readonly bookie
+                zk.getData(pathAsReadonly, false, (int rc2, String path2, Object o2, byte[] bytes2, Stat stat2) -> {
+                    if (KeeperException.Code.OK.intValue() == rc2) {
+                        try {
+                            BookieServiceInfo bookieServiceInfo = deserializeBookieService(bytes2);
+                            promise.complete(new Versioned<>(bookieServiceInfo, new LongVersion(stat2.getCversion())));
+                        } catch (IOException ex) {
+                            promise.completeExceptionally(KeeperException.create(KeeperException.Code.get(rc2), path2));
+                            return;
+                        }
+                    } else if (KeeperException.Code.NONODE.intValue() == rc2) {
+                        // not found as readonly, the bookie is offline
+                        // return an empty BookieServiceInfoStructure
+                        BookieSocketAddress address = null;
+                        try {
+                            address = new BookieSocketAddress(bookieId);
+                        } catch (UnknownHostException err) {
+                            promise.completeExceptionally(KeeperException.create(KeeperException.Code.get(rc2), path2));
+                            return;
+                        }
+                        BookieServiceInfo.Endpoint endpoint = new BookieServiceInfo.Endpoint();
 
 Review comment:
   This information is wrong.
   Why are you adding it?
   
   The bookie does not exist, you can't say that it is exposing this endpoint.
   It can result in a false configuration 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [bookkeeper] eolivelli commented on a change in pull request #2314: BP-38: Publish Bookie Service Info on Metadata Service

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #2314: BP-38: Publish Bookie Service Info on Metadata Service
URL: https://github.com/apache/bookkeeper/pull/2314#discussion_r410922496
 
 

 ##########
 File path: bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/LifecycleComponentStack.java
 ##########
 @@ -108,8 +121,22 @@ public void removeLifecycleListener(LifecycleListener listener) {
         components.forEach(component -> component.removeLifecycleListener(listener));
     }
 
+    @Override
+    public void publishInfo(ComponentInfoPublisher componentInfoPublisher) {
+        components.forEach(component -> {
+            log.info("calling publishInfo on {} ", component);
+            component.publishInfo(componentInfoPublisher);
+        });
+    }
+
     @Override
     public void start() {
+        components.forEach(component -> {
+            log.info("calling publishInfo on {} ", component);
 
 Review comment:
   Debug 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

[GitHub] [bookkeeper] eolivelli commented on a change in pull request #2314: BP-38: Publish Bookie Service Info on Metadata Service

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #2314: BP-38: Publish Bookie Service Info on Metadata Service
URL: https://github.com/apache/bookkeeper/pull/2314#discussion_r410922418
 
 

 ##########
 File path: bookkeeper-common/src/main/java/org/apache/bookkeeper/common/component/LifecycleComponentStack.java
 ##########
 @@ -108,8 +121,22 @@ public void removeLifecycleListener(LifecycleListener listener) {
         components.forEach(component -> component.removeLifecycleListener(listener));
     }
 
+    @Override
+    public void publishInfo(ComponentInfoPublisher componentInfoPublisher) {
+        components.forEach(component -> {
+            log.info("calling publishInfo on {} ", component);
 
 Review comment:
   Debug

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services