xichen01 commented on code in PR #10410: URL: https://github.com/apache/ozone/pull/10410#discussion_r3382198463
########## hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/StorageTierUtil.java: ########## @@ -0,0 +1,62 @@ +/* + * 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.client; + +import java.util.List; +import org.apache.hadoop.fs.StorageType; +import org.apache.hadoop.hdds.scm.exceptions.SCMException; + +/** + * Utility class for managing StorageTier operations. + */ +public final class StorageTierUtil { + private StorageTierUtil() { + } + + /** + * Validates the given StorageTier and throws an exception if it is empty. + * + * @param storageTier the StorageTier to check + * @throws SCMException if the StorageTier is empty + */ + public static void validateNotEmpty(StorageTier storageTier) throws SCMException { + if (storageTier.equals(StorageTier.EMPTY)) { + throw new SCMException("Cannot create Pipeline for empty tier", + SCMException.ResultCodes.CANNOT_CREATE_PIPELINE_FOR_EMPTY_TIER); + } Review Comment: An additional NOT NULL check has been added; The code here will not be null because there will always be at least one default StorageTier, even if it wasn't specified when creating the Pipeline. -- 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]
