Github user tzulitai commented on a diff in the pull request:

    https://github.com/apache/flink/pull/3915#discussion_r124966340
  
    --- Diff: 
flink-connectors/flink-connector-kafka-base/src/main/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaConsumerBase.java
 ---
    @@ -697,13 +738,19 @@ protected static void 
initializeSubscribedPartitionsToStartOffsets(
                        int indexOfThisSubtask,
                        int numParallelSubtasks,
                        StartupMode startupMode,
    +                   Date specificStartupDate,
                        Map<KafkaTopicPartition, Long> specificStartupOffsets) {
     
                for (int i = 0; i < kafkaTopicPartitions.size(); i++) {
                        if (i % numParallelSubtasks == indexOfThisSubtask) {
    -                           if (startupMode != 
StartupMode.SPECIFIC_OFFSETS) {
    -                                   
subscribedPartitionsToStartOffsets.put(kafkaTopicPartitions.get(i), 
startupMode.getStateSentinel());
    -                           } else {
    +                           if (startupMode == 
StartupMode.SPECIFIC_TIMESTAMP) {
    +                                   if (specificStartupDate == null) {
    +                                           throw new 
IllegalArgumentException(
    +                                                   "Startup mode for the 
consumer set to " + StartupMode.SPECIFIC_TIMESTAMP +
    +                                                           ", but no 
specific timestamp were specified");
    +                                   }
    +                                   
subscribedPartitionsToStartOffsets.put(kafkaTopicPartitions.get(i), 
specificStartupDate.getTime());
    --- End diff --
    
    This is the main problem:
    following the original design pattern, it would be better to place a 
`KafkaTopicPartitionStateSentinel` here instead of eagerly converting the 
`Date` to a specific offset. We only convert the date to specific offsets when 
we're about to start consuming the partition (i.e. in `KafkaConsumer` thread).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to