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 2017/12/13 08:51:57 UTC

[GitHub] jiazhai closed pull request #833: Issue 831: move zkServers and zkTimeout into AbstractCofiguration

jiazhai closed pull request #833: Issue 831: move zkServers and zkTimeout into AbstractCofiguration
URL: https://github.com/apache/bookkeeper/pull/833
 
 
   

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/bookie/BookieShell.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
index 1d19a3024..5e72c26bd 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java
@@ -1240,9 +1240,9 @@ public int runCmd(CommandLine cmdLine) throws Exception {
                 printUsage();
                 return 1;
             }
-            ClientConfiguration clientconf = new ClientConfiguration(bkConf)
-                .setZkServers(bkConf.getZkServers());
-            BookKeeperAdmin bka = new BookKeeperAdmin(clientconf);
+            ClientConfiguration clientConf = new ClientConfiguration(bkConf);
+            clientConf.setZkServers(bkConf.getZkServers());
+            BookKeeperAdmin bka = new BookKeeperAdmin(clientConf);
 
             int count = 0;
             Collection<BookieSocketAddress> bookies = new ArrayList<BookieSocketAddress>();
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
index 99e948467..57e0d2a4c 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeper.java
@@ -313,7 +313,7 @@ public static Builder forConfig(final ClientConfiguration conf) {
      */
     public BookKeeper(String servers) throws IOException, InterruptedException,
         BKException {
-        this(new ClientConfiguration().setZkServers(servers));
+        this((ClientConfiguration) (new ClientConfiguration().setZkServers(servers)));
     }
 
     /**
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
index 0d6321f80..09fda4815 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/BookKeeperAdmin.java
@@ -136,7 +136,7 @@
      *             BookKeeper client.
      */
     public BookKeeperAdmin(String zkServers) throws IOException, InterruptedException, BKException {
-        this(new ClientConfiguration().setZkServers(zkServers));
+        this((ClientConfiguration) (new ClientConfiguration().setZkServers(zkServers)));
     }
 
     /**
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
index a5f35ecb1..9f8c503b6 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/AbstractConfiguration.java
@@ -21,6 +21,7 @@
 
 import java.net.URL;
 import java.util.Iterator;
+import java.util.List;
 import javax.net.ssl.SSLEngine;
 import org.apache.bookkeeper.feature.Feature;
 import org.apache.bookkeeper.meta.LedgerManagerFactory;
@@ -29,6 +30,7 @@
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.apache.commons.configuration.SystemConfiguration;
+import org.apache.commons.lang.StringUtils;
 
 /**
  * Abstract configuration.
@@ -51,6 +53,10 @@
         DEFAULT_LOADER = loader;
     }
 
+    // Zookeeper Parameters
+    protected static final String ZK_TIMEOUT = "zkTimeout";
+    protected static final String ZK_SERVERS = "zkServers";
+
     // Ledger Manager
     protected static final String LEDGER_MANAGER_TYPE = "ledgerManagerType";
     protected static final String LEDGER_MANAGER_FACTORY_CLASS = "ledgerManagerFactoryClass";
@@ -133,6 +139,51 @@ public void loadConf(CompositeConfiguration baseConf) {
         }
     }
 
+    /**
+     * Get zookeeper servers to connect.
+     *
+     * @return zookeeper servers
+     */
+    public String getZkServers() {
+        List servers = getList(ZK_SERVERS, null);
+        if (null == servers || 0 == servers.size()) {
+            return null;
+        }
+        return StringUtils.join(servers, ",");
+    }
+
+    /**
+     * Set zookeeper servers to connect.
+     *
+     * @param zkServers
+     *          ZooKeeper servers to connect
+     */
+    public AbstractConfiguration setZkServers(String zkServers) {
+        setProperty(ZK_SERVERS, zkServers);
+        return this;
+    }
+
+    /**
+     * Get zookeeper timeout.
+     *
+     * @return zookeeper server timeout
+     */
+    public int getZkTimeout() {
+        return getInt(ZK_TIMEOUT, 10000);
+    }
+
+    /**
+     * Set zookeeper timeout.
+     *
+     * @param zkTimeout
+     *          ZooKeeper server timeout
+     * @return server configuration
+     */
+    public AbstractConfiguration setZkTimeout(int zkTimeout) {
+        setProperty(ZK_TIMEOUT, Integer.toString(zkTimeout));
+        return this;
+    }
+
     /**
      * Set Ledger Manager Type.
      *
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
index 361a383e5..e5d52ee43 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ClientConfiguration.java
@@ -34,7 +34,6 @@
 import org.apache.bookkeeper.replication.Auditor;
 import org.apache.bookkeeper.util.ReflectionUtils;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.lang.StringUtils;
 
 
 /**
@@ -42,10 +41,6 @@
  */
 public class ClientConfiguration extends AbstractConfiguration {
 
-    // Zookeeper Parameters
-    protected static final String ZK_TIMEOUT = "zkTimeout";
-    protected static final String ZK_SERVERS = "zkServers";
-
     // Throttle value
     protected static final String THROTTLE = "throttle";
 
@@ -530,51 +525,6 @@ public ClientConfiguration setUseV2WireProtocol(boolean useV2WireProtocol) {
         return this;
     }
 
-    /**
-     * Get zookeeper servers to connect.
-     *
-     * @return zookeeper servers
-     */
-    public String getZkServers() {
-        List servers = getList(ZK_SERVERS, null);
-        if (null == servers || 0 == servers.size()) {
-            return "localhost";
-        }
-        return StringUtils.join(servers, ",");
-    }
-
-    /**
-     * Set zookeeper servers to connect.
-     *
-     * @param zkServers
-     *          ZooKeeper servers to connect
-     */
-    public ClientConfiguration setZkServers(String zkServers) {
-        setProperty(ZK_SERVERS, zkServers);
-        return this;
-    }
-
-    /**
-     * Get zookeeper timeout.
-     *
-     * @return zookeeper client timeout
-     */
-    public int getZkTimeout() {
-        return getInt(ZK_TIMEOUT, 10000);
-    }
-
-    /**
-     * Set zookeeper timeout.
-     *
-     * @param zkTimeout
-     *          ZooKeeper client timeout
-     * @return client configuration
-     */
-    public ClientConfiguration setZkTimeout(int zkTimeout) {
-        setProperty(ZK_TIMEOUT, Integer.toString(zkTimeout));
-        return this;
-    }
-
     /**
      * Get the socket read timeout. This is the number of
      * seconds we wait without hearing a response from a bookie
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
index 7ff792c32..19d5df10e 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/conf/ServerConfiguration.java
@@ -18,11 +18,8 @@
 package org.apache.bookkeeper.conf;
 
 import com.google.common.annotations.Beta;
-
 import java.io.File;
-import java.util.List;
 import java.util.concurrent.TimeUnit;
-
 import org.apache.bookkeeper.bookie.InterleavedLedgerStorage;
 import org.apache.bookkeeper.bookie.LedgerStorage;
 import org.apache.bookkeeper.bookie.SortedLedgerStorage;
@@ -33,7 +30,6 @@
 import org.apache.bookkeeper.util.BookKeeperConstants;
 import org.apache.bookkeeper.util.ReflectionUtils;
 import org.apache.commons.configuration.ConfigurationException;
-import org.apache.commons.lang.StringUtils;
 
 /**
  * Configuration manages server-side settings.
@@ -101,8 +97,6 @@
     protected static final String SERVER_SOCK_LINGER = "serverTcpLinger";
 
     // Zookeeper Parameters
-    protected static final String ZK_TIMEOUT = "zkTimeout";
-    protected static final String ZK_SERVERS = "zkServers";
     protected static final String ZK_RETRY_BACKOFF_START_MS = "zkRetryBackoffStartMs";
     protected static final String ZK_RETRY_BACKOFF_MAX_MS = "zkRetryBackoffMaxMs";
     protected static final String OPEN_LEDGER_REREPLICATION_GRACE_PERIOD = "openLedgerRereplicationGracePeriod";
@@ -988,51 +982,6 @@ public ServerConfiguration setServerSockKeepalive(boolean keepalive) {
         return this;
     }
 
-    /**
-     * Get zookeeper servers to connect.
-     *
-     * @return zookeeper servers
-     */
-    public String getZkServers() {
-        List servers = getList(ZK_SERVERS, null);
-        if (null == servers || 0 == servers.size()) {
-            return null;
-        }
-        return StringUtils.join(servers, ",");
-    }
-
-    /**
-     * Set zookeeper servers to connect.
-     *
-     * @param zkServers
-     *          ZooKeeper servers to connect
-     */
-    public ServerConfiguration setZkServers(String zkServers) {
-        setProperty(ZK_SERVERS, zkServers);
-        return this;
-    }
-
-    /**
-     * Get zookeeper timeout.
-     *
-     * @return zookeeper server timeout
-     */
-    public int getZkTimeout() {
-        return getInt(ZK_TIMEOUT, 10000);
-    }
-
-    /**
-     * Set zookeeper timeout.
-     *
-     * @param zkTimeout
-     *          ZooKeeper server timeout
-     * @return server configuration
-     */
-    public ServerConfiguration setZkTimeout(int zkTimeout) {
-        setProperty(ZK_TIMEOUT, Integer.toString(zkTimeout));
-        return this;
-    }
-
     /**
      * Get zookeeper client backoff retry start time in millis.
      *
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/BKHttpServiceProvider.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/BKHttpServiceProvider.java
index a733c508a..461c52070 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/BKHttpServiceProvider.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/BKHttpServiceProvider.java
@@ -84,8 +84,8 @@ private BKHttpServiceProvider(BookieServer bookieServer,
           .sessionTimeoutMs(serverConf.getZkTimeout())
           .build();
 
-        ClientConfiguration clientConfiguration = new ClientConfiguration(serverConf)
-          .setZkServers(serverConf.getZkServers());
+        ClientConfiguration clientConfiguration = new ClientConfiguration(serverConf);
+        clientConfiguration.setZkServers(serverConf.getZkServers());
         this.bka = new BookKeeperAdmin(clientConfiguration);
 
         this.executor = Executors.newSingleThreadExecutor(
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookieInfoService.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookieInfoService.java
index 72897cf42..5da3740d7 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookieInfoService.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/http/service/ListBookieInfoService.java
@@ -81,8 +81,8 @@ public HttpServiceResponse handle(HttpServiceRequest request) throws Exception {
         HttpServiceResponse response = new HttpServiceResponse();
 
         if (HttpServer.Method.GET == request.getMethod()) {
-            ClientConfiguration clientConf = new ClientConfiguration(conf)
-              .setZkServers(conf.getZkServers());
+            ClientConfiguration clientConf = new ClientConfiguration(conf);
+            clientConf.setZkServers(conf.getZkServers());
             clientConf.setDiskWeightBasedPlacementEnabled(true);
             BookKeeper bk = new BookKeeper(clientConf);
 
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/AdvertisedAddressTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/AdvertisedAddressTest.java
index 2f42ca457..d8a8df9b9 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/AdvertisedAddressTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/AdvertisedAddressTest.java
@@ -60,9 +60,11 @@ private String newDirectory(boolean createCurDir) throws IOException {
      */
     @Test
     public void testSetAdvertisedAddress() throws Exception {
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString()).setJournalDirName(newDirectory(false))
-                .setLedgerDirNames(new String[] { newDirectory(false) }).setBookiePort(bookiePort);
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(newDirectory(false))
+            .setLedgerDirNames(new String[] { newDirectory(false) })
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
 
         conf.setAdvertisedAddress("10.0.0.1");
         assertEquals("10.0.0.1", conf.getAdvertisedAddress());
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
index 990c20538..dbb9c3caa 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieInitializationTest.java
@@ -120,9 +120,10 @@ void testRegisterBookie(ServerConfiguration conf) throws IOException {
     public void testExitCodeZK_REG_FAIL() throws Exception {
         File tmpDir = createTempDir("bookie", "test");
 
-        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(null).setJournalDirName(tmpDir.getPath())
-                .setLedgerDirNames(new String[] { tmpDir.getPath() });
+        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(tmpDir.getPath())
+            .setLedgerDirNames(new String[] { tmpDir.getPath() })
+            .setZkServers(null);
 
         // simulating ZooKeeper exception by assigning a closed zk client to bk
         BookieServer bkServer = new BookieServer(conf) {
@@ -148,9 +149,10 @@ protected Bookie newBookie(ServerConfiguration conf)
     public void testBookieRegistrationWithSameZooKeeperClient() throws Exception {
         File tmpDir = createTempDir("bookie", "test");
 
-        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(null).setJournalDirName(tmpDir.getPath())
-                .setLedgerDirNames(new String[] { tmpDir.getPath() });
+        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(tmpDir.getPath())
+            .setLedgerDirNames(new String[] { tmpDir.getPath() })
+            .setZkServers(null);
 
         final String bkRegPath = conf.getZkAvailableBookiesPath() + "/"
                 + InetAddress.getLocalHost().getHostAddress() + ":"
@@ -181,9 +183,10 @@ public void testBookieRegistrationWithSameZooKeeperClient() throws Exception {
     public void testBookieRegistration() throws Exception {
         File tmpDir = createTempDir("bookie", "test");
 
-        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(null).setJournalDirName(tmpDir.getPath())
-                .setLedgerDirNames(new String[] { tmpDir.getPath() });
+        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(tmpDir.getPath())
+            .setLedgerDirNames(new String[] { tmpDir.getPath() })
+            .setZkServers(null);
 
         final String bkRegPath = conf.getZkAvailableBookiesPath() + "/"
                 + InetAddress.getLocalHost().getHostAddress() + ":"
@@ -252,9 +255,10 @@ public void testBookieRegistration() throws Exception {
     public void testRegNodeExistsAfterSessionTimeOut() throws Exception {
         File tmpDir = createTempDir("bookie", "test");
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration().setZkServers(null)
-                .setJournalDirName(tmpDir.getPath()).setLedgerDirNames(
-                        new String[] { tmpDir.getPath() });
+        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(tmpDir.getPath())
+            .setLedgerDirNames(new String[] { tmpDir.getPath() })
+            .setZkServers(null);
 
         String bkRegPath = conf.getZkAvailableBookiesPath() + "/"
                 + InetAddress.getLocalHost().getHostAddress() + ":"
@@ -319,9 +323,10 @@ public void testDuplicateBookieServerStartup() throws Exception {
 
         ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
         int port = PortManager.nextFreePort();
-        conf.setZkServers(null).setBookiePort(port).setJournalDirName(
-                tmpDir.getPath()).setLedgerDirNames(
-                new String[] { tmpDir.getPath() });
+        conf.setBookiePort(port)
+            .setJournalDirName(tmpDir.getPath())
+            .setLedgerDirNames(new String[] { tmpDir.getPath() })
+            .setZkServers(null);
         BookieServer bs1 = new BookieServer(conf);
         conf.setZkServers(zkUtil.getZooKeeperConnectString());
         rm.initialize(conf, () -> {}, NullStatsLogger.INSTANCE);
@@ -358,11 +363,11 @@ public void testBookieServerStartupOnEphemeralPorts() throws Exception {
         File tmpDir2 = createTempDir("bookie", "test2");
 
         ServerConfiguration conf1 = TestBKConfiguration.newServerConfiguration();
-        conf1.setZkServers(null)
-            .setBookiePort(0)
+        conf1.setBookiePort(0)
             .setJournalDirName(tmpDir1.getPath())
             .setLedgerDirNames(
-                new String[] { tmpDir1.getPath() });
+                new String[] { tmpDir1.getPath() })
+            .setZkServers(null);
         assertEquals(0, conf1.getBookiePort());
         BookieServer bs1 = new BookieServer(conf1);
         conf1.setZkServers(zkUtil.getZooKeeperConnectString());
@@ -373,11 +378,11 @@ public void testBookieServerStartupOnEphemeralPorts() throws Exception {
 
         // starting bk server with same conf
         ServerConfiguration conf2 = TestBKConfiguration.newServerConfiguration();
-        conf2.setZkServers(null)
-            .setBookiePort(0)
+        conf2.setBookiePort(0)
             .setJournalDirName(tmpDir2.getPath())
             .setLedgerDirNames(
-                new String[] { tmpDir2.getPath() });
+                new String[] { tmpDir2.getPath() })
+            .setZkServers(null);
         BookieServer bs2 = new BookieServer(conf2);
         RegistrationManager newRm = new ZKRegistrationManager();
         newRm.initialize(conf2, () -> {}, NullStatsLogger.INSTANCE);
@@ -399,9 +404,10 @@ public void testStartBookieWithoutZKServer() throws Exception {
         File tmpDir = createTempDir("bookie", "test");
 
         final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setZkTimeout(5000).setJournalDirName(tmpDir.getPath())
+                .setJournalDirName(tmpDir.getPath())
                 .setLedgerDirNames(new String[] { tmpDir.getPath() });
+        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000);
+
         try {
             new Bookie(conf);
             fail("Should throw ConnectionLossException as ZKServer is not running!");
@@ -420,9 +426,10 @@ public void testStartBookieWithoutZKInitialized() throws Exception {
         final String zkRoot = "/ledgers2";
 
         final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setZkTimeout(5000).setJournalDirName(tmpDir.getPath())
+            .setJournalDirName(tmpDir.getPath())
             .setLedgerDirNames(new String[] { tmpDir.getPath() });
+        conf.setZkServers(zkUtil.getZooKeeperConnectString())
+            .setZkTimeout(5000);
         conf.setZkLedgersRootPath(zkRoot);
         try {
             new Bookie(conf);
@@ -448,12 +455,13 @@ public void testWithDiskFullReadOnlyDisabledOrForceGCAllowDisabled() throws Exce
         long usableSpace = tmpDir.getUsableSpace();
         long totalSpace = tmpDir.getTotalSpace();
         final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setZkTimeout(5000).setJournalDirName(tmpDir.getPath())
+                .setJournalDirName(tmpDir.getPath())
                 .setLedgerDirNames(new String[] { tmpDir.getPath() })
                 .setDiskCheckInterval(1000)
                 .setDiskUsageThreshold((1.0f - ((float) usableSpace / (float) totalSpace)) * 0.999f)
                 .setDiskUsageWarnThreshold(0.0f);
+        conf.setZkServers(zkUtil.getZooKeeperConnectString())
+            .setZkTimeout(5000);
 
         // if isForceGCAllowWhenNoSpace or readOnlyModeEnabled is not set and Bookie is
         // started when Disk is full, then it will fail to start with NoWritableLedgerDirException
@@ -495,12 +503,13 @@ public void testWithDiskFullReadOnlyEnabledAndForceGCAllowAllowed() throws Excep
         long usableSpace = tmpDir.getUsableSpace();
         long totalSpace = tmpDir.getTotalSpace();
         final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setZkTimeout(5000).setJournalDirName(tmpDir.getPath())
+                .setJournalDirName(tmpDir.getPath())
                 .setLedgerDirNames(new String[] { tmpDir.getPath() })
                 .setDiskCheckInterval(1000)
                 .setDiskUsageThreshold((1.0f - ((float) usableSpace / (float) totalSpace)) * 0.999f)
                 .setDiskUsageWarnThreshold(0.0f);
+        conf.setZkServers(zkUtil.getZooKeeperConnectString())
+            .setZkTimeout(5000);
 
         // if isForceGCAllowWhenNoSpace and readOnlyModeEnabled are set, then Bookie should
         // start with readonlymode when Disk is full (assuming there is no need for creation of index file
@@ -553,9 +562,10 @@ public void testWithDiskFullAndAbilityToCreateNewIndexFile() throws Exception {
         File tmpDir = createTempDir("DiskCheck", "test");
 
         final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000).setJournalDirName(tmpDir.getPath())
+                .setJournalDirName(tmpDir.getPath())
                 .setLedgerDirNames(new String[] { tmpDir.getPath() }).setDiskCheckInterval(1000)
                 .setLedgerStorageClass(SortedLedgerStorage.class.getName()).setAutoRecoveryDaemonEnabled(false);
+        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000);
 
         BookieServer server = new MockBookieServer(conf);
         server.start();
@@ -613,9 +623,10 @@ public void testWithDiskError() throws Exception {
         File parent = createTempDir("DiskCheck", "test");
         File child = File.createTempFile("DiskCheck", "test", parent);
         final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setZkTimeout(5000).setJournalDirName(child.getPath())
+                .setJournalDirName(child.getPath())
                 .setLedgerDirNames(new String[] { child.getPath() });
+        conf.setZkServers(zkUtil.getZooKeeperConnectString())
+            .setZkTimeout(5000);
         try {
             // LedgerDirsManager#init() is used in Bookie instantiation.
             // Simulating disk errors by directly calling #init
@@ -642,7 +653,8 @@ public void testAllowDiskPartitionDuplicationDisabled() throws Exception {
         ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
         int port = PortManager.nextFreePort();
         // multiple ledgerdirs in same diskpartition
-        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000).setBookiePort(port)
+        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000);
+        conf.setBookiePort(port)
         .setJournalDirName(tmpDir1.getPath())
         .setLedgerDirNames(new String[] { tmpDir1.getPath(), tmpDir2.getPath() })
         .setIndexDirName(new String[] { tmpDir1.getPath() });
@@ -663,10 +675,11 @@ public void testAllowDiskPartitionDuplicationDisabled() throws Exception {
         tmpDir2 = createTempDir("bookie", "test");
         port = PortManager.nextFreePort();
         // multiple indexdirs in same diskpartition
-        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000).setBookiePort(port)
-        .setJournalDirName(tmpDir1.getPath())
-        .setLedgerDirNames(new String[] { tmpDir1.getPath() })
-        .setIndexDirName(new String[] { tmpDir1.getPath(), tmpDir2.getPath() });
+        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000);
+        conf.setBookiePort(port)
+            .setJournalDirName(tmpDir1.getPath())
+            .setLedgerDirNames(new String[] { tmpDir1.getPath() })
+            .setIndexDirName(new String[] { tmpDir1.getPath(), tmpDir2.getPath() });
         conf.setAllowMultipleDirsUnderSameDiskPartition(false);
         bs1 = null;
         try {
@@ -684,10 +697,11 @@ public void testAllowDiskPartitionDuplicationDisabled() throws Exception {
         tmpDir2 = createTempDir("bookie", "test");
         port = PortManager.nextFreePort();
         // multiple journaldirs in same diskpartition
-        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000).setBookiePort(port)
-        .setJournalDirsName(new String[] { tmpDir1.getPath(), tmpDir2.getPath() })
-        .setLedgerDirNames(new String[] { tmpDir1.getPath() })
-        .setIndexDirName(new String[] { tmpDir1.getPath()});
+        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000);
+        conf.setBookiePort(port)
+            .setJournalDirsName(new String[] { tmpDir1.getPath(), tmpDir2.getPath() })
+            .setLedgerDirNames(new String[] { tmpDir1.getPath() })
+            .setIndexDirName(new String[] { tmpDir1.getPath()});
         conf.setAllowMultipleDirsUnderSameDiskPartition(false);
         bs1 = null;
         try {
@@ -717,10 +731,11 @@ public void testAllowDiskPartitionDuplicationAllowed() throws Exception {
 
         ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
         int port = 12555;
-        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000).setBookiePort(port)
-                .setJournalDirsName(new String[] { tmpDir1.getPath(), tmpDir2.getPath() })
-                .setLedgerDirNames(new String[] { tmpDir3.getPath(), tmpDir4.getPath() })
-                .setIndexDirName(new String[] { tmpDir5.getPath(), tmpDir6.getPath() });
+        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setZkTimeout(5000);
+        conf.setBookiePort(port)
+            .setJournalDirsName(new String[] { tmpDir1.getPath(), tmpDir2.getPath() })
+            .setLedgerDirNames(new String[] { tmpDir3.getPath(), tmpDir4.getPath() })
+            .setIndexDirName(new String[] { tmpDir5.getPath(), tmpDir6.getPath() });
         conf.setAllowMultipleDirsUnderSameDiskPartition(true);
         BookieServer bs1 = null;
         try {
@@ -749,12 +764,11 @@ private ZooKeeperClient createNewZKClient() throws Exception {
     public void testPersistBookieStatus() throws Exception {
         // enable persistent bookie status
         File tmpDir = createTempDir("bookie", "test");
-        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(tmpDir.getPath())
+        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(tmpDir.getPath())
             .setLedgerDirNames(new String[] { tmpDir.getPath() })
             .setReadOnlyModeEnabled(true)
-            .setPersistBookieStatusEnabled(true);
+            .setPersistBookieStatusEnabled(true).setZkServers(zkUtil.getZooKeeperConnectString());
         BookieServer bookieServer = new BookieServer(conf);
         bookieServer.start();
         Bookie bookie = bookieServer.getBookie();
@@ -786,12 +800,11 @@ public void testPersistBookieStatus() throws Exception {
     @Test(timeout = 10000)
     public void testReadOnlyBookieShouldIgnoreBookieStatus() throws Exception {
         File tmpDir = createTempDir("bookie", "test");
-        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(tmpDir.getPath())
+        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(tmpDir.getPath())
             .setLedgerDirNames(new String[] { tmpDir.getPath() })
             .setReadOnlyModeEnabled(true)
-            .setPersistBookieStatusEnabled(true);
+            .setPersistBookieStatusEnabled(true).setZkServers(zkUtil.getZooKeeperConnectString());
         // start new bookie
         BookieServer bookieServer = new BookieServer(conf);
         bookieServer.start();
@@ -827,12 +840,12 @@ public void testRetrieveBookieStatusWhenStatusFileIsCorrupted() throws Exception
             tmpLedgerDirs[i] = createTempDir("bookie", "test" + i);
             filePath[i] = tmpLedgerDirs[i].getPath();
         }
-        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(filePath[0])
+        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(filePath[0])
             .setLedgerDirNames(filePath)
             .setReadOnlyModeEnabled(true)
-            .setPersistBookieStatusEnabled(true);
+            .setPersistBookieStatusEnabled(true)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         // start a new bookie
         BookieServer bookieServer = new BookieServer(conf);
         bookieServer.start();
@@ -866,12 +879,12 @@ public void testReadLatestBookieStatus() throws Exception {
             tmpLedgerDirs[i] = createTempDir("bookie", "test" + i);
             filePath[i] = tmpLedgerDirs[i].getPath();
         }
-        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(filePath[0])
+        final ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(filePath[0])
             .setLedgerDirNames(filePath)
             .setReadOnlyModeEnabled(true)
-            .setPersistBookieStatusEnabled(true);
+            .setPersistBookieStatusEnabled(true)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         // start a new bookie
         BookieServer bookieServer = new BookieServer(conf);
         bookieServer.start();
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieJournalTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieJournalTest.java
index 328eddde9..9294e27f0 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieJournalTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/BookieJournalTest.java
@@ -345,10 +345,10 @@ public void testPreV2Journal() throws Exception {
         writePreV2Journal(Bookie.getCurrentDirectory(journalDir), 100);
         writeIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir), 1, "testPasswd".getBytes());
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
-            .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
 
         Bookie b = new Bookie(conf);
         b.readJournal();
@@ -374,10 +374,10 @@ public void testV4Journal() throws Exception {
 
         writeV4Journal(Bookie.getCurrentDirectory(journalDir), 100, "testPasswd".getBytes());
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
-            .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
 
         Bookie b = new Bookie(conf);
         b.readJournal();
@@ -405,10 +405,10 @@ public void testV5Journal() throws Exception {
         writeV5Journal(Bookie.getCurrentDirectory(journalDir), 2 * JournalChannel.SECTOR_SIZE,
                 "testV5Journal".getBytes());
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(null)
-                .setJournalDirName(journalDir.getPath())
-                .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
 
         Bookie b = new Bookie(conf);
         b.readJournal();
@@ -442,10 +442,11 @@ public void testAllJunkJournal() throws Exception {
 
         writeJunkJournal(Bookie.getCurrentDirectory(journalDir));
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
-            .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
+
         Bookie b = null;
         try {
             b = new Bookie(conf);
@@ -476,10 +477,10 @@ public void testEmptyJournal() throws Exception {
 
         writePreV2Journal(Bookie.getCurrentDirectory(journalDir), 0);
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
-            .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
 
         Bookie b = new Bookie(conf);
     }
@@ -498,10 +499,10 @@ public void testHeaderOnlyJournal() throws Exception {
 
         writeV2Journal(Bookie.getCurrentDirectory(journalDir), 0);
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
-            .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
 
         Bookie b = new Bookie(conf);
     }
@@ -524,10 +525,10 @@ public void testJunkEndedJournal() throws Exception {
 
         writeIndexFileForLedger(ledgerDir, 1, "testPasswd".getBytes());
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
-            .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
 
         Bookie b = null;
         try {
@@ -564,10 +565,10 @@ public void testTruncatedInLenJournal() throws Exception {
         writeIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir),
                                 1, "testPasswd".getBytes());
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
-            .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
 
         Bookie b = new Bookie(conf);
         b.readJournal();
@@ -608,10 +609,10 @@ public void testTruncatedInEntryJournal() throws Exception {
         writeIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir),
                                 1, "testPasswd".getBytes());
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
-            .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
 
         Bookie b = new Bookie(conf);
         b.readJournal();
@@ -670,10 +671,10 @@ private void testPartialFileInfoPreV3Journal(boolean truncateMasterKey)
         writePartialIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir),
                                        1, "testPasswd".getBytes(), truncateMasterKey);
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
-            .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
 
         if (truncateMasterKey) {
             try {
@@ -728,10 +729,10 @@ private void testPartialFileInfoPostV3Journal(boolean truncateMasterKey)
         writePartialIndexFileForLedger(Bookie.getCurrentDirectory(ledgerDir), 1, masterKey,
                                        truncateMasterKey);
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
-            .setLedgerDirNames(new String[] { ledgerDir.getPath() });
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setZkServers(null);
 
         Bookie b = new Bookie(conf);
         b.readJournal();
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/CookieTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/CookieTest.java
index c39ed8283..f14744f3c 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/CookieTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/CookieTest.java
@@ -99,11 +99,11 @@ public void tearDown() throws Exception {
      */
     @Test
     public void testCleanStart() throws Exception {
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(newDirectory(false))
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(newDirectory(false))
             .setLedgerDirNames(new String[] { newDirectory(false) })
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         try {
             Bookie b = new Bookie(conf);
         } catch (Exception e) {
@@ -128,11 +128,11 @@ public void testBadJournalCookie() throws Exception {
 
         String journalDir = newDirectory();
         String ledgerDir = newDirectory();
-        ServerConfiguration conf2 = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir)
+        ServerConfiguration conf2 = TestBKConfiguration.newServerConfiguration();
+        conf2.setJournalDirName(journalDir)
             .setLedgerDirNames(new String[] { ledgerDir })
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         Cookie.Builder cookieBuilder2 = Cookie.generateCookie(conf2);
         Cookie c2 = cookieBuilder2.build();
         c2.writeToDirectory(new File(journalDir, "current"));
@@ -156,11 +156,11 @@ public void testDirectoryMissing() throws Exception {
         String[] ledgerDirs = new String[] {
             newDirectory(), newDirectory(), newDirectory() };
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir)
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
             .setLedgerDirNames(ledgerDirs)
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
 
         Bookie b = new Bookie(conf); // should work fine
         b.start();
@@ -197,11 +197,11 @@ public void testCookieMissingOnJournalDir() throws Exception {
         String[] ledgerDirs = new String[] {
             newDirectory(), newDirectory(), newDirectory() };
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir)
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
             .setLedgerDirNames(ledgerDirs)
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
 
         Bookie b = new Bookie(conf); // should work fine
         b.start();
@@ -227,11 +227,11 @@ public void testCookieMissingOnLedgerDir() throws Exception {
         String[] ledgerDirs = new String[] {
             newDirectory(), newDirectory(), newDirectory() };
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir)
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
             .setLedgerDirNames(ledgerDirs)
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
 
         Bookie b = new Bookie(conf); // should work fine
         b.start();
@@ -257,11 +257,11 @@ public void testCookieMissingOnLedgerDir() throws Exception {
     public void testDirectoryAdded() throws Exception {
         String ledgerDir0 = newDirectory();
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir)
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
             .setLedgerDirNames(new String[] { ledgerDir0 })
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
 
         Bookie b = new Bookie(conf); // should work fine
         b.start();
@@ -290,13 +290,13 @@ public void testStorageExpansionOption() throws Exception {
         String ledgerDir0 = newDirectory();
         String indexDir0 = newDirectory();
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir)
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
             .setLedgerDirNames(new String[] { ledgerDir0 })
             .setIndexDirName(new String[] { indexDir0 })
             .setBookiePort(bookiePort)
-            .setAllowStorageExpansion(true);
+            .setAllowStorageExpansion(true)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
 
         Bookie b = new Bookie(conf); // should work fine
         b.start();
@@ -373,13 +373,13 @@ public void testNonEmptyDirAddWithStorageExpansionOption() throws Exception {
         String ledgerDir0 = newDirectory();
         String indexDir0 = newDirectory();
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir)
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
             .setLedgerDirNames(new String[] { ledgerDir0 })
             .setIndexDirName(new String[] { indexDir0 })
             .setBookiePort(bookiePort)
-            .setAllowStorageExpansion(true);
+            .setAllowStorageExpansion(true)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
 
         Bookie b = new Bookie(conf); // should work fine
         b.start();
@@ -427,11 +427,11 @@ public void testNonEmptyDirAddWithStorageExpansionOption() throws Exception {
     public void testDirectoryCleared() throws Exception {
         String ledgerDir0 = newDirectory();
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir)
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
             .setLedgerDirNames(new String[] { ledgerDir0 , newDirectory() })
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
 
         Bookie b = new Bookie(conf); // should work fine
         b.start();
@@ -452,11 +452,11 @@ public void testDirectoryCleared() throws Exception {
      */
     @Test
     public void testBookiePortChanged() throws Exception {
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(newDirectory())
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(newDirectory())
             .setLedgerDirNames(new String[] { newDirectory() , newDirectory() })
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         Bookie b = new Bookie(conf); // should work fine
         b.start();
         b.shutdown();
@@ -478,20 +478,20 @@ public void testBookiePortChanged() throws Exception {
      */
     @Test
     public void testNewBookieStartingWithAnotherBookiesPort() throws Exception {
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(newDirectory())
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(newDirectory())
             .setLedgerDirNames(new String[] { newDirectory() , newDirectory() })
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         Bookie b = new Bookie(conf); // should work fine
         b.start();
         b.shutdown();
 
-        conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(newDirectory())
+        conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(newDirectory())
             .setLedgerDirNames(new String[] { newDirectory() , newDirectory() })
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         try {
             b = new Bookie(conf);
             fail("Shouldn't have been able to start");
@@ -505,18 +505,18 @@ public void testNewBookieStartingWithAnotherBookiesPort() throws Exception {
      */
     @Test
     public void testVerifyCookieWithFormat() throws Exception {
-        ClientConfiguration adminConf = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration adminConf = new ClientConfiguration();
+        adminConf.setZkServers(zkUtil.getZooKeeperConnectString());
 
         adminConf.setProperty("bookkeeper.format", true);
         // Format the BK Metadata and generate INSTANCEID
         BookKeeperAdmin.format(adminConf, false, true);
 
-        ServerConfiguration bookieConf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setJournalDirName(newDirectory(false))
-                .setLedgerDirNames(new String[] { newDirectory(false) })
-                .setBookiePort(bookiePort);
+        ServerConfiguration bookieConf = TestBKConfiguration.newServerConfiguration();
+        bookieConf.setJournalDirName(newDirectory(false))
+            .setLedgerDirNames(new String[] { newDirectory(false) })
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         // Bookie should start successfully for fresh env.
         new Bookie(bookieConf);
 
@@ -548,11 +548,11 @@ public void testV2data() throws Exception {
         File ledgerDir = newV2LedgerDirectory();
         tmpDirs.add(ledgerDir);
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir.getPath())
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
             .setLedgerDirNames(new String[] { ledgerDir.getPath() })
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         try {
             Bookie b = new Bookie(conf);
             fail("Shouldn't have been able to start");
@@ -573,11 +573,11 @@ public void testV1data() throws Exception {
         File ledgerDir = newV1LedgerDirectory();
         tmpDirs.add(ledgerDir);
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir.getPath())
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
             .setLedgerDirNames(new String[]{ledgerDir.getPath()})
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         try {
             Bookie b = new Bookie(conf);
             fail("Shouldn't have been able to start");
@@ -596,10 +596,11 @@ public void testRestartWithHostNameAsBookieID() throws Exception {
         String[] ledgerDirs = new String[] { newDirectory(), newDirectory(),
                 newDirectory() };
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setJournalDirName(journalDir).setLedgerDirNames(ledgerDirs)
-                .setBookiePort(bookiePort);
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
+            .setLedgerDirNames(ledgerDirs)
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         Bookie b = new Bookie(conf); // should work fine
         b.start();
         b.shutdown();
@@ -621,10 +622,11 @@ public void testRestartWithAdvertisedAddressAsBookieID() throws Exception {
         String[] ledgerDirs = new String[] { newDirectory(), newDirectory(),
                 newDirectory() };
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setJournalDirName(journalDir).setLedgerDirNames(ledgerDirs)
-                .setBookiePort(bookiePort);
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
+            .setLedgerDirNames(ledgerDirs)
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         conf.setUseHostNameAsBookieID(false);
         Bookie b = new Bookie(conf); // should work fine
         b.start();
@@ -648,10 +650,10 @@ public void testRestartWithIpAddressAsBookieID() throws Exception {
         String[] ledgerDirs = new String[] { newDirectory(), newDirectory(),
                 newDirectory() };
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setJournalDirName(journalDir).setLedgerDirNames(ledgerDirs)
-                .setBookiePort(bookiePort);
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir).setLedgerDirNames(ledgerDirs)
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         conf.setUseHostNameAsBookieID(true);
         Bookie b = new Bookie(conf); // should work fine
         b.start();
@@ -677,11 +679,11 @@ public void testV2dataWithHostNameAsBookieID() throws Exception {
         File ledgerDir = newV2LedgerDirectory();
         tmpDirs.add(ledgerDir);
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setJournalDirName(journalDir.getPath())
-                .setLedgerDirNames(new String[] { ledgerDir.getPath() })
-                .setBookiePort(bookiePort);
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
+            .setLedgerDirNames(new String[] { ledgerDir.getPath() })
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         try {
             conf.setUseHostNameAsBookieID(true);
             new Bookie(conf);
@@ -700,9 +702,11 @@ public void testV2dataWithHostNameAsBookieID() throws Exception {
     public void testWriteToZooKeeper() throws Exception {
         String[] ledgerDirs = new String[] { newDirectory(), newDirectory(), newDirectory() };
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString()).setJournalDirName(journalDir)
-                .setLedgerDirNames(ledgerDirs).setBookiePort(bookiePort);
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
+            .setLedgerDirNames(ledgerDirs)
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         Bookie b = new Bookie(conf); // should work fine
         b.start();
         b.shutdown();
@@ -730,9 +734,11 @@ public void testWriteToZooKeeper() throws Exception {
     public void testDeleteFromZooKeeper() throws Exception {
         String[] ledgerDirs = new String[] { newDirectory(), newDirectory(), newDirectory() };
         String journalDir = newDirectory();
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString()).setJournalDirName(journalDir)
-                .setLedgerDirNames(ledgerDirs).setBookiePort(bookiePort);
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir)
+            .setLedgerDirNames(ledgerDirs)
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         Bookie b = new Bookie(conf); // should work fine
         b.start();
         b.shutdown();
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EnableZkSecurityBasicTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EnableZkSecurityBasicTest.java
index 6d498956c..c7a7f6533 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EnableZkSecurityBasicTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/EnableZkSecurityBasicTest.java
@@ -80,9 +80,9 @@ public static void cleanUpJAAS() {
     public void testCreateLedgerAddEntryOnSecureZooKeepeer() throws Exception {
         startNewBookie();
 
-        ClientConfiguration conf = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setZkTimeout(20000);
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
+        conf.setZkTimeout(20000);
 
         conf.setZkEnableSecurity(true);
 
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
index 61b295571..53083af88 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/LedgerCacheTest.java
@@ -323,9 +323,9 @@ public void testIndexPageEvictionWriteOrder() throws Exception {
         File ledgerDir = createTempDir("bookie", "ledger");
         Bookie.checkDirectoryStructure(Bookie.getCurrentDirectory(ledgerDir));
 
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setZkServers(null);
+        conf.setJournalDirName(journalDir.getPath())
             .setLedgerDirNames(new String[] { ledgerDir.getPath() })
             .setFlushInterval(1000)
             .setPageLimit(1)
@@ -338,9 +338,9 @@ public void testIndexPageEvictionWriteOrder() throws Exception {
             b.addEntry(packet, new Bookie.NopWriteCallback(), null, "passwd".getBytes());
         }
 
-        conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(null)
-            .setJournalDirName(journalDir.getPath())
+        conf = TestBKConfiguration.newServerConfiguration();
+        conf.setZkServers(null);
+        conf.setJournalDirName(journalDir.getPath())
             .setLedgerDirNames(new String[] { ledgerDir.getPath() });
 
         b = new Bookie(conf);
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/UpgradeTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/UpgradeTest.java
index a67235a3b..77f245332 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/UpgradeTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/bookie/UpgradeTest.java
@@ -151,9 +151,9 @@ static File newV2LedgerDirectory() throws Exception {
     }
 
     private static void testUpgradeProceedure(String zkServers, String journalDir, String ledgerDir) throws Exception {
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkServers)
-            .setJournalDirName(journalDir)
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setZkServers(zkServers);
+        conf.setJournalDirName(journalDir)
             .setLedgerDirNames(new String[] { ledgerDir })
             .setBookiePort(bookiePort);
         Bookie b = null;
@@ -215,11 +215,11 @@ public void testUpgradeCurrent() throws Exception {
         testUpgradeProceedure(zkUtil.getZooKeeperConnectString(), journalDir.getPath(), ledgerDir.getPath());
 
         // Upgrade again
-        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
-            .setJournalDirName(journalDir.getPath())
+        ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
+        conf.setJournalDirName(journalDir.getPath())
             .setLedgerDirNames(new String[] { ledgerDir.getPath() })
-            .setBookiePort(bookiePort);
+            .setBookiePort(bookiePort)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         FileSystemUpgrade.upgrade(conf); // should work fine with current directory
         Bookie b = new Bookie(conf);
         b.start();
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperDiskSpaceWeightedLedgerPlacementTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperDiskSpaceWeightedLedgerPlacementTest.java
index 154a45008..d20a8c87b 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperDiskSpaceWeightedLedgerPlacementTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperDiskSpaceWeightedLedgerPlacementTest.java
@@ -140,11 +140,11 @@ public void testDiskSpaceWeightedBookieSelection() throws Exception {
         long freeDiskSpace = 1000000L;
         int multiple = 3;
 
-        ClientConfiguration conf = new ClientConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setDiskWeightBasedPlacementEnabled(true)
-                .setGetBookieInfoRetryIntervalSeconds(1, TimeUnit.SECONDS)
-                .setBookieMaxWeightMultipleForWeightBasedPlacement(multiple);
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setDiskWeightBasedPlacementEnabled(true)
+            .setGetBookieInfoRetryIntervalSeconds(1, TimeUnit.SECONDS)
+            .setBookieMaxWeightMultipleForWeightBasedPlacement(multiple)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         final BookKeeperCheckInfoReader client = new BookKeeperCheckInfoReader(conf);
 
         for (int i = 0; i < numBookies; i++) {
@@ -190,11 +190,11 @@ public void testDiskSpaceWeightedBookieSelectionWithChangingWeights() throws Exc
         long freeDiskSpace = 1000000L;
         int multiple = 3;
 
-        ClientConfiguration conf = new ClientConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setDiskWeightBasedPlacementEnabled(true)
-                .setGetBookieInfoRetryIntervalSeconds(1, TimeUnit.SECONDS)
-                .setBookieMaxWeightMultipleForWeightBasedPlacement(multiple);
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setDiskWeightBasedPlacementEnabled(true)
+            .setGetBookieInfoRetryIntervalSeconds(1, TimeUnit.SECONDS)
+            .setBookieMaxWeightMultipleForWeightBasedPlacement(multiple)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         final BookKeeperCheckInfoReader client = new BookKeeperCheckInfoReader(conf);
 
         for (int i = 0; i < numBookies; i++) {
@@ -280,11 +280,11 @@ public void testDiskSpaceWeightedBookieSelectionWithBookiesDying() throws Except
         long freeDiskSpace = 1000000L;
         int multiple = 3;
 
-        ClientConfiguration conf = new ClientConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setDiskWeightBasedPlacementEnabled(true)
-                .setGetBookieInfoRetryIntervalSeconds(1, TimeUnit.SECONDS)
-                .setBookieMaxWeightMultipleForWeightBasedPlacement(multiple);
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setDiskWeightBasedPlacementEnabled(true)
+            .setGetBookieInfoRetryIntervalSeconds(1, TimeUnit.SECONDS)
+            .setBookieMaxWeightMultipleForWeightBasedPlacement(multiple)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         final BookKeeperCheckInfoReader client = new BookKeeperCheckInfoReader(conf);
 
         for (int i = 0; i < numBookies; i++) {
@@ -361,11 +361,11 @@ public void testDiskSpaceWeightedBookieSelectionWithBookiesBeingAdded() throws E
         long freeDiskSpace = 1000000L;
         int multiple = 3;
 
-        ClientConfiguration conf = new ClientConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setDiskWeightBasedPlacementEnabled(true)
-                .setGetBookieInfoRetryIntervalSeconds(1, TimeUnit.SECONDS)
-                .setBookieMaxWeightMultipleForWeightBasedPlacement(multiple);
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setDiskWeightBasedPlacementEnabled(true)
+            .setGetBookieInfoRetryIntervalSeconds(1, TimeUnit.SECONDS)
+            .setBookieMaxWeightMultipleForWeightBasedPlacement(multiple)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
         final BookKeeperCheckInfoReader client = new BookKeeperCheckInfoReader(conf);
 
         for (int i = 0; i < numBookies; i++) {
@@ -436,12 +436,12 @@ public void testDiskSpaceWeightedBookieSelectionWithPeriodicBookieInfoUpdate() t
         int multiple = 3;
 
         int updateIntervalSecs = 6;
-         ClientConfiguration conf = new ClientConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setDiskWeightBasedPlacementEnabled(true)
-                .setGetBookieInfoRetryIntervalSeconds(1, TimeUnit.SECONDS)
-                .setBookieMaxWeightMultipleForWeightBasedPlacement(multiple)
-                .setGetBookieInfoIntervalSeconds(updateIntervalSecs, TimeUnit.SECONDS);
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
+        conf.setDiskWeightBasedPlacementEnabled(true)
+            .setGetBookieInfoRetryIntervalSeconds(1, TimeUnit.SECONDS)
+            .setBookieMaxWeightMultipleForWeightBasedPlacement(multiple)
+            .setGetBookieInfoIntervalSeconds(updateIntervalSecs, TimeUnit.SECONDS);
         final BookKeeperCheckInfoReader client = new BookKeeperCheckInfoReader(conf);
 
         AtomicBoolean useHigherValue = new AtomicBoolean(false);
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
index 521e4b049..49784c60f 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
@@ -63,8 +63,8 @@ public BookKeeperTest() {
 
     @Test
     public void testConstructionZkDelay() throws Exception {
-        ClientConfiguration conf = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString())
             .setZkTimeout(20000);
 
         CountDownLatch l = new CountDownLatch(1);
@@ -78,8 +78,8 @@ public void testConstructionZkDelay() throws Exception {
 
     @Test
     public void testConstructionNotConnectedExplicitZk() throws Exception {
-        ClientConfiguration conf = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString())
             .setZkTimeout(20000);
 
         CountDownLatch l = new CountDownLatch(1);
@@ -106,8 +106,8 @@ public void testConstructionNotConnectedExplicitZk() throws Exception {
      */
     @Test
     public void testBookkeeperPassword() throws Exception {
-        ClientConfiguration conf = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
         BookKeeper bkc = new BookKeeper(conf);
 
         DigestType digestCorrect = digestType;
@@ -191,8 +191,8 @@ public void addComplete(int rc, LedgerHandle lh, long entryId, Object ctx) {
      */
     @Test
     public void testCloseDuringOp() throws Exception {
-        ClientConfiguration conf = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
         for (int i = 0; i < 10; i++) {
             final BookKeeper client = new BookKeeper(conf);
             final CountDownLatch l = new CountDownLatch(1);
@@ -227,8 +227,8 @@ public void addComplete(int rc, LedgerHandle lh, long entryId, Object ctx) {
 
     @Test
     public void testIsClosed() throws Exception {
-        ClientConfiguration conf = new ClientConfiguration()
-        .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
 
         BookKeeper bkc = new BookKeeper(conf);
         LedgerHandle lh = bkc.createLedger(digestType, "testPasswd".getBytes());
@@ -247,7 +247,8 @@ public void testIsClosed() throws Exception {
 
     @Test
     public void testReadFailureCallback() throws Exception {
-        ClientConfiguration conf = new ClientConfiguration().setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
 
         BookKeeper bkc = new BookKeeper(conf);
         LedgerHandle lh = bkc.createLedger(digestType, "testPasswd".getBytes());
@@ -293,8 +294,8 @@ public void readComplete(int rc, LedgerHandle lh, Enumeration<LedgerEntry> seq,
 
     @Test
     public void testAutoCloseableBookKeeper() throws Exception {
-        ClientConfiguration conf = new ClientConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
         BookKeeper bkc2;
         try (BookKeeper bkc = new BookKeeper(conf)) {
             bkc2 = bkc;
@@ -312,8 +313,8 @@ public void testAutoCloseableBookKeeper() throws Exception {
 
     @Test
     public void testReadHandleWithNoExplicitLAC() throws Exception {
-        ClientConfiguration confWithNoExplicitLAC = new ClientConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration confWithNoExplicitLAC = new ClientConfiguration();
+        confWithNoExplicitLAC.setZkServers(zkUtil.getZooKeeperConnectString());
         confWithNoExplicitLAC.setExplictLacInterval(0);
 
         BookKeeper bkcWithNoExplicitLAC = new BookKeeper(confWithNoExplicitLAC);
@@ -372,8 +373,8 @@ public void testReadHandleWithNoExplicitLAC() throws Exception {
 
     @Test
     public void testReadHandleWithExplicitLAC() throws Exception {
-        ClientConfiguration confWithExplicitLAC = new ClientConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration confWithExplicitLAC = new ClientConfiguration();
+        confWithExplicitLAC.setZkServers(zkUtil.getZooKeeperConnectString());
         int explicitLacIntervalMillis = 1000;
         confWithExplicitLAC.setExplictLacInterval(explicitLacIntervalMillis);
 
@@ -437,8 +438,8 @@ public void testReadHandleWithExplicitLAC() throws Exception {
     @Test
     public void testReadAfterLastAddConfirmed() throws Exception {
 
-        ClientConfiguration clientConfiguration = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration clientConfiguration = new ClientConfiguration();
+        clientConfiguration.setZkServers(zkUtil.getZooKeeperConnectString());
 
         try (BookKeeper bkWriter = new BookKeeper(clientConfiguration)) {
             LedgerHandle writeLh = bkWriter.createLedger(digestType, "testPasswd".getBytes());
@@ -653,9 +654,8 @@ public void testReadAfterLastAddConfirmed() throws Exception {
 
     @Test
     public void testReadWriteWithV2WireProtocol() throws Exception {
-        ClientConfiguration conf = new ClientConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setUseV2WireProtocol(true);
+        ClientConfiguration conf = new ClientConfiguration().setUseV2WireProtocol(true);
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
         int numEntries = 100;
         byte[] data = "foobar".getBytes();
         try (BookKeeper bkc = new BookKeeper(conf)) {
@@ -699,8 +699,8 @@ public void testReadWriteWithV2WireProtocol() throws Exception {
 
     @Test
     public void testReadEntryReleaseByteBufs() throws Exception {
-        ClientConfiguration confWriter = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration confWriter = new ClientConfiguration();
+        confWriter.setZkServers(zkUtil.getZooKeeperConnectString());
         int numEntries = 10;
         byte[] data = "foobar".getBytes();
         long ledgerId;
@@ -715,9 +715,10 @@ public void testReadEntryReleaseByteBufs() throws Exception {
 
         // v2 protocol, using pooled buffers
         ClientConfiguration confReader1 = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
             .setUseV2WireProtocol(true)
             .setNettyUsePooledBuffers(true);
+        confReader1.setZkServers(zkUtil.getZooKeeperConnectString());
+
         try (BookKeeper bkc = new BookKeeper(confReader1)) {
             try (LedgerHandle lh = bkc.openLedger(ledgerId, digestType, "testPasswd".getBytes())) {
                 assertEquals(numEntries - 1, lh.readLastConfirmed());
@@ -735,9 +736,10 @@ public void testReadEntryReleaseByteBufs() throws Exception {
 
         // v2 protocol, not using pooled buffers
         ClientConfiguration confReader2 = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
             .setUseV2WireProtocol(true)
             .setNettyUsePooledBuffers(false);
+        confReader2.setZkServers(zkUtil.getZooKeeperConnectString());
+
         try (BookKeeper bkc = new BookKeeper(confReader2)) {
             try (LedgerHandle lh = bkc.openLedger(ledgerId, digestType, "testPasswd".getBytes())) {
                 assertEquals(numEntries - 1, lh.readLastConfirmed());
@@ -755,9 +757,9 @@ public void testReadEntryReleaseByteBufs() throws Exception {
 
         // v3 protocol, not using pooled buffers
         ClientConfiguration confReader3 = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
             .setUseV2WireProtocol(false)
             .setNettyUsePooledBuffers(false);
+        confReader3.setZkServers(zkUtil.getZooKeeperConnectString());
         try (BookKeeper bkc = new BookKeeper(confReader3)) {
             try (LedgerHandle lh = bkc.openLedger(ledgerId, digestType, "testPasswd".getBytes())) {
                 assertEquals(numEntries - 1, lh.readLastConfirmed());
@@ -778,9 +780,10 @@ public void testReadEntryReleaseByteBufs() throws Exception {
         // v3 protocol, using pooled buffers
         // v3 protocol from 4.5 always "wraps" buffers returned by protobuf
         ClientConfiguration confReader4 = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString())
             .setUseV2WireProtocol(false)
             .setNettyUsePooledBuffers(true);
+        confReader4.setZkServers(zkUtil.getZooKeeperConnectString());
+
         try (BookKeeper bkc = new BookKeeper(confReader4)) {
             try (LedgerHandle lh = bkc.openLedger(ledgerId, digestType, "testPasswd".getBytes())) {
                 assertEquals(numEntries - 1, lh.readLastConfirmed());
@@ -800,8 +803,8 @@ public void testReadEntryReleaseByteBufs() throws Exception {
         }
 
         // cannot read twice an entry
-        ClientConfiguration confReader5 = new ClientConfiguration()
-            .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration confReader5 = new ClientConfiguration();
+        confReader5.setZkServers(zkUtil.getZooKeeperConnectString());
         try (BookKeeper bkc = new BookKeeper(confReader5)) {
             try (LedgerHandle lh = bkc.openLedger(ledgerId, digestType, "testPasswd".getBytes())) {
                 assertEquals(numEntries - 1, lh.readLastConfirmed());
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
index 332d8ea1a..ad9c352b7 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/LedgerCloseTest.java
@@ -71,7 +71,8 @@ public LedgerCloseTest() {
     @Test
     public void testLedgerCloseWithConsistentLength() throws Exception {
         ClientConfiguration conf = new ClientConfiguration();
-        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setReadTimeout(1);
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
+        conf.setReadTimeout(1);
 
         BookKeeper bkc = new BookKeeper(conf);
         LedgerHandle lh = bkc.createLedger(6, 3, DigestType.CRC32, new byte[] {});
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ListLedgersTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ListLedgersTest.java
index 60d586409..8afda99ea 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ListLedgersTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/ListLedgersTest.java
@@ -44,8 +44,8 @@ public void testListLedgers()
     throws Exception {
         int numOfLedgers = 10;
 
-        ClientConfiguration conf = new ClientConfiguration()
-        .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
 
         BookKeeper bkc = new BookKeeper(conf);
         for (int i = 0; i < numOfLedgers; i++) {
@@ -69,8 +69,8 @@ public void testListLedgers()
     @Test
     public void testEmptyList()
     throws Exception {
-        ClientConfiguration conf = new ClientConfiguration()
-        .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
 
         BookKeeperAdmin admin = new BookKeeperAdmin(zkUtil.
                 getZooKeeperConnectString());
@@ -84,8 +84,8 @@ public void testRemoveNotSupported()
     throws Exception {
         int numOfLedgers = 1;
 
-        ClientConfiguration conf = new ClientConfiguration()
-        .setZkServers(zkUtil.getZooKeeperConnectString());
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
 
         BookKeeper bkc = new BookKeeper(conf);
         for (int i = 0; i < numOfLedgers; i++) {
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
index e5e0e2542..83bfd502e 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java
@@ -55,7 +55,7 @@ public SlowBookieTest() {
     @Test
     public void testSlowBookie() throws Exception {
         ClientConfiguration conf = new ClientConfiguration();
-        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setReadTimeout(360);
+        conf.setReadTimeout(360).setZkServers(zkUtil.getZooKeeperConnectString());
 
         BookKeeper bkc = new BookKeeper(conf);
 
@@ -101,7 +101,7 @@ public void addComplete(int rc, LedgerHandle lh, long entryId, Object ctx) {
     @Test
     public void testBookieFailureWithSlowBookie() throws Exception {
         ClientConfiguration conf = new ClientConfiguration();
-        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setReadTimeout(5);
+        conf.setReadTimeout(5).setZkServers(zkUtil.getZooKeeperConnectString());
 
         BookKeeper bkc = new BookKeeper(conf);
 
@@ -155,7 +155,7 @@ public void operationComplete(int rc, Set<LedgerFragment> fragments) {
     @Test
     public void testManyBookieFailureWithSlowBookies() throws Exception {
         ClientConfiguration conf = new ClientConfiguration();
-        conf.setZkServers(zkUtil.getZooKeeperConnectString()).setReadTimeout(5);
+        conf.setReadTimeout(5).setZkServers(zkUtil.getZooKeeperConnectString());
 
         BookKeeper bkc = new BookKeeper(conf);
 
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestDisableEnsembleChange.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestDisableEnsembleChange.java
index 428aa8a58..de6d4e486 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestDisableEnsembleChange.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/TestDisableEnsembleChange.java
@@ -69,8 +69,8 @@ public void testDisableEnsembleChangeNotEnoughBookies() throws Exception {
 
     void disableEnsembleChangeTest(boolean startNewBookie) throws Exception {
         ClientConfiguration conf = new ClientConfiguration();
-        conf.setZkServers(zkUtil.getZooKeeperConnectString())
-            .setDelayEnsembleChange(false)
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
+        conf.setDelayEnsembleChange(false)
             .setDisableEnsembleChangeFeatureName(FEATURE_DISABLE_ENSEMBLE_CHANGE);
 
         SettableFeatureProvider featureProvider = new SettableFeatureProvider("test", 0);
@@ -172,8 +172,8 @@ public void run() {
     @Test
     public void testRetryFailureBookie() throws Exception {
         ClientConfiguration conf = new ClientConfiguration();
-        conf.setZkServers(zkUtil.getZooKeeperConnectString())
-            .setDelayEnsembleChange(false)
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
+        conf.setDelayEnsembleChange(false)
             .setDisableEnsembleChangeFeatureName(FEATURE_DISABLE_ENSEMBLE_CHANGE);
 
         SettableFeatureProvider featureProvider = new SettableFeatureProvider("test", 0);
@@ -219,11 +219,11 @@ public void testRetrySlowBookie() throws Exception {
         final int readTimeout = 2;
 
         ClientConfiguration conf = new ClientConfiguration();
-        conf.setZkServers(zkUtil.getZooKeeperConnectString())
-            .setReadEntryTimeout(readTimeout)
+        conf.setReadEntryTimeout(readTimeout)
             .setAddEntryTimeout(readTimeout)
             .setDelayEnsembleChange(false)
-            .setDisableEnsembleChangeFeatureName(FEATURE_DISABLE_ENSEMBLE_CHANGE);
+            .setDisableEnsembleChangeFeatureName(FEATURE_DISABLE_ENSEMBLE_CHANGE)
+            .setZkServers(zkUtil.getZooKeeperConnectString());
 
 
         SettableFeatureProvider featureProvider = new SettableFeatureProvider("test", 0);
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/NetworkLessBookieTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/NetworkLessBookieTest.java
index 5e77f03dd..b63a874f1 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/NetworkLessBookieTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/proto/NetworkLessBookieTest.java
@@ -46,9 +46,9 @@ public NetworkLessBookieTest() {
 
     @Test
     public void testUseLocalBookie() throws Exception {
-        ClientConfiguration conf = new ClientConfiguration()
-                .setZkServers(zkUtil.getZooKeeperConnectString())
-                .setZkTimeout(20000);
+        ClientConfiguration conf = new ClientConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
+        conf.setZkTimeout(20000);
 
         try (BookKeeper bkc = new BookKeeper(conf)) {
             try (LedgerHandle h = bkc.createLedger(1, 1, DigestType.CRC32, "testPasswd".getBytes())) {
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestLedgerUnderreplicationManager.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestLedgerUnderreplicationManager.java
index f4da4daa1..25d381fda 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestLedgerUnderreplicationManager.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/replication/TestLedgerUnderreplicationManager.java
@@ -92,7 +92,8 @@ public void setupZooKeeper() throws Exception {
         zkUtil = new ZooKeeperUtil();
         zkUtil.startServer();
 
-        conf = TestBKConfiguration.newServerConfiguration().setZkServers(zkUtil.getZooKeeperConnectString());
+        conf = TestBKConfiguration.newServerConfiguration();
+        conf.setZkServers(zkUtil.getZooKeeperConnectString());
 
         executor = Executors.newCachedThreadPool();
 
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
index 6bf05ae39..6db454e31 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/test/BookieClientTest.java
@@ -73,9 +73,10 @@ public void setUp() throws Exception {
         // know via ZooKeeper which Bookies are available, okay, so pass in null
         // for the zkServers input parameter when constructing the BookieServer.
         ServerConfiguration conf = TestBKConfiguration.newServerConfiguration();
-        conf.setZkServers(null).setBookiePort(port)
+        conf.setBookiePort(port)
             .setJournalDirName(tmpDir.getPath())
-            .setLedgerDirNames(new String[] { tmpDir.getPath() });
+            .setLedgerDirNames(new String[] { tmpDir.getPath() })
+            .setZkServers(null);
         bs = new BookieServer(conf);
         bs.start();
         eventLoopGroup = new NioEventLoopGroup();


 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services