smengcl commented on code in PR #5920: URL: https://github.com/apache/ozone/pull/5920#discussion_r1442440938
########## hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/ListOpenFilesSubCommand.java: ########## @@ -0,0 +1,189 @@ +/** + * 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 + * <p> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p> + * 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.ozone.admin.om; + +import org.apache.commons.lang3.StringUtils; +import org.apache.hadoop.hdds.cli.HddsVersionProvider; +import org.apache.hadoop.hdds.server.JsonUtils; +import org.apache.hadoop.ozone.om.helpers.ListOpenFilesResult; +import org.apache.hadoop.ozone.om.helpers.OmKeyInfo; +import org.apache.hadoop.ozone.om.helpers.OpenKeySession; +import org.apache.hadoop.ozone.om.protocol.OzoneManagerProtocol; +import picocli.CommandLine; + +import java.io.IOException; +import java.util.List; +import java.util.concurrent.Callable; + +/** + * Handler of ozone admin om listopenfiles command. + */ [email protected]( + name = "listopenfiles", + aliases = {"listopenkeys", "lof", "lok"}, + description = "Lists open keys in Ozone Manager.", + mixinStandardHelpOptions = true, + versionProvider = HddsVersionProvider.class +) +public class ListOpenFilesSubCommand implements Callable<Void> { + + @CommandLine.ParentCommand + private OMAdmin parent; + + @CommandLine.Option( + names = {"-id", "--service-id"}, + description = "Ozone Manager Service ID", + required = false + ) + private String omServiceId; + + @CommandLine.Option( + names = {"-host", "--service-host"}, + description = "Ozone Manager Host. If OM HA is enabled, use -id instead. " + + "If insists on using -host with OM HA, this must point directly " + + "to the leader OM. " + + "This option is required when -id is not provided or " + + "when HA is not enabled." + ) + private String omHost; + + @CommandLine.Option(names = { "--json" }, + defaultValue = "false", + description = "Format output as JSON") + private boolean json; + + @CommandLine.Option( + names = {"-p", "--path"}, + description = "Show only open files under this path.", + defaultValue = "/", + hidden = false + ) + private String path; + + @CommandLine.Option( + names = {"-n"}, + description = "Numerical limit of open files/keys to return.", + defaultValue = "1000", + hidden = false + ) + private long count; + + @CommandLine.Option( + names = {"-t", "--token"}, // TODO: Conform to Ozone CLI convention + description = "Previous/last file/key path as the continuation token.", Review Comment: Users of this command won't have to remember the usage of this option's usage ideally, as I have added `getCmdForNextBatch()` to prompt the command to fetch the next batch. User could just copy, paste and run. Markdown doc to be added later. -- 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]
