ivandika3 commented on code in PR #10410:
URL: https://github.com/apache/ozone/pull/10410#discussion_r3353770122


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/StorageTier.java:
##########
@@ -121,50 +117,51 @@ public String getTierName() {
     return tierName;
   }
 
-  public boolean isUniformStorageType() {
-    return uniformStorageType;
+  public boolean isUniform() {
+    return isUniform;
   }
 
   /**
    * Computes the list of StorageTypes based on replication configuration.
    *
-   * @param replicationConfig The replication configuration.
+   * @param nodeCount The node count of the storageTier required.
+   * @param storageTier The required StorageTier.
    * @return The list of StorageTypes for the given tier and replication 
configuration.
    */
-  private List<StorageType> computeStorageTypes(
-      ReplicationConfig replicationConfig) {
-    if (isUniformStorageType()) {
-      int numberOfNodes = replicationConfig.getRequiredNodes();
+  private List<StorageType> computeStorageTypes(int nodeCount, StorageTier 
storageTier) {
+    if (isUniform()) {
       if (storageTypes.isEmpty()) {
         return Collections.emptyList();
       }
-      return Collections.nCopies(numberOfNodes, storageTypes.get(0));
+      return Collections.nCopies(nodeCount, storageTypes.get(0));
     } else {
       throw new UnsupportedOperationException(
-          "Unsupported not UniformStorage Storage Tier: " + replicationConfig);
+          "Unsupported not uniform StorageTier: " + storageTier);
     }
   }
 
   /**
    * Maps a StorageTier to its corresponding StorageType based on replication 
type.
    *
-   * @param replicationConfig The replication configuration.
+   * @param nodeCount The node count of the storageTier required.
    * @return The list of StorageTypes corresponding to the given tier and 
replication configuration.
    * @throws IllegalArgumentException if the replication configuration is not 
supported.
    */
-  public List<StorageType> getStorageTypes(
-      ReplicationConfig replicationConfig) {
-    Map<ReplicationConfig, List<StorageType>> tierCache = CACHE.get(this);
+  public List<StorageType> getStorageTypes(int nodeCount) {
+    Map<Integer, List<StorageType>> tierCache = CACHE.get(this);
 
     if (tierCache != null) {
-      List<StorageType> cachedStorageType = tierCache.get(replicationConfig);
+      List<StorageType> cachedStorageType = tierCache.get(nodeCount);
       if (cachedStorageType != null) {
         return cachedStorageType;
       }
     }
 
-    throw new IllegalArgumentException("Unsupported ReplicationConfig: " +
-        replicationConfig + " for StorageTier: " + getTierName());
+    throw new IllegalArgumentException("Unsupported node count: " +
+        nodeCount + " for StorageTier: " + getTierName());
   }
 
+  public static void setDefault(StorageTier storageTier) {
+    defaultTier = storageTier;
+  }

Review Comment:
   Does not seem to be used, should be configured and set in 
`StorageContainerManager.java`



##########
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:
   Nullity check here?



-- 
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]

Reply via email to