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

KAFKA-18453: Add StreamsTopology class to group coordinator #18446

Merged
merged 4 commits into from
Jan 9, 2025

Conversation

cadonna
Copy link
Contributor

@cadonna cadonna commented Jan 8, 2025

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)

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

Adds a class that represent the topology of a Streams group to
the group coordinator.
@github-actions github-actions bot added the triage PRs from the community label Jan 8, 2025
@cadonna cadonna requested review from bbejeck and lucasbru January 8, 2025 16:45
Copy link
Member

@lucasbru lucasbru 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 the PR!

import java.util.stream.Stream;

/**
* Contains all information related to a topology of a Streams group.
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fair enough.

Copy link
Contributor Author

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.
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.
*
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor Author

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.
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

));
}

private Subtopology mkSubtopology2() {
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

@lucasbru lucasbru left a 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!

@cadonna cadonna added streams core Kafka Broker KIP-1071 PRs related to KIP-1071 and removed triage PRs from the community labels Jan 9, 2025
@cadonna cadonna merged commit 11459ae into apache:trunk Jan 9, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Kafka Broker KIP-1071 PRs related to KIP-1071 streams
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants