adoroszlai commented on code in PR #7266:
URL: https://github.com/apache/ozone/pull/7266#discussion_r2078881132


##########
hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/datanode/VolumeSubCommand.java:
##########
@@ -0,0 +1,222 @@
+/*
+ * 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.datanode;
+
+import java.io.IOException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.hadoop.hdds.cli.HddsVersionProvider;
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos.VolumeInfoProto;
+import 
org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.GetVolumeInfosResponseProto;
+import org.apache.hadoop.hdds.scm.cli.ScmSubcommand;
+import org.apache.hadoop.hdds.scm.client.ScmClient;
+import org.apache.hadoop.hdds.scm.datanode.VolumeInfo;
+import org.apache.hadoop.hdds.server.JsonUtils;
+import org.apache.hadoop.ozone.utils.FormattingCLIUtils;
+import org.apache.hadoop.util.StringUtils;
+import picocli.CommandLine.Command;
+import picocli.CommandLine.Option;
+
+/**
+ * We provide a set of volume commands to display the disk information of the 
DataNode.
+ */
+@Command(
+    name = "volumes",
+    description = "Display the list of volumes on the DataNode.",
+    mixinStandardHelpOptions = true,
+    versionProvider = HddsVersionProvider.class)
+public class VolumeSubCommand extends ScmSubcommand {
+
+  // Display it in JSON format.
+  @Option(names = { "--json" },
+       defaultValue = "false",
+       description = "Format output as JSON.")
+  private boolean json;
+
+  // Display it in TABLE format.
+  @Option(names = { "--table" },
+       defaultValue = "false",
+       description = "Format output as Table.")
+  private boolean table;
+
+  // PageSize refers to the number of items displayed per page
+  // in a paginated view.
+  @Option(names = { "--pageSize" },
+       defaultValue = "20",
+       description = "The number of volume information items displayed per 
page.")
+  private int pageSize;
+
+  // The current page.
+  @Option(names = { "--currentPage" },
+       defaultValue = "1",
+       description = "The current page.")
+  private int currentPage;

Review Comment:
   The problem with numeric "current page" is that the list is not fixed.  By 
the time you request the next page, it may be shorter or longer.  Then you may 
get the same item twice (if new item is added in the range of the earlier 
pages) or not at all (if item is removed from earlier pages).
   
   Using an anchor item eliminates the problem of duplicates.
   
   Compare GitHub's list of commits, which uses commit SHA as anchor:
   
   
https://github.com/apache/ozone/commits/master?after=e6daae4af3f9839be52ea6db636c9ff434acf306+34
   
   to list of pull requests, which has simple numeric page:
   
   https://github.com/apache/ozone/pulls?page=2
   
   Created HDDS-12995 to move out `--prefix`, to allow reusing `ListOptions` 
for lists that are filtered by other parameters.



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