-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-6958: Add new NamedOperation interface to enforce consistency i… #6409
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
streams/src/main/java/org/apache/kafka/streams/kstream/NamedOperation.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.streams.kstream; | ||
|
|
||
| /** | ||
| * Default interface which can be used to personalized the named of operations, internal topics or store. | ||
| */ | ||
| interface NamedOperation<T extends NamedOperation<T>> { | ||
|
|
||
| /** | ||
| * Sets the name to be used for an operation. | ||
| * | ||
| * @param name the name to use. | ||
| * @return an instance of {@link NamedOperation} | ||
| */ | ||
| T withName(final String name); | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
streams/src/main/java/org/apache/kafka/streams/kstream/internals/JoinedInternal.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.kafka.streams.kstream.internals; | ||
|
|
||
| import org.apache.kafka.common.serialization.Serde; | ||
| import org.apache.kafka.streams.kstream.Joined; | ||
|
|
||
| public class JoinedInternal<K, V, VO> extends Joined<K, V, VO> { | ||
|
|
||
| JoinedInternal(final Joined<K, V, VO> joined) { | ||
| super(joined); | ||
| } | ||
|
|
||
| public Serde<K> keySerde() { | ||
| return keySerde; | ||
| } | ||
|
|
||
| public Serde<V> valueSerde() { | ||
| return valueSerde; | ||
| } | ||
|
|
||
| public Serde<VO> otherValueSerde() { | ||
| return otherValueSerde; | ||
| } | ||
|
|
||
| @Override // TODO remove annotation when super.name() is removed | ||
| @SuppressWarnings("deprecation") // this method should not be removed if super.name() is removed | ||
| public String name() { | ||
| return name; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -567,13 +567,15 @@ private <VO, VR> KStream<K, VR> doJoin(final KStream<K, VO> other, | |
| KStreamImpl<K, V> joinThis = this; | ||
| KStreamImpl<K, VO> joinOther = (KStreamImpl<K, VO>) other; | ||
|
|
||
| final JoinedInternal<K, V, VO> joinedInternal = new JoinedInternal<>(joined); | ||
| final String name = joinedInternal.name(); | ||
| if (joinThis.repartitionRequired) { | ||
| final String leftJoinRepartitionTopicName = joined.name() != null ? joined.name() + "-left" : joinThis.name; | ||
| final String leftJoinRepartitionTopicName = name != null ? name + "-left" : joinThis.name; | ||
| joinThis = joinThis.repartitionForJoin(leftJoinRepartitionTopicName, joined.keySerde(), joined.valueSerde()); | ||
| } | ||
|
|
||
| if (joinOther.repartitionRequired) { | ||
| final String rightJoinRepartitionTopicName = joined.name() != null ? joined.name() + "-right" : joinOther.name; | ||
| final String rightJoinRepartitionTopicName = name != null ? name + "-right" : joinOther.name; | ||
| joinOther = joinOther.repartitionForJoin(rightJoinRepartitionTopicName, joined.keySerde(), joined.otherValueSerde()); | ||
| } | ||
|
|
||
|
|
@@ -679,9 +681,12 @@ public <VO, VR> KStream<K, VR> join(final KTable<K, VO> other, | |
| Objects.requireNonNull(other, "other can't be null"); | ||
| Objects.requireNonNull(joiner, "joiner can't be null"); | ||
| Objects.requireNonNull(joined, "joined can't be null"); | ||
|
|
||
| final JoinedInternal<K, V, VO> joinedInternal = new JoinedInternal<>(joined); | ||
| final String name = joinedInternal.name(); | ||
| if (repartitionRequired) { | ||
| final KStreamImpl<K, V> thisStreamRepartitioned = repartitionForJoin( | ||
| joined.name() != null ? joined.name() : name, | ||
| name != null ? name : this.name, | ||
| joined.keySerde(), | ||
| joined.valueSerde() | ||
| ); | ||
|
|
@@ -703,9 +708,11 @@ public <VO, VR> KStream<K, VR> leftJoin(final KTable<K, VO> other, | |
| Objects.requireNonNull(other, "other can't be null"); | ||
| Objects.requireNonNull(joiner, "joiner can't be null"); | ||
| Objects.requireNonNull(joined, "joined can't be null"); | ||
| final JoinedInternal<K, V, VO> joinedInternal = new JoinedInternal<>(joined); | ||
| final String internalName = joinedInternal.name(); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: should this be |
||
| if (repartitionRequired) { | ||
| final KStreamImpl<K, V> thisStreamRepartitioned = repartitionForJoin( | ||
| joined.name() != null ? joined.name() : name, | ||
| internalName != null ? internalName : name, | ||
| joined.keySerde(), | ||
| joined.valueSerde() | ||
| ); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.