You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by si...@apache.org on 2018/02/03 17:32:32 UTC

[bookkeeper] branch master updated: Cleanup registration client interface

This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new 1286970  Cleanup registration client interface
1286970 is described below

commit 12869703b90a98a62e4c7692e289ea2ae73cf4b1
Author: Sijie Guo <si...@apache.org>
AuthorDate: Sat Feb 3 09:32:25 2018 -0800

    Cleanup registration client interface
    
    Descriptions of the changes in this PR:
    
    This change is mainly to remove `zookeeper` reference from metadata interface. The existence of `Optional<ZooKeeper>` is to allow passing an external zookeeper client to bookkeeper, so bookkeeper can reuse that client instance. That is useful for services like pulsar broker, which they can only instantiate a zookeeper client and pass the zookeeper client around to construct bookkeeper client. However, this pollutes the registration client interface, change the method to `Optional<Obje [...]
    
    Author: Sijie Guo <si...@apache.org>
    
    Reviewers: Enrico Olivelli <eo...@gmail.com>, Jia Zhai <None>
    
    This closes #1116 from sijie/clean_registration_client_interface
---
 .../java/org/apache/bookkeeper/discover/RegistrationClient.java   | 5 ++---
 .../java/org/apache/bookkeeper/discover/ZKRegistrationClient.java | 8 +++++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/RegistrationClient.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/RegistrationClient.java
index b22311f..7b18325 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/RegistrationClient.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/RegistrationClient.java
@@ -30,7 +30,6 @@ import org.apache.bookkeeper.meta.LayoutManager;
 import org.apache.bookkeeper.net.BookieSocketAddress;
 import org.apache.bookkeeper.stats.StatsLogger;
 import org.apache.bookkeeper.versioning.Versioned;
-import org.apache.zookeeper.ZooKeeper;
 
 /**
  * A registration client, which the bookkeeper client will use to interact with registration service.
@@ -55,13 +54,13 @@ public interface RegistrationClient extends AutoCloseable {
      *
      * @param conf client configuration
      * @param statsLogger stats logger
-     * @param zkOptional a supplier to supply zookeeper client.
+     * @param optionalCtx optional context is passed for initialization.
      * @return
      */
     RegistrationClient initialize(ClientConfiguration conf,
                                   ScheduledExecutorService scheduler,
                                   StatsLogger statsLogger,
-                                  Optional<ZooKeeper> zkOptional)
+                                  Optional<Object> optionalCtx)
         throws BKException;
 
     @Override
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationClient.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationClient.java
index 36c38dd..6633d9c 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationClient.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/discover/ZKRegistrationClient.java
@@ -197,7 +197,7 @@ public class ZKRegistrationClient implements RegistrationClient {
     public RegistrationClient initialize(ClientConfiguration conf,
                                          ScheduledExecutorService scheduler,
                                          StatsLogger statsLogger,
-                                         Optional<ZooKeeper> zkOptional)
+                                         Optional<Object> zkOptional)
             throws BKException {
         this.conf = conf;
         this.scheduler = scheduler;
@@ -208,8 +208,10 @@ public class ZKRegistrationClient implements RegistrationClient {
         this.acls = ZkUtils.getACLs(conf);
 
         // construct the zookeeper
-        if (zkOptional.isPresent()) {
-            this.zk = zkOptional.get();
+        if (zkOptional.isPresent()
+            && zkOptional.get() instanceof ZooKeeper) {
+            // if an external zookeeper is added, use the zookeeper instance
+            this.zk = (ZooKeeper) (zkOptional.get());
             this.ownZKHandle = false;
         } else {
             try {

-- 
To stop receiving notification emails like this one, please contact
sijie@apache.org.