Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Commit

Permalink
Fix BenchReadThroughputLatency batch read can't stop problems. (apach…
Browse files Browse the repository at this point in the history
…e#4220)

Fix BenchReadThroughputLatency batch read can't stop problems.
  • Loading branch information
horizonzy authored Mar 18, 2024
1 parent bacd9ac commit ad06dfb
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,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;
Expand All @@ -90,7 +90,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;
Expand All @@ -103,14 +103,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<LedgerEntry> 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();
Expand Down

0 comments on commit ad06dfb

Please sign in to comment.