This is an automated email from the ASF dual-hosted git repository.
zhaijia pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git
The following commit(s) were added to refs/heads/master by this push:
new f1bee51 ISSUE #831: move zkServers and zkTimeout into
AbstractCofiguration
f1bee51 is described below
commit f1bee51d8157399fc4e1b777376b29656d154819
Author: Jia Zhai <[email protected]>
AuthorDate: Wed Dec 13 16:51:42 2017 +0800
ISSUE #831: move zkServers and zkTimeout into AbstractCofiguration
Descriptions of the changes in this PR:
both ClientConfiguration and ServerConfiguration contain ZkServers and
ZKTimeout, would like to move them into AbstractConfiguration.
Changes:
1, Regarding methods setZkServers/getZkServers/setZkTimeout/getZkTimeout,
remove them in ClientConfiguration and ServerConfiguration; added them in
AbstractConfiguration;
2, fix usage of above methods in test cases;
Master Issue: #831
Author: Jia Zhai <[email protected]>
Author: Sijie Guo <[email protected]>
Reviewers: Enrico Olivelli <[email protected]>, Sijie Guo
<[email protected]>
This closes #833 from zhaijack/issue-831, closes #831
---
.../org/apache/bookkeeper/bookie/BookieShell.java | 6 +-
.../org/apache/bookkeeper/client/BookKeeper.java | 2 +-
.../apache/bookkeeper/client/BookKeeperAdmin.java | 2 +-
.../bookkeeper/conf/AbstractConfiguration.java | 51 ++++++
.../bookkeeper/conf/ClientConfiguration.java | 50 ------
.../bookkeeper/conf/ServerConfiguration.java | 51 ------
.../server/http/BKHttpServiceProvider.java | 4 +-
.../server/http/service/ListBookieInfoService.java | 4 +-
.../bookkeeper/bookie/AdvertisedAddressTest.java | 8 +-
.../bookie/BookieInitializationTest.java | 135 +++++++++-------
.../bookkeeper/bookie/BookieJournalTest.java | 89 ++++++-----
.../org/apache/bookkeeper/bookie/CookieTest.java | 178 +++++++++++----------
.../bookie/EnableZkSecurityBasicTest.java | 6 +-
.../apache/bookkeeper/bookie/LedgerCacheTest.java | 12 +-
.../org/apache/bookkeeper/bookie/UpgradeTest.java | 14 +-
...KeeperDiskSpaceWeightedLedgerPlacementTest.java | 52 +++---
.../apache/bookkeeper/client/BookKeeperTest.java | 63 ++++----
.../apache/bookkeeper/client/LedgerCloseTest.java | 3 +-
.../apache/bookkeeper/client/ListLedgersTest.java | 12 +-
.../apache/bookkeeper/client/SlowBookieTest.java | 6 +-
.../client/TestDisableEnsembleChange.java | 14 +-
.../bookkeeper/proto/NetworkLessBookieTest.java | 6 +-
.../TestLedgerUnderreplicationManager.java | 3 +-
.../apache/bookkeeper/test/BookieClientTest.java | 5 +-
24 files changed, 377 insertions(+), 399 deletions(-)
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 1d19a30..5e72c26 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 class BookieShell implements Tool {
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 d0f8a64..69e1139 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
@@ -314,7 +314,7 @@ public class BookKeeper implements
org.apache.bookkeeper.client.api.BookKeeper {
*/
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 0d6321f..09fda48 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 @@ public class BookKeeperAdmin implements AutoCloseable {
* 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 a5f35ec..9f8c503 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 static
org.apache.bookkeeper.conf.ClientConfiguration.CLIENT_AUTH_PROVIDE
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.CompositeConfiguration;
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 @@ public abstract class AbstractConfiguration extends
CompositeConfiguration {
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";
@@ -134,6 +140,51 @@ public abstract class AbstractConfiguration extends
CompositeConfiguration {
}
/**
+ * 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.
*
* @param lmType
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 966fd42..93adc1f 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.discover.ZKRegistrationClient;
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 @@ import org.apache.commons.lang.StringUtils;
*/
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";
@@ -532,51 +527,6 @@ public class ClientConfiguration extends
AbstractConfiguration {
}
/**
- * 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
* before we consider it failed.
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 7ff792c..19d5df1 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.stats.StatsProvider;
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 @@ public class ServerConfiguration extends
AbstractConfiguration {
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";
@@ -989,51 +983,6 @@ public class ServerConfiguration extends
AbstractConfiguration {
}
/**
- * 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.
*
* @return zk 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 a733c50..461c520 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 @@ public class BKHttpServiceProvider implements
HttpServiceProvider {
.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 72897cf..5da3740 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 class ListBookieInfoService implements
HttpEndpointService {
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 2f42ca4..d8a8df9 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 @@ public class AdvertisedAddressTest extends
BookKeeperClusterTestCase {
*/
@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 990c205..dbb9c3c 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 @@ public class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 @@ public class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
// 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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 @@ public class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
@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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 class BookieInitializationTest extends
BookKeeperClusterTestCase {
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 328eddd..9294e27 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 class BookieJournalTest {
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 class BookieJournalTest {
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 class BookieJournalTest {
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 class BookieJournalTest {
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 class BookieJournalTest {
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 class BookieJournalTest {
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 class BookieJournalTest {
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 class BookieJournalTest {
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 class BookieJournalTest {
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 @@ public class BookieJournalTest {
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 @@ public class BookieJournalTest {
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 c39ed82..f14744f 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 class CookieTest extends BookKeeperClusterTestCase {
*/
@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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
*/
@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 class CookieTest extends BookKeeperClusterTestCase
{
*/
@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 class CookieTest extends BookKeeperClusterTestCase
{
*/
@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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase
{
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 class CookieTest extends BookKeeperClusterTestCase {
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 class CookieTest extends BookKeeperClusterTestCase {
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 6d49895..c7a7f65 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 class EnableZkSecurityBasicTest extends
BookKeeperClusterTestCase {
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 61b2955..53083af 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 class LedgerCacheTest {
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 class LedgerCacheTest {
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 a67235a..77f2453 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 @@ public class UpgradeTest extends BookKeeperClusterTestCase {
}
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 class UpgradeTest extends
BookKeeperClusterTestCase {
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 154a450..d20a8c8 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 class
BookKeeperDiskSpaceWeightedLedgerPlacementTest extends BookKeeperCl
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 class
BookKeeperDiskSpaceWeightedLedgerPlacementTest extends BookKeeperCl
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 class
BookKeeperDiskSpaceWeightedLedgerPlacementTest extends BookKeeperCl
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 class
BookKeeperDiskSpaceWeightedLedgerPlacementTest extends BookKeeperCl
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 class
BookKeeperDiskSpaceWeightedLedgerPlacementTest extends BookKeeperCl
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 521e4b0..49784c6 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 class BookKeeperTest extends BookKeeperClusterTestCase
{
@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 class BookKeeperTest extends BookKeeperClusterTestCase
{
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
*/
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
*/
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
@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 class BookKeeperTest extends
BookKeeperClusterTestCase {
// 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 class BookKeeperTest extends
BookKeeperClusterTestCase {
// 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 class BookKeeperTest extends
BookKeeperClusterTestCase {
// 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 class BookKeeperTest extends
BookKeeperClusterTestCase {
// 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 class BookKeeperTest extends
BookKeeperClusterTestCase {
}
// 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 332d8ea..ad9c352 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 class LedgerCloseTest extends
BookKeeperClusterTestCase {
@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 60d5864..8afda99 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 class ListLedgersTest extends
BookKeeperClusterTestCase {
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 class ListLedgersTest extends
BookKeeperClusterTestCase {
@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 class ListLedgersTest extends
BookKeeperClusterTestCase {
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 e5e0e25..83bfd50 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 class SlowBookieTest extends BookKeeperClusterTestCase
{
@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 class SlowBookieTest extends
BookKeeperClusterTestCase {
@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 class SlowBookieTest extends
BookKeeperClusterTestCase {
@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 428aa8a..de6d4e4 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 class TestDisableEnsembleChange extends
BookKeeperClusterTestCase {
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 class TestDisableEnsembleChange extends
BookKeeperClusterTestCase {
@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 class TestDisableEnsembleChange extends
BookKeeperClusterTestCase {
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 5e77f03..b63a874 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 class NetworkLessBookieTest extends
BookKeeperClusterTestCase {
@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 f4da4da..25d381f 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 class TestLedgerUnderreplicationManager {
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 b799635..2abf020 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
@@ -78,9 +78,10 @@ public class BookieClientTest {
// 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();
--
To stop receiving notification emails like this one, please contact
['"[email protected]" <[email protected]>'].