jigar-bhati commented on code in PR #267:
URL:
https://github.com/apache/flink-connector-kafka/pull/267#discussion_r3761953672
##########
flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/source/KafkaPropertiesUtil.java:
##########
@@ -36,6 +39,41 @@ public static void copyProperties(@Nonnull Properties from,
@Nonnull Properties
}
}
+ /** Resolves an explicit cluster or global reset strategy before the
initializer default. */
+ public static String resolveAutoOffsetResetStrategy(
+ @Nonnull Properties globalProperties,
+ @Nonnull Properties clusterProperties,
+ @Nonnull OffsetsInitializer startingOffsetsInitializer) {
+ String clusterReset =
+
clusterProperties.getProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG);
+ if (clusterReset != null) {
+ return clusterReset;
+ }
+
+ String globalReset =
globalProperties.getProperty(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG);
+ if (globalReset != null) {
+ return globalReset;
+ }
+
+ return
startingOffsetsInitializer.getAutoOffsetResetStrategy().name().toLowerCase();
Review Comment:
Done. `resolveAutoOffsetResetStrategy(...)` now uses the nested
`Properties#getProperty` precedence and returns the parsed
`OffsetResetStrategy`.
##########
flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/dynamic/source/enumerator/DynamicKafkaSourceEnumerator.java:
##########
@@ -534,12 +534,27 @@ private KafkaSourceEnumerator
createEnumeratorWithAssignedTopicPartitions(
KafkaPropertiesUtil.copyProperties(properties, consumerProps);
DynamicKafkaSourceOptions.removeRemovedClusterRetentionOption(consumerProps);
KafkaPropertiesUtil.setClientIdPrefix(consumerProps, kafkaClusterId);
+ String effectiveOffsetResetStrategy =
+ KafkaPropertiesUtil.resolveAutoOffsetResetStrategy(
+ properties, fetchedProperties,
effectiveStartingOffsetsInitializer);
+ if (KafkaPropertiesUtil.hasOpposingOffsetResetStrategies(
Review Comment:
Done. The dynamic warning now runs from
`DynamicKafkaSourceBuilder#sanityCheck`; the enumerator only resolves the
effective strategy and passes it to Kafka.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]