Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add broker query event listener #11437

Merged
merged 12 commits into from
Sep 26, 2023

Conversation

tibrewalpratik17
Copy link
Contributor

@tibrewalpratik17 tibrewalpratik17 commented Aug 24, 2023

labels:

  • feature

In #10606 we discussed adding the support for pluggable query event listener. This PR scaffolds the logic for that and is first among series of PRs.

In this PR, we are adding the support for broker query-level event listener. We can register a custom implementation for a broker-level event-listener and pass the class path as a config - pinot.broker.event.listener.factory.className and define our own implementation of onQueryCompletion method of the BrokerQueryEventListener interface.

Tested this locally by logging the BrokerQueryEventInfo object values in the NoOpBrokerQueryEventListener implementation. It worked as expected.

Re-posting the design doc here -- https://docs.google.com/document/d/11UeU6eNTlyEJ9G096j9XT57QuWgbuCtwnfTC5TQpQ8M/edit#heading=h.uc9rahlz5o0x

cc @ankitsultana

@codecov-commenter
Copy link

codecov-commenter commented Aug 24, 2023

Codecov Report

Merging #11437 (8b83318) into master (a485778) will increase coverage by 0.12%.
Report is 83 commits behind head on master.
The diff coverage is 20.83%.

@@             Coverage Diff              @@
##             master   #11437      +/-   ##
============================================
+ Coverage     63.04%   63.17%   +0.12%     
+ Complexity     1108     1106       -2     
============================================
  Files          2320     2325       +5     
  Lines        124520   124502      -18     
  Branches      19011    18989      -22     
============================================
+ Hits          78507    78651     +144     
+ Misses        40422    40257     -165     
- Partials       5591     5594       +3     
Flag Coverage Δ
integration <0.01% <0.00%> (ø)
integration1 <0.01% <0.00%> (ø)
integration2 0.00% <0.00%> (ø)
java-11 63.12% <20.83%> (+0.10%) ⬆️
java-17 63.01% <20.83%> (+0.11%) ⬆️
java-20 63.04% <20.83%> (+0.13%) ⬆️
temurin 63.17% <20.83%> (+0.12%) ⬆️
unittests 63.16% <20.83%> (+0.12%) ⬆️
unittests1 67.41% <0.00%> (-0.12%) ⬇️
unittests2 14.53% <20.83%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
...roker/requesthandler/GrpcBrokerRequestHandler.java 0.00% <0.00%> (ø)
...ntlistener/query/NoOpBrokerQueryEventListener.java 0.00% <0.00%> (ø)
...ener/query/PinotBrokerQueryEventListenerUtils.java 0.00% <0.00%> (ø)
.../apache/pinot/spi/trace/DefaultRequestContext.java 0.00% <0.00%> (ø)
...ava/org/apache/pinot/spi/trace/RequestContext.java 0.00% <ø> (ø)
...va/org/apache/pinot/spi/utils/CommonConstants.java 21.11% <ø> (ø)
...roker/requesthandler/BaseBrokerRequestHandler.java 46.22% <50.00%> (-0.09%) ⬇️
...e/pinot/broker/broker/helix/BaseBrokerStarter.java 72.24% <100.00%> (+0.32%) ⬆️
...requesthandler/MultiStageBrokerRequestHandler.java 19.84% <100.00%> (-0.82%) ⬇️
...thandler/SingleConnectionBrokerRequestHandler.java 18.42% <100.00%> (ø)

... and 132 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@tibrewalpratik17 tibrewalpratik17 force-pushed the add_event_listener branch 2 times, most recently from e51ab49 to 0e803b5 Compare August 25, 2023 10:14
Copy link
Contributor

@Jackie-Jiang Jackie-Jiang left a comment

Choose a reason for hiding this comment

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

Thanks for starting this effort!

@ankitsultana
Copy link
Contributor

@tibrewalpratik17 : Thanks for raising this. Can you enumerate the remaining tasks we need to do in #10606 so that @Jackie-Jiang is also aware of the remaining changes.

@tibrewalpratik17 tibrewalpratik17 force-pushed the add_event_listener branch 3 times, most recently from ee9e58d to d0cd024 Compare September 3, 2023 07:08
Copy link
Contributor

@ankitsultana ankitsultana left a comment

Choose a reason for hiding this comment

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

Lgtm. Left some minor comments. cc: @walterddr @Jackie-Jiang can you folks also take a look?

public interface BrokerQueryEventListener {

void init(PinotConfiguration eventListenerConfiguration);
void onQueryCompletion(BrokerQueryEventInfo brokerQueryEventInfo);
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to also include onQueryFailure? Counting failed query as completed could cause confusion and unexpected behavior

Copy link
Contributor Author

@tibrewalpratik17 tibrewalpratik17 Sep 15, 2023

Choose a reason for hiding this comment

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

Umm we can have a separate onQueryFailure as well but I was planning to leverage errorCode to differentiate between onQuerySuccess and onQueryFailure. But let me know if onQueryCompletion is really confusing.

Copy link
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

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

looks good to me on the higher level.

Copy link
Contributor

@walterddr walterddr left a comment

Choose a reason for hiding this comment

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

did another pass and looks good mostly. please kindly follow up with comments

@Jackie-Jiang
Copy link
Contributor

@siddharthteotia @jackjlli Can you also help take a look at this PR? I think this should be very similar to what LinkedIn is doing

@tibrewalpratik17
Copy link
Contributor Author

Hey @Jackie-Jiang @walterddr can we merge this?

@Jackie-Jiang Jackie-Jiang added documentation Configuration Config changes (addition/deletion/change in behavior) labels Sep 26, 2023
@Jackie-Jiang Jackie-Jiang merged commit 1748be4 into apache:master Sep 26, 2023
21 checks passed
Copy link
Member

@jackjlli jackjlli left a comment

Choose a reason for hiding this comment

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

LGTM on LinkedIn side. Thanks for making the code change!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Configuration Config changes (addition/deletion/change in behavior) documentation feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants