Efrat19 commented on code in PR #287: URL: https://github.com/apache/flink-connector-kafka/pull/287#discussion_r3624074673
########## flink-connector-kafka/src/main/java/org/apache/flink/connector/kafka/source/enumerator/subscriber/TopicIntegrityProvider.java: ########## @@ -0,0 +1,162 @@ +/* + * 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.flink.connector.kafka.source.enumerator.subscriber; + +import org.apache.flink.connector.kafka.integrity.TopicIntegrityException; + +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.apache.kafka.clients.admin.AdminClient; +import org.apache.kafka.clients.admin.TopicDescription; +import org.apache.kafka.common.Uuid; +import org.apache.kafka.common.errors.UnknownTopicOrPartitionException; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.Serializable; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +import static org.apache.flink.connector.kafka.util.AdminUtils.getTopicMetadata; +import static org.apache.flink.connector.kafka.util.AdminUtils.getTopicsByPattern; + +/** Provider of topic integrity related functionalities for {@link KafkaSourceEnumerator}. */ +class TopicIntegrityProvider implements Serializable { + + private static final Logger LOG = LoggerFactory.getLogger(TopicIntegrityProvider.class); + private final Map<String, String> topicIntegrityMapping = new ConcurrentHashMap<>(); + + TopicIntegrityProvider() {} + + public void open(Map<String, String> topicIntegrityMappingFromContext) { Review Comment: The thing is we only have the state mapping in `KafkaSourceEnumerator` where a subscriber is already initialized. So it got me to reconsider the ownership model and make `topicIntegrityProvider` property of `KafkaSourceEnumerator` instead of the subscriber's, and have subscribers passed a generic `TopicMetadataProvider` instead Is it be better now? -- 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]
