cmccabe commented on a change in pull request #11527: URL: https://github.com/apache/kafka/pull/11527#discussion_r754714660
########## File path: metadata/src/main/java/org/apache/kafka/image/ProducerIdsImage.java ########## @@ -0,0 +1,77 @@ +/* + * 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.image; + +import org.apache.kafka.common.metadata.ProducerIdsRecord; +import org.apache.kafka.server.common.ApiMessageAndVersion; + +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.function.Consumer; + + +/** + * Stores the highest seen producer ID in the metadata image. + * + * This class is thread-safe. + */ +public final class ProducerIdsImage { + public final static ProducerIdsImage EMPTY = new ProducerIdsImage(-1L); + + private final long highestSeenProducerId; + + public ProducerIdsImage(long highestSeenProducerId) { + this.highestSeenProducerId = highestSeenProducerId; + } + + public long highestSeenProducerId() { + return highestSeenProducerId; + } + + public void write(Consumer<List<ApiMessageAndVersion>> out) { + if (highestSeenProducerId >= 0) { + out.accept(Collections.singletonList(new ApiMessageAndVersion( + new ProducerIdsRecord(). + setBrokerId(-1). + setBrokerEpoch(-1). Review comment: It's useful in the log as a kind of record of what happened. I think it's much less useful in the snapshot since at most we would be just giving the very latest broker to request producer ids, which isn't very interesting for debugging, 99% of the time. -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org