dao-jun commented on code in PR #23180:
URL: https://github.com/apache/pulsar/pull/23180#discussion_r1725635508
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/ReadEntryUtils.java:
##########
@@ -18,21 +18,32 @@
*/
package org.apache.bookkeeper.mledger.impl.cache;
+import com.google.common.annotations.VisibleForTesting;
import java.util.concurrent.CompletableFuture;
import org.apache.bookkeeper.client.api.LedgerEntries;
+import org.apache.bookkeeper.client.api.LedgerMetadata;
import org.apache.bookkeeper.client.api.ReadHandle;
import org.apache.bookkeeper.mledger.ManagedLedger;
import org.apache.bookkeeper.mledger.ManagedLedgerException;
-class ReadEntryUtils {
+@VisibleForTesting
+public class ReadEntryUtils {
- static CompletableFuture<LedgerEntries> readAsync(ManagedLedger ml,
ReadHandle handle, long firstEntry,
- long lastEntry) {
+ @VisibleForTesting
+ public static CompletableFuture<LedgerEntries> readAsync(ManagedLedger ml,
ReadHandle handle, long firstEntry,
+ long lastEntry, boolean
useBookkeeperV2WireProtocol) {
if (ml.getOptionalLedgerInfo(handle.getId()).isEmpty()) {
// The read handle comes from another managed ledger, in this
case, we can only compare the entry range with
// the LAC of that read handle. Specifically, it happens when this
method is called by a
// ReadOnlyManagedLedgerImpl object.
- return handle.readAsync(firstEntry, lastEntry);
+ int entriesToRead = (int) (lastEntry - firstEntry + 1);
+ // Batch read is not supported for striped ledgers.
+ LedgerMetadata m = handle.getLedgerMetadata();
+ boolean isStriped = m.getEnsembleSize() != m.getWriteQuorumSize();
+ if (!useBatchRead(entriesToRead, useBookkeeperV2WireProtocol,
isStriped)) {
+ return handle.readAsync(firstEntry, lastEntry);
+ }
+ return handle.batchReadAsync(firstEntry, entriesToRead, 0);
Review Comment:
> If maxSize = 0, info log will be printed for each call, which will affect
performance.
https://github.com/apache/bookkeeper/blob/7c41204506122ed6904289f4814d4130274874aa/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerHandle.java#L955-L967
>
> ```
> private CompletableFuture<LedgerEntries>
batchReadEntriesInternalAsync(long startEntry, int maxCount, long maxSize,
> boolean isRecoveryRead) {
> int nettyMaxFrameSizeBytes =
clientCtx.getConf().nettyMaxFrameSizeBytes;
> if (maxSize > nettyMaxFrameSizeBytes) {
> LOG.info(
> "The max size is greater than nettyMaxFrameSizeBytes, use
nettyMaxFrameSizeBytes:{} to replace it.",
> nettyMaxFrameSizeBytes);
> maxSize = nettyMaxFrameSizeBytes;
> }
> if (maxSize <= 0) {
> LOG.info("The max size is negative, use
nettyMaxFrameSizeBytes:{} to replace it.", nettyMaxFrameSizeBytes);
> maxSize = nettyMaxFrameSizeBytes;
> }
> ```
https://github.com/apache/bookkeeper/pull/4485 I created a PR to change the
log level to debug
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]