ankit-j commented on a change in pull request #2096: Entries must be
acknowledged by bookies in multiple fault domains before being acknowledged to
client
URL: https://github.com/apache/bookkeeper/pull/2096#discussion_r286271013
##########
File path:
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookKeeperTest.java
##########
@@ -982,76 +1009,70 @@ public void testEnforceMinNumFaultDomainsForWrite()
throws Exception {
ClientConfiguration conf = new ClientConfiguration();
conf.setMetadataServiceUri(zkUtil.getMetadataServiceUri());
- conf.setProperty(REPP_DNS_RESOLVER_CLASS,
StaticDNSResolver.class.getName());
-
conf.setEnsemblePlacementPolicy(RackawareEnsemblePlacementPolicy.class);
+
conf.setEnsemblePlacementPolicy(MockRackawareEnsemblePlacementPolicy.class);
conf.setMinNumRacksPerWriteQuorum(2);
- conf.setEnforceMinNumRacksPerWriteQuorum(true);
conf.setEnforceMinNumFaultDomainsForWrite(true);
// Abnormal values for testing to prevent timeouts
conf.setAddEntryTimeout(300);
+ BookKeeperTestClient bk = new BookKeeperTestClient(conf);
- if (LOG.isDebugEnabled()) {
- LOG.debug(conf.toString());
- }
-
- // Assign all initial bookies started to the default rack by modifying
the `localhost` in the StaticDNSResolver
- StaticDNSResolver.reset();
- StaticDNSResolver.addNodeToRack("localhost",
NetworkTopology.DEFAULT_REGION + "/rack0");
-
- try (BookKeeperTestClient bk = new BookKeeperTestClient(conf)) {
- // Modify localhost in StaticDNSResolver to assign next started
bookie to a different rack("/rack1")
- StaticDNSResolver.addNodeToRack("localhost",
NetworkTopology.DEFAULT_REGION + "/rack1");
- List<BookieSocketAddress> bookieRack1 =
Collections.singletonList(startNewBookieAndReturnAddress());
+ MockRackawareEnsemblePlacementPolicy currPlacementPolicy =
+ (MockRackawareEnsemblePlacementPolicy) bk.getPlacementPolicy();
+ currPlacementPolicy.resetCounter();
+ BookieSocketAddress bookieToSleep;
- try (LedgerHandle lh = bk.createLedger(3, 3, digestType,
password)) {
- CountDownLatch sleepLatch = new CountDownLatch(1);
+ try (LedgerHandle lh = bk.createLedger(3, 3, 2, digestType, password))
{
+ CountDownLatch sleepLatch = new CountDownLatch(1);
- Thread bookieSleeperCountdown = new Thread(() -> {
- try {
- LOG.info("Counting down 10 seconds before awakening
non default rack bookie");
- sleepLatch.await(10, TimeUnit.SECONDS);
- LOG.info("Non default rack bookie awake");
- } catch (InterruptedException ignored) {}
+ Thread bookieSleeperCountdown = new Thread(() -> {
+ try {
+ LOG.info("Counting down 10 seconds before waking sleeping
bookie");
+ sleepLatch.await(10, TimeUnit.SECONDS);
+ LOG.info("Picked bookie awake");
+ } catch (InterruptedException ignored) {
+ }
- sleepLatch.countDown();
- });
+ sleepLatch.countDown();
+ });
- Thread writeToLedger = new Thread(() -> {
- try {
- LOG.info("Initiating write for entry");
- long entryId = lh.addEntry(data);
- LOG.info("Wrote entry with entryId = {}", entryId);
- assertTrue(entryId >= 0);
- } catch (InterruptedException | BKException ignored) {
- // Fail the test if the write times out
- fail("Write should not have thrown error");
- }
- });
+ Thread writeToLedger = new Thread(() -> {
+ try {
+ LOG.info("Initiating write for entry");
+ long entryId = lh.addEntry(data);
+ LOG.info("Wrote entry with entryId = {}", entryId);
+ assertTrue(entryId >= 0);
Review comment:
Modifying.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services