cadonna commented on a change in pull request #10163: URL: https://github.com/apache/kafka/pull/10163#discussion_r585542433
########## File path: streams/src/main/java/org/apache/kafka/streams/processor/internals/ChangelogTopics.java ########## @@ -0,0 +1,132 @@ +/* + * 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.kafka.streams.processor.internals; + +import org.apache.kafka.common.TopicPartition; +import org.apache.kafka.common.utils.LogContext; +import org.apache.kafka.streams.processor.TaskId; +import org.apache.kafka.streams.processor.internals.InternalTopologyBuilder.TopicsInfo; +import org.slf4j.Logger; + +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.apache.kafka.streams.processor.internals.assignment.StreamsAssignmentProtocolVersions.UNKNOWN; + +public class ChangelogTopics { + + private final InternalTopicManager internalTopicManager; + private final Map<Integer, TopicsInfo> topicGroups; + private final Map<Integer, Set<TaskId>> tasksForTopicGroup; + private final Map<TaskId, Set<TopicPartition>> changelogPartitionsForTask = new HashMap<>(); + private final Map<TaskId, Set<TopicPartition>> preExistingChangelogPartitionsForTask = new HashMap<>(); + private final Set<TopicPartition> preExistingNonSourceTopicBasedChangelogPartitions = new HashSet<>(); + private final Set<String> sourceTopicBasedChangelogTopics = new HashSet<>(); + private final Set<TopicPartition> sourceTopicBasedChangelogTopicPartitions = new HashSet<>(); + private final Logger log; + + public ChangelogTopics(final InternalTopicManager internalTopicManager, + final Map<Integer, TopicsInfo> topicGroups, + final Map<Integer, Set<TaskId>> tasksForTopicGroup, + final String logPrefix) { + this.internalTopicManager = internalTopicManager; + this.topicGroups = topicGroups; + this.tasksForTopicGroup = tasksForTopicGroup; + final LogContext logContext = new LogContext(logPrefix); + log = logContext.logger(getClass()); + } + + public void setup() { Review comment: I agree with you and if I remember correctly you brought this up also on my change that introduces `RepartitionTopics`. Once we have the explicit user initialisation as described in KIP-698, we need to distinguish between setting up the broker-side state for Streams and verifying the the broker-side change. That requires changes in the `InternalTopicManager`. Currently, I could not separate this two concerns and left both in the setup method. Moving forward I will put everything that can be initialized in the constructor to avoid the mistakes you refer to. Consider the state of this class a temporary situation that will be soon fixed. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: [email protected]
