diff --git a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java index 5c04558b84d..af1be89323b 100644 --- a/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java +++ b/bookkeeper-benchmark/src/main/java/org/apache/bookkeeper/benchmark/BenchReadThroughputLatency.java @@ -78,7 +78,7 @@ private static void readLedger(ClientConfiguration conf, long ledgerId, byte[] p BookKeeper bk = null; long time = 0; long entriesRead = 0; - long lastRead = 0; + long lastRead = -1; int nochange = 0; long absoluteLimit = 5000000; @@ -89,7 +89,7 @@ private static void readLedger(ClientConfiguration conf, long ledgerId, byte[] p lh = bk.openLedgerNoRecovery(ledgerId, BookKeeper.DigestType.CRC32, passwd); long lastConfirmed = Math.min(lh.getLastAddConfirmed(), absoluteLimit); - if (lastConfirmed == lastRead) { + if (lastConfirmed <= lastRead + 1) { nochange++; if (nochange == 10) { break; @@ -102,14 +102,14 @@ private static void readLedger(ClientConfiguration conf, long ledgerId, byte[] p } long starttime = System.nanoTime(); - while (entriesRead <= lastConfirmed) { + while (lastRead < lastConfirmed) { long nextLimit = lastRead + 100000; Enumeration entries; if (batchEntries <= 0) { long readTo = Math.min(nextLimit, lastConfirmed); entries = lh.readEntries(lastRead + 1, readTo); } else { - entries = lh.batchReadEntries(lastRead, batchEntries, -1); + entries = lh.batchReadEntries(lastRead + 1, batchEntries, -1); } while (entries.hasMoreElements()) { LedgerEntry e = entries.nextElement();