mas-chen commented on code in PR #97:
URL:
https://github.com/apache/flink-connector-kafka/pull/97#discussion_r1580512725
##########
flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/dynamic/source/enumerator/DynamicKafkaSourceEnumerator.java:
##########
@@ -288,36 +288,39 @@ private void
onHandleSubscribedStreamsFetch(Set<KafkaStream> fetchedKafkaStreams
// create enumerators
for (Entry<String, Set<String>> activeClusterTopics :
latestClusterTopicsMap.entrySet()) {
- final Set<TopicPartition> activeTopicPartitions = new HashSet<>();
-
- if (dynamicKafkaSourceEnumState
+ KafkaSourceEnumState kafkaSourceEnumState =
+ dynamicKafkaSourceEnumState
.getClusterEnumeratorStates()
- .get(activeClusterTopics.getKey())
- != null) {
- Set<TopicPartition> oldTopicPartitions =
- dynamicKafkaSourceEnumState
- .getClusterEnumeratorStates()
- .get(activeClusterTopics.getKey())
- .assignedPartitions();
+ .get(activeClusterTopics.getKey());
+
+ final KafkaSourceEnumState newKafkaSourceEnumState;
+ if (kafkaSourceEnumState != null) {
+ Set<TopicPartition> activeTopicPartitions = new HashSet<>();
+ Set<TopicPartition> oldTopicPartitions =
kafkaSourceEnumState.assignedPartitions();
// filter out removed topics
for (TopicPartition oldTopicPartition : oldTopicPartitions) {
if
(activeClusterTopics.getValue().contains(oldTopicPartition.topic())) {
activeTopicPartitions.add(oldTopicPartition);
}
}
+
+ newKafkaSourceEnumState =
+ new KafkaSourceEnumState(
+ activeTopicPartitions,
+
kafkaSourceEnumState.unassignedInitialPartitions(),
Review Comment:
I think we should also filter out invalid topics here. It would be good to
add a unit test in DynamicKafkaSourceEnumeratorTest (integration test will be
difficult for this case)
--
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]