kerneltime commented on code in PR #3595: URL: https://github.com/apache/ozone/pull/3595#discussion_r920610335
########## hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSFinalizationRequirements.java: ########## @@ -0,0 +1,128 @@ +/* + * 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.hadoop.hdds.upgrade; + +import java.util.Collection; + +import static org.apache.hadoop.hdds.upgrade.HDDSFinalizationRequirements.PipelineRequirements.CLOSE_ALL_PIPELINES; + +/** + * Used by layout features in {@link HDDSLayoutFeature} to specify + * requirements that SCM must enforce before, during, or after they finalize. + */ +public class HDDSFinalizationRequirements { + /** + * What each layout feature requires for pipelines while it is + * finalizing. + */ + public enum PipelineRequirements { + /** + * The layout feature requires all pipelines to be closed while finalizing. + */ + CLOSE_ALL_PIPELINES, + /** + * The layout feature has no special requirements for pipeline handling + * while it is finalizing. + */ + NONE + } + + private final int minFinalizedDatanodes; + private final PipelineRequirements pipelineRequirements; + + private HDDSFinalizationRequirements(Builder builder) { + minFinalizedDatanodes = builder.minFinalizedDatanodes; + pipelineRequirements = builder.pipelineRequirements; + } + + /** + * Generates one requirements object by aggregating multiple requirements. + * The requirements aggregate will reflect the strictest requirements of + * any individual requirements provided. + */ + public HDDSFinalizationRequirements( + Collection<HDDSFinalizationRequirements> requirements) { + int currentMinFinalizedDatanodes = 0; + PipelineRequirements currentPipelineRequirements = + PipelineRequirements.NONE; + + for (HDDSFinalizationRequirements req: requirements) { + // The minimum number of datanodes we must wait to finalize is the + // largest of the minimums of all layout features. + currentMinFinalizedDatanodes = Math.max(currentMinFinalizedDatanodes, + req.minFinalizedDatanodes); + + if (req.pipelineRequirements == CLOSE_ALL_PIPELINES) { + currentPipelineRequirements = CLOSE_ALL_PIPELINES; + } + } + + minFinalizedDatanodes = currentMinFinalizedDatanodes; + pipelineRequirements = currentPipelineRequirements; + } + + /** + * @return The minimum number of datanodes that SCM must wait to have + * finalized before declaring finalization has finished. The remaining + * datanodes will finalize asynchronously. + */ + public int getMinFinalizedDatanodes() { + return minFinalizedDatanodes; + } + + public PipelineRequirements getPipelineRequirements() { + return pipelineRequirements; + } + + @Override + public String toString() { + return String.format("Pipeline requirements: %s%nMinimum number of " + + "finalized datanodes: %s", pipelineRequirements, minFinalizedDatanodes); + } + + /** + * Builds an {@link HDDSFinalizationRequirements} object, using default + * values for unspecified requirements. + */ + public static final class Builder { + private int minFinalizedDatanodes; + private PipelineRequirements pipelineRequirements; + + public Builder() { + // Default values. + this.minFinalizedDatanodes = 3; Review Comment: We would need to revisit this post enablement of EC ########## hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/upgrade/HDDSLayoutFeature.java: ########## @@ -22,32 +22,57 @@ import java.util.Optional; import org.apache.hadoop.ozone.upgrade.LayoutFeature; +import org.apache.hadoop.hdds.upgrade.HDDSFinalizationRequirements.PipelineRequirements; /** * List of HDDS Features. */ public enum HDDSLayoutFeature implements LayoutFeature { ////////////////////////////// ////////////////////////////// - INITIAL_VERSION(0, "Initial Layout Version"), - DATANODE_SCHEMA_V2(1, "Datanode RocksDB Schema Version 2 (with column " + + + // TODO: After HDDS-6887 schema version changes will not require closing + // pipelines. + INITIAL_VERSION(0, + new HDDSFinalizationRequirements.Builder().build(), + "Initial Layout Version"), + DATANODE_SCHEMA_V2(1, + new HDDSFinalizationRequirements.Builder() + .setPipelineRequirements(PipelineRequirements.CLOSE_ALL_PIPELINES) + .build(), + "Datanode RocksDB Schema Version 2 (with column " + "families)"), - SCM_HA(2, "Storage Container Manager HA"), - ERASURE_CODED_STORAGE_SUPPORT(3, "Ozone version with built in support for" + SCM_HA(2, + new HDDSFinalizationRequirements.Builder().build(), + "Storage Container Manager HA"), + ERASURE_CODED_STORAGE_SUPPORT(3, + new HDDSFinalizationRequirements.Builder() + // At least 5 datanodes are required for an EC pipeline. + .setMinFinalizedDatanodes(5) + .build(), + "Ozone version with built in support for" + " Erasure Coded block data storage."), - DATANODE_SCHEMA_V3(4, "Datanode RocksDB Schema Version 3 (one rocksdb " + + DATANODE_SCHEMA_V3(4, + new HDDSFinalizationRequirements.Builder() + .setPipelineRequirements(PipelineRequirements.CLOSE_ALL_PIPELINES) Review Comment: Will all pipelines be closed if this feature is defaulted to off? -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
