cmccabe commented on code in PR #12513: URL: https://github.com/apache/kafka/pull/12513#discussion_r949676920
########## metadata/src/main/java/org/apache/kafka/metadata/bootstrap/BootstrapMetadata.java: ########## @@ -0,0 +1,141 @@ +/* + * 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.metadata.bootstrap; + +import org.apache.kafka.common.metadata.FeatureLevelRecord; +import org.apache.kafka.common.protocol.ApiMessage; +import org.apache.kafka.server.common.ApiMessageAndVersion; +import org.apache.kafka.server.common.MetadataVersion; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + + +/** + * The bootstrap metadata. On startup, if the metadata log is empty, we will populate the log with + * these records. Alternately, if log is not empty, but the metadata version is not set, we will + * use the version specified here. + */ +public class BootstrapMetadata { + private final List<ApiMessageAndVersion> records; + private final MetadataVersion metadataVersion; + private final String source; + + public static BootstrapMetadata fromVersion(MetadataVersion metadataVersion, String source) { + List<ApiMessageAndVersion> records = Collections.singletonList( + new ApiMessageAndVersion(new FeatureLevelRecord(). + setName(MetadataVersion.FEATURE_NAME). + setFeatureLevel(metadataVersion.featureLevel()), (short) 0)); Review Comment: This is an issue which is not really specific to `bootstrap.checkpoint`... it's kind of similar to should we bump the version of `ApiVersionRequest`? I do think the `FeatureLevelRecord` which contains the initial metadata version should always remain at version 0. Otherwise old Kafkas won't be able to determine the version of newer metadata logs. (They wouldn't have been able to read them in either case, but if they can't even read the first record, the error message is bad) I guess this seemed obvious to me, but we should probably add a comment to `FeatureLevelRecord.json` telling people not to bump the version. I will add one. -- 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]
