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-12648: MINOR - Add TopologyMetadata.Subtopology class for subtopology metadata #10676

Conversation

ableegoldman
Copy link
Contributor

@ableegoldman ableegoldman commented May 12, 2021

Renames the existing Subtopology class + interface to SubtopologyDescription, since that more closely matches what it is/is used for. Then introduces a new Subtopology class which includes basic metadata such as the topic group id and the NamedTopology that this subtopology belongs to, if any.

Also adds an internal NamedTaskId class to expose the namedTopology of a TaskId outside the package. I realized TaskId is part of the public API, so we can't just add a public namedTopology() getter method. I made the namedTopology field protected and removed the getter/moved it to the NamedTaskId class.

There are no actual logical changes or features in this PR, it's just a refactoring. Split these changes out to reduce the LOC in the main PRs.

@ableegoldman ableegoldman marked this pull request as draft May 12, 2021 04:03
@ableegoldman ableegoldman changed the title MINOR: rename TopologyDescription.Subtopology to SubtopologyDescription KAFKA-12648: Pt. 0 - Add TopologyMetadata.Subtopology class for subtopology metadata May 13, 2021
@ableegoldman ableegoldman marked this pull request as ready for review May 13, 2021 01:16
@ableegoldman ableegoldman force-pushed the MINOR-rename-Subtopology-to-SubtopologyDescription branch from 105eca2 to 502c6c7 Compare May 13, 2021 01:26
@ableegoldman ableegoldman force-pushed the MINOR-rename-Subtopology-to-SubtopologyDescription branch from 4c46ddb to 9243a12 Compare May 13, 2021 01:28
@ableegoldman ableegoldman force-pushed the MINOR-rename-Subtopology-to-SubtopologyDescription branch 2 times, most recently from 62bd924 to b54f0d0 Compare May 13, 2021 01:50
@ableegoldman
Copy link
Contributor Author

Ready for review @wcarlson5 @guozhangwang @rodesai

@ableegoldman ableegoldman force-pushed the MINOR-rename-Subtopology-to-SubtopologyDescription branch from b54f0d0 to 6245684 Compare May 13, 2021 01:55
Copy link
Contributor

@wcarlson5 wcarlson5 left a comment

Choose a reason for hiding this comment

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

LGTM!

new InternalTopologyBuilder.Subtopology(0,
Collections.singleton(expectedSourceNode)));
new SubtopologyDescription(0,
Collections.singleton(expectedSourceNode)));
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: are these indents right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, looks like my IDE just reformatted this when it did the renaming.

@@ -59,10 +58,6 @@ public TaskId(final int topicGroupId, final int partition, final String namedTop
}
}

public Optional<String> namedTopology() {
Copy link
Contributor

Choose a reason for hiding this comment

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

If we don't have this could we add something like it to TaskMetadata?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hm, TaskMetadata is also a public class, right? I think we'll need to do something similar in that case, ie add an internal NamedTaskMetadata class that exposes the namedTopology and then you can access it via something like NamedTaskMetadata.extractNamedTopology(TaskMetadata)

It's unfortunate that TaskMetadata has the taskId field as a String, rather than as an actual TaskId object -- not sure what the motivation there was 😕 I might try to do a very small KIP to fix that, and then we won't have to bother with this at all (you can just use the internal NamedTaskId class/method to access the namedTopology

Copy link
Contributor

Choose a reason for hiding this comment

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

It would be defiantly better to just fix the taskId in taskMetadata :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright, here we are: KIP-740: Use TaskId instead of String for the taskId field in TaskMetadata

That was probably the fastest/easiest KIP I've ever written

@ableegoldman ableegoldman changed the title KAFKA-12648: Pt. 0 - Add TopologyMetadata.Subtopology class for subtopology metadata KAFKA-12648: MINOR - Add TopologyMetadata.Subtopology class for subtopology metadata May 13, 2021
@ableegoldman
Copy link
Contributor Author

I'm going to merge this without another committer +1 since it's a minor PR with mostly renaming/wrapping classes. And the PR build is actually completely green for once 🥳

@ableegoldman ableegoldman merged commit 4b27365 into apache:trunk May 13, 2021
ijuma added a commit to ijuma/kafka that referenced this pull request May 16, 2021
…e-allocations-lz4

* apache-github/trunk: (155 commits)
  KAFKA-12728: Upgrade gradle to 7.0.2 and shadow to 7.0.0 (apache#10606)
  KAFKA-12778: Fix QuorumController request timeouts and electLeaders (apache#10688)
  KAFKA-12754: Improve endOffsets for TaskMetadata (apache#10634)
  Rework on KAFKA-3968: fsync the parent directory of a segment file when the file is created (apache#10680)
  MINOR: set replication.factor to 1 to make StreamsBrokerCompatibilityService work with old broker (apache#10673)
  MINOR: prevent cleanup() from being called while Streams is still shutting down (apache#10666)
  KAFKA-8326: Introduce List Serde (apache#6592)
  KAFKA-12697: Add Global Topic and Partition count metrics to the Quorum Controller (apache#10679)
  KAFKA-12648: MINOR - Add TopologyMetadata.Subtopology class for subtopology metadata (apache#10676)
  MINOR: Update jacoco to 0.8.7 for JDK 16 support (apache#10654)
  MINOR: exclude all `src/generated` and `src/generated-test` (apache#10671)
  KAFKA-12772: Move all transaction state transition rules into their states (apache#10667)
  KAFKA-12758 Added `server-common` module to have server side common classes.  (apache#10638)
  MINOR Removed copying storage libraries specifically as they are already copied. (apache#10647)
  KAFKA-5876: KIP-216 Part 4, Apply InvalidStateStorePartitionException for Interactive Queries (apache#10657)
  KAFKA-12747: Fix flakiness in shouldReturnUUIDsWithStringPrefix (apache#10643)
  MINOR: remove unnecessary placeholder from WorkerSourceTask#recordSent (apache#10659)
  MINOR: Remove unused `scalatest` definition from `dependencies.gradle` (apache#10655)
  MINOR: checkstyle version upgrade: 8.20 -> 8.36.2 (apache#10656)
  KAFKA-12464: minor code cleanup and additional logging in constrained sticky assignment (apache#10645)
  ...
Copy link
Contributor

@guozhangwang guozhangwang left a comment

Choose a reason for hiding this comment

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

@ableegoldman do we have a KIP for this change since this is public APIs (not a fan to be picky really)... if not, at least we should document in the upgrade guides.

@ableegoldman
Copy link
Contributor Author

@guozhangwang Ah, shoot, I forgot that the interface name would be public of course..I'll just go ahead and revert that change. I believe the internal class name change should be fine but let me know if there's another name you would prefer

@ableegoldman
Copy link
Contributor Author

Here: #10713

ableegoldman added a commit that referenced this pull request May 18, 2021
In #10676 we renamed the internal Subtopology class that implemented the TopologyDescription.Subtopology interface. By mistake, we also renamed the interface itself, which is a public API. This wasn't really the intended point of that PR, so rather than do a retroactive KIP, let's just reverse the renaming.

Reviewers: Walker Carlson <wcarlson@confluent.io>, Guozhang Wang <guozhang@confluent.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants