You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2022/09/28 04:04:38 UTC

[GitHub] [bookkeeper] zymap commented on a diff in pull request #3505: Rename success with writableResult and update final writableResult about wait writeSet

zymap commented on code in PR #3505:
URL: https://github.com/apache/bookkeeper/pull/3505#discussion_r981921160


##########
bookkeeper-server/src/test/java/org/apache/bookkeeper/client/SlowBookieTest.java:
##########
@@ -390,4 +390,32 @@ public void operationComplete(int rc, Set<LedgerFragment> fragments) {
         checklatch.await();
         assertEquals("There should be no missing fragments", 0, numFragments.get());
     }
+
+    @Test
+    public void testWaitForWritable() throws Exception {
+        final ClientConfiguration conf = new ClientConfiguration();
+        conf.setMetadataServiceUri(zkUtil.getMetadataServiceUri());
+        BookKeeper bkc = new BookKeeper(conf);
+
+        byte[] pwd = new byte[]{};
+        try (LedgerHandle lh = bkc.createLedger(1, 1, 1, BookKeeper.DigestType.CRC32, pwd)) {
+            long entryId = lh.addEntry(this.entry);
+
+            RoundRobinDistributionSchedule schedule = new RoundRobinDistributionSchedule(1, 1, 1);
+            DistributionSchedule.WriteSet writeSet = schedule.getWriteSet(entryId);
+
+            int slowBookieIndex = writeSet.get(ThreadLocalRandom.current().nextInt(writeSet.size()));
+            List<BookieId> curEns = lh.getCurrentEnsemble();
+
+            // disable channel writable
+            setTargetChannelState(bkc, curEns.get(slowBookieIndex), 0, false);
+            boolean isWriteable = lh.waitForWritable(writeSet, 0, 1000);

Review Comment:
   This is always true/false if you set the state before you call this method. We need a test to make sure after the backoff retries,  it returns the correct state after the `waitForWritable`. 
   So the test case will be like this:
   1. change the writable to false.
   2. call the `waitForWriable`, it will retry with backoff.
   3. at the same time, change the writable to true.
   4. we should get the true from the step2 call.



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@bookkeeper.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org