Skip to content

Conversation

@dao-jun
Copy link
Member

@dao-jun dao-jun commented Nov 9, 2025

Motivation

For protocolHandlers, such as kop.

Modifications

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Does this pull request potentially affect one of the following parts:

If the box was checked, please highlight the changes

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • [] doc-required
  • doc-not-needed
  • doc-complete

# Conflicts:
#	managed-ledger/src/test/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerTest.java
@github-actions github-actions bot added the doc-not-needed Your PR changes do not impact docs label Nov 9, 2025
@dao-jun dao-jun self-assigned this Nov 10, 2025
Comment on lines +769 to +779
/**
* Async read entries.
* Notice: You MUST have a Durable cursor outside of the managed ledger, to protect the ledgers from being deleted.
*
* @param start
* @param numberOfEntriesToRead
* @param callback
* @param ctx
*/
void asyncReadEntries(Position start, long numberOfEntriesToRead, AsyncCallbacks.ReadEntriesCallback callback,
Object ctx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add a callback based API

Comment on lines +781 to +787
/**
* Async read entries.
* Notice: You MUST have a Durable cursor outside of the managed ledger, to protect the ledgers from being deleted.
*
* @param start
* @param numberOfEntriesToRead
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No document is better than documents that are just a template.

Regarding the ledger deletion, it should not be documented here. There is already a document for this: https://pulsar.apache.org/docs/next/cookbooks-retention-expiry/

* @param start
* @param numberOfEntriesToRead
*/
CompletableFuture<List<Entry>> asyncReadEntries(Position start, long numberOfEntriesToRead);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numberOfEntriesToRead should be int.

Additionally, this method does not have maxSizeBytes limit like ManagedCursor#asyncReadEntries

Copy link
Contributor

@BewareMyPower BewareMyPower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please write a PIP since this proposal adds new methods to the ManagedLedger interface

}

int actualReadEntries = getNumberOfEntries(readerPositions);
ReadEntriesCallback callback0 = new InternalReadEntriesCallback(actualReadEntries, callback);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Such callback is complicated, a better solution is to gather all futures of asyncReadEntry and wait for all of them

* @return
*/
@VisibleForTesting
public Map<Long, Pair<Long, Long>> getReaderPositions(Position start, long numberOfEntries) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this method is exposed as a public method, is there still a reason to add asyncReadEntries?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-not-needed Your PR changes do not impact docs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants