Skip to content

Commit e21eb64

Browse files
author
fanjianye
committed
fix replicateRate of batchRead in auto-recover is negative
1 parent 487be97 commit e21eb64

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerFragmentReplicator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -455,9 +455,10 @@ void batchRecoverLedgerFragmentEntry(final long startEntryId,
455455
int entriesToReplicateCnt = (int) (endEntryId - startEntryId + 1);
456456
int maxBytesToReplicate = conf.getReplicationRateByBytes();
457457
if (replicationThrottle != null) {
458-
if (maxBytesToReplicate != -1 && maxBytesToReplicate > averageEntrySize.get() * entriesToReplicateCnt) {
459-
maxBytesToReplicate = averageEntrySize.get() * entriesToReplicateCnt;
460-
}
458+
int bytesToReplicateCnt = averageEntrySize.get() * entriesToReplicateCnt;
459+
bytesToReplicateCnt = bytesToReplicateCnt >= 0 ? bytesToReplicateCnt : Integer.MAX_VALUE;
460+
maxBytesToReplicate = Math.min(maxBytesToReplicate, bytesToReplicateCnt);
461+
461462
replicationThrottle.acquire(maxBytesToReplicate);
462463
}
463464

0 commit comments

Comments
 (0)