slfan1989 commented on code in PR #7266: URL: https://github.com/apache/ozone/pull/7266#discussion_r2078757409
########## 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: > Other Ozone CLI commands allow pagination (via ListOptions reusable mixin) with --start to specify the start item, --length for "page size", and --all (only one of these last two are allowed). Please try to use options consistent with that. I have thoroughly reviewed `ListOptions`, and it is indeed a powerful tool class. However, my requirements differ slightly from its original functionality. I want to implement a pagination display, as there may sometimes be a certain number of damaged disks. For example, if there are 30 damaged disks and the `limit` is set to 10, the `currentPage` can range from 1 to 3, allowing for pagination. In this case, `currentPage` represents the current page number. Therefore, I plan to add the `currentPage` option to `ListOptions` to meet this need. > Using ListOption directly may not work, since --prefix does not seem to be applicable here. The `--start` and `--prefix` options have limited relevance for our functionality. Currently, we support filtering by `hostName`, which I believe should be sufficient. I'm unsure whether we need to filter by disk letter as well. What do you think? -- 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]
