sijie closed pull request #1694:  autorecovery-use-metadata-driver (part 2) : 
remove ZooKeeper from ReplicationWorker
URL: https://github.com/apache/bookkeeper/pull/1694
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
index 3369de8b3d..b43ff850e6 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/AutoRecoveryMain.java
@@ -91,7 +91,6 @@ public AutoRecoveryMain(ServerConfiguration conf, StatsLogger 
statsLogger)
             getZooKeeperFromMetadataDriver(metadataBookieDriver),
             statsLogger.scope(AUDITOR_SCOPE));
         replicationWorker = new ReplicationWorker(
-            getZooKeeperFromMetadataDriver(metadataBookieDriver),
             conf,
             statsLogger.scope(REPLICATION_WORKER_SCOPE));
         deathWatcher = new AutoRecoveryDeathWatcher(this);
diff --git 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
index d5c85f1610..b536fb0972 100644
--- 
a/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
+++ 
b/bookkeeper-server/src/main/java/org/apache/bookkeeper/replication/ReplicationWorker.java
@@ -67,7 +67,6 @@
 import org.apache.bookkeeper.stats.OpStatsLogger;
 import org.apache.bookkeeper.stats.StatsLogger;
 import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooKeeper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -83,7 +82,6 @@
 
     private final LedgerUnderreplicationManager underreplicationManager;
     private final ServerConfiguration conf;
-    private final ZooKeeper zkc;
     private volatile boolean workerRunning = false;
     private final BookKeeperAdmin admin;
     private final LedgerChecker ledgerChecker;
@@ -107,16 +105,13 @@
      * UnderReplicationManager to the targetBookie. This target bookie will be 
a
      * local bookie.
      *
-     * @param zkc
-     *            - ZK instance
      * @param conf
      *            - configurations
      */
-    public ReplicationWorker(final ZooKeeper zkc,
-                             final ServerConfiguration conf)
+    public ReplicationWorker(final ServerConfiguration conf)
             throws CompatibilityException, KeeperException,
             InterruptedException, IOException {
-        this(zkc, conf, NullStatsLogger.INSTANCE);
+        this(conf, NullStatsLogger.INSTANCE);
     }
 
     /**
@@ -124,19 +119,15 @@ public ReplicationWorker(final ZooKeeper zkc,
      * UnderReplicationManager to the targetBookie. This target bookie will be 
a
      * local bookie.
      *
-     * @param zkc
-     *            - ZK instance
      * @param conf
      *            - configurations
      * @param statsLogger
      *            - stats logger
      */
-    public ReplicationWorker(final ZooKeeper zkc,
-                             final ServerConfiguration conf,
+    public ReplicationWorker(final ServerConfiguration conf,
                              StatsLogger statsLogger)
             throws CompatibilityException, KeeperException,
             InterruptedException, IOException {
-        this.zkc = zkc;
         this.conf = conf;
         try {
             this.bkc = BookKeeper.forConfig(new ClientConfiguration(conf))
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java
index 4e3bda8eba..0668088ed5 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/AuditorPeriodicCheckTest.java
@@ -449,8 +449,7 @@ public void testFailedWriteRecovery() throws Exception {
         // now start the replication workers
         List<ReplicationWorker> l = new ArrayList<ReplicationWorker>();
         for (int i = 0; i < numBookies; i++) {
-            ReplicationWorker rw = new ReplicationWorker(
-                    zkc, bsConfs.get(i), NullStatsLogger.INSTANCE);
+            ReplicationWorker rw = new ReplicationWorker(bsConfs.get(i), 
NullStatsLogger.INSTANCE);
             rw.start();
             l.add(rw);
         }
diff --git 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java
 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java
index e4b1232e77..a4b280a3b7 100644
--- 
a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java
+++ 
b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestReplicationWorker.java
@@ -52,7 +52,6 @@
 import org.apache.bookkeeper.test.BookKeeperClusterTestCase;
 import org.apache.bookkeeper.util.BookKeeperConstants;
 import org.apache.bookkeeper.zookeeper.ZooKeeperClient;
-import org.apache.zookeeper.ZooKeeper;
 import org.junit.Test;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -153,7 +152,7 @@ public void testRWShouldReplicateFragmentsToTargetBookie() 
throws Exception {
             lh.addEntry(data);
         }
 
-        ReplicationWorker rw = new ReplicationWorker(zkc, baseConf);
+        ReplicationWorker rw = new ReplicationWorker(baseConf);
 
         rw.start();
         try {
@@ -198,7 +197,7 @@ public void 
testRWShouldRetryUntilThereAreEnoughBksAvailableForReplication()
         LOG.info("New Bookie addr :" + newBkAddr);
 
         killAllBookies(lh, newBkAddr);
-        ReplicationWorker rw = new ReplicationWorker(zkc, baseConf);
+        ReplicationWorker rw = new ReplicationWorker(baseConf);
 
         rw.start();
         try {
@@ -248,16 +247,12 @@ public void 
test2RWsShouldCompeteForReplicationOf2FragmentsAndCompleteReplicatio
         // Starte RW1
         BookieSocketAddress newBkAddr1 = startNewBookieAndReturnAddress();
         LOG.info("New Bookie addr : {}", newBkAddr1);
-        ReplicationWorker rw1 = new ReplicationWorker(zkc, baseConf);
+        ReplicationWorker rw1 = new ReplicationWorker(baseConf);
 
         // Starte RW2
         BookieSocketAddress newBkAddr2 = startNewBookieAndReturnAddress();
         LOG.info("New Bookie addr : {}", newBkAddr2);
-        ZooKeeper zkc1 = ZooKeeperClient.newBuilder()
-                .connectString(zkUtil.getZooKeeperConnectString())
-                .sessionTimeoutMs(10000)
-                .build();
-        ReplicationWorker rw2 = new ReplicationWorker(zkc1, baseConf);
+        ReplicationWorker rw2 = new ReplicationWorker(baseConf);
         rw1.start();
         rw2.start();
 
@@ -283,7 +278,6 @@ public void 
test2RWsShouldCompeteForReplicationOf2FragmentsAndCompleteReplicatio
         } finally {
             rw1.shutdown();
             rw2.shutdown();
-            zkc1.close();
         }
     }
 
@@ -308,7 +302,7 @@ public void 
testRWShouldCleanTheLedgerFromUnderReplicationIfLedgerAlreadyDeleted
 
         BookieSocketAddress newBkAddr = startNewBookieAndReturnAddress();
         LOG.info("New Bookie addr : {}", newBkAddr);
-        ReplicationWorker rw = new ReplicationWorker(zkc, baseConf);
+        ReplicationWorker rw = new ReplicationWorker(baseConf);
         rw.start();
 
         try {
@@ -363,7 +357,7 @@ public void 
testMultipleLedgerReplicationWithReplicationWorker()
         BookieSocketAddress newBkAddr = startNewBookieAndReturnAddress();
         LOG.info("New Bookie addr : {}", newBkAddr);
 
-        ReplicationWorker rw = new ReplicationWorker(zkc, baseConf);
+        ReplicationWorker rw = new ReplicationWorker(baseConf);
 
         rw.start();
         try {
@@ -419,7 +413,7 @@ public void 
testRWShouldReplicateTheLedgersAfterTimeoutIfLastFragmentIsUR()
 
         // set to 3s instead of default 30s
         baseConf.setOpenLedgerRereplicationGracePeriod("3000");
-        ReplicationWorker rw = new ReplicationWorker(zkc, baseConf);
+        ReplicationWorker rw = new ReplicationWorker(baseConf);
 
         @Cleanup MetadataClientDriver clientDriver = 
MetadataDrivers.getClientDriver(
             URI.create(baseClientConf.getMetadataServiceUri()));
@@ -489,8 +483,8 @@ public void 
testBookiesNotAvailableScenarioForReplicationWorker() throws Excepti
 
         // create couple of replicationworkers
         baseConf.setLockReleaseOfFailedLedgerGracePeriod("500");
-        ReplicationWorker rw1 = new ReplicationWorker(zkc, baseConf);
-        ReplicationWorker rw2 = new ReplicationWorker(zkc, baseConf);
+        ReplicationWorker rw1 = new ReplicationWorker(baseConf);
+        ReplicationWorker rw2 = new ReplicationWorker(baseConf);
 
         @Cleanup
         MetadataClientDriver clientDriver = MetadataDrivers
@@ -610,7 +604,7 @@ public void 
testRWShouldReplicateTheLedgersAfterTimeoutIfLastFragmentIsNotUR()
             lh.addEntry(data);
         }
 
-        ReplicationWorker rw = new ReplicationWorker(zkc, baseConf);
+        ReplicationWorker rw = new ReplicationWorker(baseConf);
 
         baseClientConf.setMetadataServiceUri(zkUtil.getMetadataServiceUri());
 
@@ -660,7 +654,7 @@ public void testRWZKConnectionLost() throws Exception {
                 .sessionTimeoutMs(10000)
                 .build()) {
 
-            ReplicationWorker rw = new ReplicationWorker(zk, baseConf);
+            ReplicationWorker rw = new ReplicationWorker(baseConf);
             rw.start();
             for (int i = 0; i < 10; i++) {
                 if (rw.isRunning()) {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to