smengcl commented on a change in pull request #2565: URL: https://github.com/apache/ozone/pull/2565#discussion_r694494559
########## File path: hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/DiskUsageSubCommand.java ########## @@ -0,0 +1,215 @@ +/* + * 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.nssummary; + +import com.google.gson.internal.LinkedTreeMap; +import org.apache.commons.io.FileUtils; +import org.apache.hadoop.hdds.cli.HddsVersionProvider; +import org.apache.hadoop.ozone.shell.ListOptions; +import picocli.CommandLine; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.concurrent.Callable; + +import static org.apache.hadoop.ozone.OzoneConsts.OM_KEY_PREFIX; +import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.getResponseMap; +import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.makeHttpCall; +import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.parseInputPath; +import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printEmptyPathRequest; +import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printFSOReminder; +import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printKVSeparator; +import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printNewLines; +import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printPathNotFound; +import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printSpaces; +import static org.apache.hadoop.ozone.admin.nssummary.NSSummaryCLIUtils.printWithUnderline; + +/** + * Disk Usage Subcommand. + */ [email protected]( + name = "du", + description = "Get disk usage for a path request.", + mixinStandardHelpOptions = true, + versionProvider = HddsVersionProvider.class +) + +public class DiskUsageSubCommand implements Callable { + @CommandLine.ParentCommand + private NSSummaryAdmin parent; + + @CommandLine.Parameters(index = "0", arity = "0..1", + description = "Non-empty path request without any protocol prefix.") + private String path; + + @CommandLine.Option(names = {"-f", "--file"}, + description = "List direct files as a sub path.") + private boolean listFiles; + + @CommandLine.Option(names = {"-r", "--replica"}, + description = "Show disk usage with replication.") + private boolean withReplica; + + @CommandLine.Option(names = {"-n", "--no-header"}, + description = "Show DU without the header for current path.") + private boolean noHeader; + Review comment: ```suggestion ``` ########## File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/recon/ReconConfigKeys.java ########## @@ -36,6 +36,10 @@ private ReconConfigKeys() { "ozone.recon.datanode.address"; public static final String OZONE_RECON_ADDRESS_KEY = "ozone.recon.address"; + public static final String OZONE_RECON_HTTP_ADDRESS_KEY = + "ozone.recon.http-address"; + public static final String OZONE_RECON_HTTPS_ADDRESS_KEY = + "ozone.recon.https-address"; Review comment: We already have these in `ReconServerConfigKeys`. No need to add them here. ```suggestion ``` ########## File path: hadoop-ozone/dist/src/main/compose/ozone/docker-config ########## @@ -31,6 +31,8 @@ OZONE-SITE.XML_ozone.recon.db.dir=/data/metadata/recon OZONE-SITE.XML_ozone.scm.client.address=scm OZONE-SITE.XML_hdds.datanode.dir=/data/hdds OZONE-SITE.XML_ozone.recon.address=recon:9891 +OZONE-SITE.XML_ozone.recon.http-address=recon:9888 +OZONE-SITE.XML_ozone.recon.https-address=recon:9889 Review comment: Just use `0.0.0.0` as only the port portion matters. ```suggestion OZONE-SITE.XML_ozone.recon.http-address=0.0.0.0:9888 OZONE-SITE.XML_ozone.recon.https-address=0.0.0.0:9889 ``` ########## File path: hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/HddsUtils.java ########## @@ -314,6 +316,48 @@ public static InetSocketAddress getReconAddresses( return NetUtils.createSocketAddr(hostname.get(), port); } + /** + * Retrieve the socket addresses of recon HTTP. + * + * @return Recon address + * @throws IllegalArgumentException If the configuration is invalid + */ + public static InetSocketAddress getReconHTTPAddresses( + ConfigurationSource conf) { + String name = conf.get(OZONE_RECON_HTTP_ADDRESS_KEY); Review comment: We should still use `OZONE_RECON_ADDRESS_KEY` here, as it is expected that Recon RPC and REST share the same **host**. The rationale is that `ozone-default.xml` has `ozone.recon.http-address=0.0.0.0:9888`. So one doesn't have to manually add another config entry to `ozone-site.xml`, when the CLI feature lands, it should just work without extra configs. -- 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]
