Skip to content

Commit 709bef6

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

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,8 +455,9 @@ 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;
458+
long bytesToReplicateCnt = (long) averageEntrySize.get() * entriesToReplicateCnt;
459+
if (bytesToReplicateCnt <= Integer.MAX_VALUE && bytesToReplicateCnt >= 0) {
460+
maxBytesToReplicate = Math.min(maxBytesToReplicate, (int) bytesToReplicateCnt);
460461
}
461462
replicationThrottle.acquire(maxBytesToReplicate);
462463
}

0 commit comments

Comments
 (0)