sreejasahithi commented on code in PR #11420:
URL: https://github.com/apache/ozone/pull/11420#discussion_r4333185213


##########
hadoop-hdds/interface-admin/src/main/proto/ScmAdminProtocol.proto:
##########
@@ -744,6 +747,29 @@ message SuppressContainerResponseProto {
   repeated int64 failedContainerIDs = 1;
 }
 
+message StorageTypeUsageInfoProto {
+  required hadoop.hdds.StorageTypeProto storageType = 1;
+  optional int64 capacity = 2;
+  optional int64 used = 3;
+  optional int64 remaining = 4;
+  optional int64 committed = 5;
+  optional int64 freeSpaceToSpare = 6;

Review Comment:
   Was omitting reserved from StorageTypeUsageInfoProto / storagepolicy 
usageinfo intentional? SCM already exposes per-StorageType reserved via 
scmNodeStat.getReserved(storageType), and datanode usageinfo shows reserved at 
node level. Curious if that was out of Jira scope or if you would want a follow 
up for per-type reserved.



##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/storagepolicy/UsageInfoSubCommand.java:
##########
@@ -0,0 +1,311 @@
+/*
+ * 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.scm.cli.storagepolicy;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Comparator;
+import java.util.EnumMap;
+import java.util.List;
+import java.util.Map;
+import org.apache.hadoop.fs.StorageType;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.client.StorageTypeUtils;
+import org.apache.hadoop.hdds.protocol.DatanodeDetails;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeOperationalState;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeState;
+import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.DatanodeStorageTypeUsageInfoProto;
+import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ListStorageTypeUsageInfoRequestProto;
+import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.StorageTypeUsageInfoProto;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.apache.hadoop.hdds.server.JsonUtils;
+import org.apache.hadoop.util.StringUtils;
+import picocli.CommandLine;
+
+/**
+ * Handler of list storage usage info by StorageType command.
+ */
[email protected](
+    name = "usageinfo",
+    description = "List usage information in the StorageType dimension",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class UsageInfoSubCommand extends ScmSubcommand {
+
+  @CommandLine.Option(
+      names = {"-d", "--with-datanode"},
+      description = "Print detailed per-datanode storage-type usage",
+      defaultValue = "false")
+  private boolean printDatanodeInfo;
+
+  @CommandLine.Option(
+      names = {"-o", "--operational-state"},
+      description = "Show datanodes in a specific operational state "
+          + "(IN_SERVICE, DECOMMISSIONING, DECOMMISSIONED, "
+          + "ENTERING_MAINTENANCE, IN_MAINTENANCE), "
+          + "or ALL to show all operational states",
+      defaultValue = "IN_SERVICE")
+  private String nodeOperationalStateStr;
+
+  @CommandLine.Option(
+      names = {"-n", "--node-state"},
+      description = "Show datanodes in a specific health state "
+          + "(HEALTHY, STALE, DEAD), or ALL to show all health states",
+      defaultValue = "HEALTHY")
+  private String nodeStateStr;

Review Comment:
   With no -o/-n, the command still sends IN_SERVICE + HEALTHY (Picocli 
defaultValue), but --help doesn’t show those defaults. Worth a sentence in the 
command help.



##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/storagepolicy/UsageInfoSubCommand.java:
##########
@@ -141,6 +142,7 @@ private List<DatanodeStorageTypeUsage> 
buildDatanodeUsageList(List<DatanodeStora
         datanodeUsage.add(new DatanodeStorageTypeUsage(dn, st));
       }
     }
+    
datanodeUsage.sort(Comparator.comparing(DatanodeStorageTypeUsage::getStorageType));

Review Comment:
   Sort is only Comparator.comparing(DatanodeStorageTypeUsage::getStorageType) 
— datanodes within a type follow RPC iteration order, not hostname. Optional, 
you can take a call if we need : thenComparing(u -> 
u.getDatanodeDetails().getUuidString())



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