You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/08/09 07:43:56 UTC
[GitHub] [pulsar] Technoboy- commented on a diff in pull request #12258: [pulsar-broker] Support caching to drain backlog consumers
Technoboy- commented on code in PR #12258:
URL: https://github.com/apache/pulsar/pull/12258#discussion_r941009063
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java:
##########
@@ -4144,4 +4156,41 @@ public void checkInactiveLedgerAndRollOver() {
}
}
+
+ public void checkCursorsToCacheEntries() {
+ if (minBacklogCursorsForCaching < 1) {
+ return;
+ }
+ Iterator<ManagedCursor> it = cursors.iterator();
+ Map<ManagedCursorImpl, Long> cursorBacklogMap = new HashMap<>();
+ while (it.hasNext()) {
+ ManagedCursorImpl cursor = (ManagedCursorImpl) it.next();
+ if (cursor.isDurable()) {
+ cursorBacklogMap.put(cursor, cursor.getNumberOfEntries());
+ }
+ }
+ int cursorsInSameBacklogRange = 0;
+ for (java.util.Map.Entry<ManagedCursorImpl, Long> cursor : cursorBacklogMap.entrySet()) {
+ cursorsInSameBacklogRange = 0;
+ for (java.util.Map.Entry<ManagedCursorImpl, Long> other : cursorBacklogMap.entrySet()) {
+ if (cursor.equals(other)) {
+ continue;
+ }
+ long backlog = cursor.getValue();
+ // if backlog difference is > maxBacklogBetweenCursorsForCaching (eg: 10000) then cached entry might be
+ // invalidated by the time so, skip caching such long range messages.
+ if (backlog < minBacklogEntriesForCaching) {
+ continue;
+ }
+ if (Math.abs(backlog - other.getValue()) <= maxBacklogBetweenCursorsForCaching) {
+ cursorsInSameBacklogRange++;
+ }
+ }
+ cursor.getKey().setCacheReadEntry(cursorsInSameBacklogRange >= minBacklogCursorsForCaching);
+ if (log.isDebugEnabled()) {
+ log.info("{} Enabling cache read = {} for {}", name,
Review Comment:
Oh, a mistake here.
--
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: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org