-
Notifications
You must be signed in to change notification settings - Fork 15.1k
KAFKA-4923: Add Exaclty-Once Semantics to Streams (testing) #2974
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,6 +60,9 @@ | |
| import java.util.Properties; | ||
| import java.util.concurrent.TimeUnit; | ||
|
|
||
| import static org.apache.kafka.streams.StreamsConfig.EXACTLY_ONCE; | ||
| import static org.apache.kafka.streams.StreamsConfig.PROCESSING_GUARANTEE_CONFIG; | ||
|
|
||
| public class StreamsKafkaClient { | ||
|
|
||
| private static final ConfigDef CONFIG = StreamsConfig.configDef() | ||
|
|
@@ -308,7 +311,7 @@ public MetadataResponse fetchMetadata() { | |
| * | ||
| * @throws StreamsException if brokers have version 0.10.0.x | ||
| */ | ||
| public void checkBrokerCompatibility() throws StreamsException { | ||
| public void checkBrokerCompatibility(final boolean eosEnabled) throws StreamsException { | ||
| final ClientRequest clientRequest = kafkaClient.newClientRequest( | ||
| getAnyReadyBrokerId(), | ||
| new ApiVersionsRequest.Builder(), | ||
|
|
@@ -329,5 +332,19 @@ public void checkBrokerCompatibility() throws StreamsException { | |
| if (apiVersionsResponse.apiVersion(ApiKeys.CREATE_TOPICS.id) == null) { | ||
| throw new StreamsException("Kafka Streams requires broker version 0.10.1.x or higher."); | ||
| } | ||
|
|
||
| if (eosEnabled && !brokerSupportsTransactions(apiVersionsResponse)) { | ||
| throw new StreamsException("Setting " + PROCESSING_GUARANTEE_CONFIG + "=" + EXACTLY_ONCE + " requires broker version 0.11.0.x or higher."); | ||
| } | ||
| } | ||
|
|
||
| private boolean brokerSupportsTransactions(final ApiVersionsResponse apiVersionsResponse) { | ||
| return apiVersionsResponse.apiVersion(ApiKeys.INIT_PRODUCER_ID.id) != null | ||
|
Contributor
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. Do we actually need to check for all of these
Member
Author
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. Don't think there is a strict need -- I thought it might be "cleaner" to check all. But maybe that overkill. Curious what others think about this.
Contributor
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. I guess it doesn't harm.
Contributor
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. Agree that it is safer to check all: though it may unlike to happen but we may remove some of the APIs moving forward. |
||
| && apiVersionsResponse.apiVersion(ApiKeys.ADD_PARTITIONS_TO_TXN.id) != null | ||
| && apiVersionsResponse.apiVersion(ApiKeys.ADD_OFFSETS_TO_TXN.id) != null | ||
| && apiVersionsResponse.apiVersion(ApiKeys.END_TXN.id) != null | ||
| && apiVersionsResponse.apiVersion(ApiKeys.WRITE_TXN_MARKERS.id) != null | ||
| && apiVersionsResponse.apiVersion(ApiKeys.TXN_OFFSET_COMMIT.id) != null; | ||
| } | ||
|
|
||
| } | ||
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.
Can you just add a suppression for the file that needs to have 5 booleans? There is little point in having rules if people are just going to keep on changing the values
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.
There is also little point in adding an exception for each single file that break the rule IMHO. I just think that 4 (and even 5) is a rather small number anyway. (But this goes back to you other comment -- if we only check a single API key, we could keep
4here.)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.
Hmmm. well the point is to not break the rule! If you really feel you need to break the rule then add a suppression