BewareMyPower opened a new pull request #9257:
URL: https://github.com/apache/pulsar/pull/9257


   ### Motivation
   
   
[PIP-70](https://github.com/apache/pulsar/wiki/PIP-70%3A-Introduce-lightweight-broker-entry-metadata)
 introduced lightweight broker entry metadata which is added by related 
interceptor like `AppendBrokerTimestampMetadataInterceptor` before being 
written to bookie asynchronously. However, in the callback when entries are 
written to bookie successfully, the caller side can only get the ledger id and 
entry id, see `PublishContext#completed`:
   
   ```java
   void completed(Exception e, long ledgerId, long entryId);
   ```
   
   Currently there's no way to get the broker entry data in publish callback. 
We can access the interceptor's internal field but it may be overwritten by the 
next entry's broker entry metadata because the interceptor changes the internal 
fields when the entry was sent while the callback is invoked when the send is 
done.
   
   This PR intends to expose the entry's data to callbacks, including managed 
ledger's add callback and the publish context's complete callback. If we want 
to make use of broker entry metadata or the old message metadata in future, we 
can use the new callbacks.
   
   ### Modifications
   
   - Add an extra `ByteBuf` argument to `AddEntryCallback#addComplete` to 
expose the entry data.
   - Add a default method `setMetadataFromEntryData` to `PublishContext` 
interface to allow implementer side retrieve some metadata from entry data.
   - [WIP] Add tests for `AddEntryCallback#addComplete`.
   - [WIP] Add tests for `PublishContext#setMetadataFromEntryData`.
   
   ### 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 `yes` was chosen, please highlight the changes*
   
     - Dependencies (does it add or upgrade a dependency): (yes / no)
     - The public API: (yes / no)
     - The schema: (yes / no / don't know)
     - The default values of configurations: (yes / no)
     - The wire protocol: (yes / no)
     - The rest endpoints: (yes / no)
     - The admin cli options: (yes / no)
     - Anything that affects deployment: (yes / no / don't know)
   
   ### Documentation
   
     - Does this pull request introduce a new feature? (yes / no)
     - If yes, how is the feature documented? (not applicable / docs / JavaDocs 
/ not documented)
     - If a feature is not applicable for documentation, explain why?
     - If a feature is not documented yet in this PR, please create a followup 
issue for adding the documentation
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to