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-6729: Reuse source topics for source KTable's materialized store's changelog #5017

Merged
merged 8 commits into from May 17, 2018

Conversation

guozhangwang
Copy link
Contributor

@guozhangwang guozhangwang commented May 15, 2018

  1. In InternalTopologyBuilder#topicGroups, which is used in StreamsPartitionAssignor, look for book-kept storeToChangelogTopic map before creating a new internal changelog topics. In this way if the source KTable is created, its source topic stored in storeToChangelogTopic will be used.

  2. Added unit test (confirmed that without 1) it will fail).

  3. MINOR: removed TODOs that are related to removed KStreamBuilder.

  4. MINOR: removed TODOs in StreamsBuilderTest util functions and replaced with TopologyWrapper.

  5. MINOR: removed StreamsBuilderTest#testFrom as it is already covered by TopologyTest#shouldNotAllowToAddSourcesWithSameName, plus it requires KStreamImpl.SOURCE_NAME which should be a package private field of the KStreamImpl.

Committer Checklist (excluded from commit message)

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

@guozhangwang
Copy link
Contributor Author

@mjsax @bbejeck @xvrl for reviews.

@@ -192,7 +182,7 @@ public void shouldProcessViaThroughTopic() {
}

@Test
public void testMerge() {
public void ShouldMergeStreams() {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: camel case

Copy link
Member

Choose a reason for hiding this comment

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

Please fix this, too.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is just a renaming to make its name consistent with others, I will rename it with non-capitalized name.

Copy link
Contributor

@vvcephei vvcephei left a comment

Choose a reason for hiding this comment

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

fwiw, this looks good to me.

Copy link
Contributor

@bbejeck bbejeck left a comment

Choose a reason for hiding this comment

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

Thanks, @guozhangwang LGTM

@bbejeck
Copy link
Contributor

bbejeck commented May 15, 2018

retest this please

if (!stateChangelogTopics.containsKey(topicName)) {
final InternalTopicConfig internalTopicConfig = createChangelogTopicConfig(stateFactory, topicName);
stateChangelogTopics.put(topicName, internalTopicConfig);
}
Copy link
Member

Choose a reason for hiding this comment

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

Can this be simplified with a single if-then-else checking storeToChangelogTopic.containsKey(stateFactory.name()) once?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that storeToChangelogTopic and stateChangelogTopics are different :) The former is pre-built when the DSL is parsed, while the latter is built within the topicGroups to get the changelog topic configs for topics related to the topic group, a.k.a the sub-topology alone.

@@ -174,7 +173,7 @@ public Integer apply(Integer value1, Integer value2) {
1 + // to
2 + // through
1, // process
StreamsBuilderTest.internalTopologyBuilder(builder).setApplicationId("X").build(null).processors().size());
TopologyWrapper.getInternalTopologyBuilder(builder.build()).setApplicationId("X").build(null).processors().size());
Copy link
Member

Choose a reason for hiding this comment

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

nit: fix indention

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack.

@bbejeck
Copy link
Contributor

bbejeck commented May 16, 2018

retest this please

@guozhangwang
Copy link
Contributor Author

@mjsax addressed comments.

@@ -58,13 +55,6 @@
private final StreamsBuilder builder = new StreamsBuilder();
private final Properties props = StreamsTestUtils.topologyTestConfig(Serdes.String(), Serdes.String());

@Test(expected = TopologyException.class)
public void testFrom() {
Copy link
Member

Choose a reason for hiding this comment

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

Why do we remove this test? Rename -> shouldNotAllowToResueAutoGeneratedProcessorName ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is just a renaming to make its name consistent with others, I will rename it with non-capitalized name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

EDIT: actually for this test, I removed it because it was covered in TopologyTest#shouldNotAllowToAddSourcesWithSameName.

Copy link
Member

@mjsax mjsax left a comment

Choose a reason for hiding this comment

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

LGTM.

@guozhangwang guozhangwang merged commit 1a324d7 into apache:trunk May 17, 2018
ying-zheng pushed a commit to ying-zheng/kafka that referenced this pull request Jul 6, 2018
…e's changelog (apache#5017)

1. In InternalTopologyBuilder#topicGroups, which is used in StreamsPartitionAssignor, look for book-kept storeToChangelogTopic map before creating a new internal changelog topics. In this way if the source KTable is created, its source topic stored in storeToChangelogTopic will be used.

2. Added unit test (confirmed that without 1) it will fail).

3. MINOR: removed TODOs that are related to removed KStreamBuilder.

4. MINOR: removed TODOs in StreamsBuilderTest util functions and replaced with TopologyWrapper.

5. MINOR: removed StreamsBuilderTest#testFrom as it is already covered by TopologyTest#shouldNotAllowToAddSourcesWithSameName, plus it requires KStreamImpl.SOURCE_NAME which should be a package private field of the KStreamImpl.

Reviewers: John Roesler <john@confluent.io>, Bill Bejeck <bill@confluent.io>, Matthias
 J. Sax <matthias@confluent.io>
@guozhangwang guozhangwang deleted the K6729-reuse-source-topic branch April 24, 2020 23:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants