-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
KAFKA-18453: Add StreamsTopology class to group coordinator #18446
Conversation
Adds a class that represent the topology of a Streams group to the group coordinator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/streams/StreamsTopology.java
Outdated
Show resolved
Hide resolved
import java.util.stream.Stream; | ||
|
||
/** | ||
* Contains all information related to a topology of a Streams group. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should specify that this is the requested topology that has not been configured according to the topics available on the broker. So differentiate to ConfiguredTopology. It doesn't really contain "all information related to a topology".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough.
/** | ||
* Contains all information related to a topology of a Streams group. | ||
* <p> | ||
* This class is immutable and is fully backed by records stored in the __consumer_offsets topic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know I wrote that, so I'm talking to myself here, but the subtopologies
objects aren't actually immutable. We don't want to mutate it, but saying it's immutable is probably misleady.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough! I ensured that the map is unmodifiable at least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair enough! I ensured that the map is unmodifiable at least.
* Contains all information related to a topology of a Streams group. | ||
* <p> | ||
* This class is immutable and is fully backed by records stored in the __consumer_offsets topic. | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's also useful to specify, that the main purpose of this class compared to StreamGroupTopologyValue
is that we have a map for looking up a subtopology by name in constant time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Map<String, Subtopology> subtopologies) { | ||
|
||
/** | ||
* Returns the set of topics required by the topology. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These javadocs seem somewhat void of content. They say nothing that isn't implied by the function name. If we are going to put these javadocs, please specify what it means to be "required".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/** | ||
* Creates a instance of StreamsTopology from a StreamsGroupTopologyValue record. | ||
* | ||
* @param record StreamsGroupTopologyValue record |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think most other classes use full sentences, with initial character capitalized and trailing period in @param
and @return
. Applies to several javadoc comments here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
)); | ||
} | ||
|
||
private Subtopology mkSubtopology2() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally preferred the unit tests when they were self-contained, which is easier to understand. There is no benefit to making this a separate method, and mkSubtopology2
doesn't mean anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree.
There is at least the benefit to not duplicate the code for the creation of the subtopology.
What do you mean with
mkSubtopology2
doesn't mean anything
You look once at the mkSubtopologyX
methods and understand the created subtopologies and then when you look at the tests you do not need to understand the subtopology again for each test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, as stated this is just my preference - self-contained tests go a long way, and sharing data between tests easily becomes hard to deal with. This class won't grow much, so either way is probably fine. Agreed to keep it like this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the updates!
Adds a class that represent the topology of a Streams group to the group coordinator.
More detailed description of your change,
if necessary. The PR title and PR message become
the squashed commit message, so use a separate
comment to ping reviewers.
Summary of testing strategy (including rationale)
for the feature or bug fix. Unit and/or integration
tests are expected for any behaviour change and
system tests should be considered for larger changes.
Committer Checklist (excluded from commit message)