zachjsh commented on code in PR #16190:
URL: https://github.com/apache/druid/pull/16190#discussion_r1566575886
##########
extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisor.java:
##########
@@ -444,4 +447,56 @@ public KafkaSupervisorTuningConfig getTuningConfig()
{
return spec.getTuningConfig();
}
+
+ @Override
+ protected Map<KafkaTopicPartition, Long> getOffsetsFromMetadataStorage()
+ {
+ final DataSourceMetadata dataSourceMetadata = retrieveDataSourceMetadata();
+ if (dataSourceMetadata instanceof KafkaDataSourceMetadata
+ && checkSourceMetadataMatch(dataSourceMetadata)) {
+ @SuppressWarnings("unchecked")
+ SeekableStreamSequenceNumbers<KafkaTopicPartition, Long> partitions =
((KafkaDataSourceMetadata) dataSourceMetadata)
+ .getSeekableStreamSequenceNumbers();
+ if (partitions != null && partitions.getPartitionSequenceNumberMap() !=
null) {
+ Map<KafkaTopicPartition, Long> partitionOffsets = new HashMap<>();
+ Set<String> topicMisMatchLogged = new HashSet<>();
+ boolean isMultiTopic = getIoConfig().isMultiTopic();
+ Pattern pattern = isMultiTopic ?
Pattern.compile(getIoConfig().getStream()) : null;
+
partitions.getPartitionSequenceNumberMap().forEach((kafkaTopicPartition, value)
-> {
+ final boolean match;
+ final String matchValue;
+ // previous offsets are from multi-topic config
+ if (kafkaTopicPartition.topic().isPresent()) {
+ matchValue = kafkaTopicPartition.topic().get();
+ } else {
+ // previous offsets are from single topic config
+ matchValue = partitions.getStream();
+ }
+
+ match = pattern != null
+ ? pattern.matcher(matchValue).matches()
+ : getIoConfig().getStream().equals(matchValue);
+
+ if (!match && !topicMisMatchLogged.contains(matchValue)) {
+ log.warn(
+ "Topic/stream in metadata storage [%s] doesn't match spec
topic/stream [%s], ignoring stored sequences",
Review Comment:
I prefer the original wording, if you dont feel strongly about this. Also
this is the same as the base class.
##########
extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisor.java:
##########
@@ -444,4 +447,56 @@ public KafkaSupervisorTuningConfig getTuningConfig()
{
return spec.getTuningConfig();
}
+
Review Comment:
added
##########
extensions-core/kafka-indexing-service/src/main/java/org/apache/druid/indexing/kafka/KafkaSeekableStreamStartSequenceNumbers.java:
##########
@@ -0,0 +1,220 @@
+/*
+ * 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.druid.indexing.kafka;
+
+import com.fasterxml.jackson.annotation.JsonTypeName;
+import org.apache.druid.data.input.kafka.KafkaTopicPartition;
+import org.apache.druid.indexing.seekablestream.SeekableStreamSequenceNumbers;
+import
org.apache.druid.indexing.seekablestream.SeekableStreamStartSequenceNumbers;
+import org.apache.druid.java.util.common.IAE;
+import org.apache.druid.utils.CollectionUtils;
+
+import javax.annotation.Nullable;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Pattern;
+import java.util.stream.Collectors;
+
+@JsonTypeName(SeekableStreamStartSequenceNumbers.TYPE)
+public class KafkaSeekableStreamStartSequenceNumbers extends
SeekableStreamStartSequenceNumbers<KafkaTopicPartition, Long>
+{
+ private static final String TYPE = "start";
+ private final boolean isMultiTopicPartition;
+
+ public KafkaSeekableStreamStartSequenceNumbers(
+ String stream,
+ String topic,
+ Map<KafkaTopicPartition, Long> partitionSequenceNumberMap,
+ Map<KafkaTopicPartition, Long> partitionOffsetMap,
+ @Nullable Set<KafkaTopicPartition> exclusivePartitions
+ )
+ {
+ super(stream, topic, partitionSequenceNumberMap, partitionOffsetMap,
exclusivePartitions);
+ // how to know it topicPattern if the partitionSequenceNumberMap is empty?
+ isMultiTopicPartition = !partitionSequenceNumberMap.isEmpty() &&
partitionSequenceNumberMap.keySet()
+ .stream()
+ .findFirst()
+ .get()
+ .isMultiTopicPartition();
+ }
+
+ @Override
+ public boolean isMultiTopicPartition()
+ {
+ return isMultiTopicPartition;
+ }
+
+ @Override
+ public SeekableStreamSequenceNumbers<KafkaTopicPartition, Long> plus(
+ SeekableStreamSequenceNumbers<KafkaTopicPartition, Long> other
+ )
+ {
+ if (this.getClass() != other.getClass()) {
+ throw new IAE(
+ "Expected instance of %s, got %s",
+ this.getClass().getName(),
+ other.getClass().getName()
+ );
+ }
Review Comment:
added
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]