From 51c6ed65add3775ff7f4481aacccf5015e354b2b Mon Sep 17 00:00:00 2001 From: "Doroszlai, Attila" <6454655+adoroszlai@users.noreply.github.com> Date: Sat, 7 Dec 2024 07:21:00 +0100 Subject: [PATCH] HDDS-11830. Subcommands should not extend GenericCli .(#7537) --- .../ozone/admin/nssummary/NSSummaryAdmin.java | 12 +----------- .../org/apache/hadoop/ozone/admin/om/OMAdmin.java | 14 +------------- .../apache/hadoop/ozone/admin/scm/ScmAdmin.java | 14 +------------- .../ozone/debug/segmentparser/RatisLogParser.java | 7 +------ 4 files changed, 4 insertions(+), 43 deletions(-) diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java index af039cfff6d..ef9be49abfb 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/NSSummaryAdmin.java @@ -18,7 +18,6 @@ package org.apache.hadoop.ozone.admin.nssummary; import org.apache.hadoop.fs.ozone.OzoneClientUtils; -import org.apache.hadoop.hdds.cli.GenericCli; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.OzoneAdmin; import org.apache.hadoop.hdds.cli.AdminSubcommand; @@ -63,23 +62,14 @@ FileSizeDistSubCommand.class }) @MetaInfServices(AdminSubcommand.class) -public class NSSummaryAdmin extends GenericCli implements AdminSubcommand { +public class NSSummaryAdmin implements AdminSubcommand { @CommandLine.ParentCommand private OzoneAdmin parent; - @CommandLine.Spec - private CommandLine.Model.CommandSpec spec; - public OzoneAdmin getParent() { return parent; } - @Override - public Void call() throws Exception { - GenericCli.missingSubcommand(spec); - return null; - } - private boolean isObjectStoreBucket(OzoneBucket bucket, ObjectStore objectStore) { boolean enableFileSystemPaths = getOzoneConfig() .getBoolean(OMConfigKeys.OZONE_OM_ENABLE_FILESYSTEM_PATHS, diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/OMAdmin.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/OMAdmin.java index 9e2e31b6f89..9076ce9bf7d 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/OMAdmin.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/OMAdmin.java @@ -17,7 +17,6 @@ */ package org.apache.hadoop.ozone.admin.om; -import org.apache.hadoop.hdds.cli.GenericCli; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.OzoneAdmin; import org.apache.hadoop.hdds.cli.AdminSubcommand; @@ -38,8 +37,6 @@ import org.apache.ratis.protocol.ClientId; import org.kohsuke.MetaInfServices; import picocli.CommandLine; -import picocli.CommandLine.Model.CommandSpec; -import picocli.CommandLine.Spec; import java.util.Collection; @@ -64,24 +61,15 @@ FetchKeySubCommand.class }) @MetaInfServices(AdminSubcommand.class) -public class OMAdmin extends GenericCli implements AdminSubcommand { +public class OMAdmin implements AdminSubcommand { @CommandLine.ParentCommand private OzoneAdmin parent; - @Spec - private CommandSpec spec; - public OzoneAdmin getParent() { return parent; } - @Override - public Void call() throws Exception { - GenericCli.missingSubcommand(spec); - return null; - } - public ClientProtocol createClient(String omServiceId) throws Exception { OzoneConfiguration conf = parent.getOzoneConf(); if (OmUtils.isOmHAServiceId(conf, omServiceId)) { diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ScmAdmin.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ScmAdmin.java index d31f7527045..996485b13fd 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ScmAdmin.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/ScmAdmin.java @@ -17,14 +17,11 @@ */ package org.apache.hadoop.ozone.admin.scm; -import org.apache.hadoop.hdds.cli.GenericCli; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.OzoneAdmin; import org.apache.hadoop.hdds.cli.AdminSubcommand; import org.kohsuke.MetaInfServices; import picocli.CommandLine; -import picocli.CommandLine.Model.CommandSpec; -import picocli.CommandLine.Spec; /** * Subcommand for admin operations related to SCM. @@ -44,21 +41,12 @@ RotateKeySubCommand.class }) @MetaInfServices(AdminSubcommand.class) -public class ScmAdmin extends GenericCli implements AdminSubcommand { +public class ScmAdmin implements AdminSubcommand { @CommandLine.ParentCommand private OzoneAdmin parent; - @Spec - private CommandSpec spec; - public OzoneAdmin getParent() { return parent; } - - @Override - public Void call() throws Exception { - GenericCli.missingSubcommand(spec); - return null; - } } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/RatisLogParser.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/RatisLogParser.java index 653ea710aca..1fad2b607c1 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/RatisLogParser.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/segmentparser/RatisLogParser.java @@ -17,7 +17,6 @@ */ package org.apache.hadoop.ozone.debug.segmentparser; -import org.apache.hadoop.hdds.cli.GenericCli; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.DebugSubcommand; @@ -39,9 +38,5 @@ versionProvider = HddsVersionProvider.class, mixinStandardHelpOptions = true) @MetaInfServices(DebugSubcommand.class) -public class RatisLogParser extends GenericCli implements DebugSubcommand { - - public static void main(String[] args) { - new RatisLogParser().run(args); - } +public class RatisLogParser implements DebugSubcommand { }