Skip to content

KAFKA-14247: Define event handler interface and events#12663

Merged
hachikuji merged 25 commits into
apache:trunkfrom
philipnee:consumer-refactor-event-handler-definition
Oct 3, 2022
Merged

KAFKA-14247: Define event handler interface and events#12663
hachikuji merged 25 commits into
apache:trunkfrom
philipnee:consumer-refactor-event-handler-definition

Conversation

@philipnee

@philipnee philipnee commented Sep 19, 2022

Copy link
Copy Markdown
Contributor

https://cwiki.apache.org/confluence/display/KAFKA/Proposal%3A+Consumer+Threading+Model+Refactor

  • We want to abstract away the queues from the new KafkaConsumer using an EventHandler.
  • poll: Retrieve a response from the eventHandler
  • add: Add a request to the handler

In the subsequent PRs, I'll add a backgroundThread inside of the eventHandler to actually consume the events.

*Unit tests

Committer Checklist (excluded from commit message)

  • Verify design and implementation
  • Verify test coverage and CI build status
  • Verify documentation (including upgrade notes)

@philipnee
philipnee marked this pull request as ready for review September 19, 2022 21:30
@philipnee

Copy link
Copy Markdown
Contributor Author

cc @guozhangwang @hachikuji @dajac for review.

@philipnee

Copy link
Copy Markdown
Contributor Author

Thanks @hachikuji and @guozhangwang - I just updated the PR. I'm settling with ApplicationEvent and BackgroundEvent. Also, brief definitions for the abstract classes have been added.

@guozhangwang

Copy link
Copy Markdown
Contributor

Thanks @philipnee , I think we can merge the PR as is since it's new interfaces and if we found anything in follow-up developments we can always come back and change them. So LGTM.

@philipnee

Copy link
Copy Markdown
Contributor Author

Thanks @guozhangwang! Agreed, we can make incremental changes to these implementation as we make more progress.

@philipnee philipnee changed the title [Consumer Refactor] Define event handler interface and events KAFKA-14247: Define event handler interface and events Sep 21, 2022
Documentation on the beahvior
@philipnee
philipnee force-pushed the consumer-refactor-event-handler-definition branch from 1c7be91 to ccb5f14 Compare September 21, 2022 19:27
@philipnee
philipnee requested a review from hachikuji September 23, 2022 22:38
* This class interfaces with the KafkaConsumer and the background thread. It allows the caller to enqueue events via
* the {@code add()} method and to retrieve events via the {@code poll()} method.
*/
public interface EventHandler {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess this is for the application side since we add application events and poll background events. Are we going to need something similar for the background thread as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think we need another handler on the background thread, what I'm thinking is to have the background thread living inside of the handler implementation, process the application events, and produce the background events.

@philipnee
philipnee force-pushed the consumer-refactor-event-handler-definition branch from a45fb02 to 816b285 Compare September 26, 2022 22:59
clean up

documentation

implemented poll and commitSync

clean up

clean up
@philipnee
philipnee force-pushed the consumer-refactor-event-handler-definition branch from 83b6190 to f5b25e6 Compare September 27, 2022 20:58
}
}

maybeSendFetches(); // send new fetches

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would think this would be handled by the background thread.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

the intention was to enqueue a fetch event, I think we still want the poll loop to drive the fetching, right? Maybe a better naming is needed. enqueueFetchEvent() perhaps?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks, @hachikuji - removed this line per your comment.

import java.util.concurrent.TimeoutException;

/**
* This is the prototype of the consumer that uses the {@link EventHandler} to process application events.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think the main thing this doc should mention is that all network IO will be done in a background thread instead of being partially driven by the application calling poll(). Also, perhaps it would be helpful to link to the wiki so that people can understand a little better?

@hachikuji hachikuji left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, LGTM. Hopefully this is the beginning of the end of the single-threaded consumer.

@hachikuji
hachikuji merged commit c3690a3 into apache:trunk Oct 3, 2022
vvcephei pushed a commit that referenced this pull request Oct 20, 2022
Adds skeleton of the background thread.

1-pager: https://cwiki.apache.org/confluence/display/KAFKA/Proposal%3A+Consumer+Threading+Model+Refactor
Continuation of #12663

Reviewers: Guozhang Wang <guozhang@apache.org>, Kirk True <kirk@mustardgrain.com>, John Roesler <vvcephei@apache.org>
guozhangwang pushed a commit to guozhangwang/kafka that referenced this pull request Jan 25, 2023
Add some initial interfaces to kick off https://cwiki.apache.org/confluence/display/KAFKA/Proposal%3A+Consumer+Threading+Model+Refactor. We introduce an `EventHandler` interface and a new consumer implementation which demonstrates how it will be used. Subsequent PRs will continue to flesh out the implementation.

Reviewers: Guozhang Wang wangguoz@gmail.com, Jason Gustafson <jason@confluent.io>
guozhangwang pushed a commit to guozhangwang/kafka that referenced this pull request Jan 25, 2023
…2672)

Adds skeleton of the background thread.

1-pager: https://cwiki.apache.org/confluence/display/KAFKA/Proposal%3A+Consumer+Threading+Model+Refactor
Continuation of apache#12663

Reviewers: Guozhang Wang <guozhang@apache.org>, Kirk True <kirk@mustardgrain.com>, John Roesler <vvcephei@apache.org>
@philipnee philipnee added KIP-848 The Next Generation of the Consumer Rebalance Protocol ctr Consumer Threading Refactor (KIP-848) labels May 23, 2023
rutvijmehta-harness pushed a commit to rutvijmehta-harness/kafka that referenced this pull request Feb 9, 2024
Add some initial interfaces to kick off https://cwiki.apache.org/confluence/display/KAFKA/Proposal%3A+Consumer+Threading+Model+Refactor. We introduce an `EventHandler` interface and a new consumer implementation which demonstrates how it will be used. Subsequent PRs will continue to flesh out the implementation.

Reviewers: Guozhang Wang wangguoz@gmail.com, Jason Gustafson <jason@confluent.io>
rutvijmehta-harness added a commit to rutvijmehta-harness/kafka that referenced this pull request Feb 9, 2024
…#30)

Add some initial interfaces to kick off https://cwiki.apache.org/confluence/display/KAFKA/Proposal%3A+Consumer+Threading+Model+Refactor. We introduce an `EventHandler` interface and a new consumer implementation which demonstrates how it will be used. Subsequent PRs will continue to flesh out the implementation.

Reviewers: Guozhang Wang wangguoz@gmail.com, Jason Gustafson <jason@confluent.io>

Co-authored-by: Philip Nee <pnee@confluent.io>
rutvijmehta-harness pushed a commit to rutvijmehta-harness/kafka that referenced this pull request Feb 9, 2024
…2672)

Adds skeleton of the background thread.

1-pager: https://cwiki.apache.org/confluence/display/KAFKA/Proposal%3A+Consumer+Threading+Model+Refactor
Continuation of apache#12663

Reviewers: Guozhang Wang <guozhang@apache.org>, Kirk True <kirk@mustardgrain.com>, John Roesler <vvcephei@apache.org>
rutvijmehta-harness added a commit to rutvijmehta-harness/kafka that referenced this pull request Feb 9, 2024
…2672) (#76)

Adds skeleton of the background thread.

1-pager: https://cwiki.apache.org/confluence/display/KAFKA/Proposal%3A+Consumer+Threading+Model+Refactor
Continuation of apache#12663

Reviewers: Guozhang Wang <guozhang@apache.org>, Kirk True <kirk@mustardgrain.com>, John Roesler <vvcephei@apache.org>

Co-authored-by: Philip Nee <pnee@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ctr Consumer Threading Refactor (KIP-848) KIP-848 The Next Generation of the Consumer Rebalance Protocol

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants