diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/OzoneAdmin.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/OzoneAdmin.java index bc75f6aee90..5b5b8fe8947 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/OzoneAdmin.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/OzoneAdmin.java @@ -19,9 +19,8 @@ import org.apache.hadoop.hdds.cli.AdminSubcommand; import org.apache.hadoop.hdds.cli.ExtensibleParentCommand; -import org.apache.hadoop.hdds.cli.GenericCli; import org.apache.hadoop.hdds.cli.HddsVersionProvider; -import org.apache.hadoop.hdds.tracing.TracingUtil; +import org.apache.hadoop.ozone.shell.Shell; import picocli.CommandLine; @@ -33,20 +32,12 @@ description = "Developer tools for Ozone Admin operations", versionProvider = HddsVersionProvider.class, mixinStandardHelpOptions = true) -public class OzoneAdmin extends GenericCli implements ExtensibleParentCommand { +public class OzoneAdmin extends Shell implements ExtensibleParentCommand { public static void main(String[] argv) { new OzoneAdmin().run(argv); } - @Override - public int execute(String[] argv) { - TracingUtil.initTracing("shell", getOzoneConf()); - String spanName = "ozone admin " + String.join(" ", argv); - return TracingUtil.executeInNewSpan(spanName, - () -> super.execute(argv)); - } - @Override public Class subcommandType() { return AdminSubcommand.class; diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/OzoneDebug.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/OzoneDebug.java index 164d07f96b4..d626db81f3a 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/OzoneDebug.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/OzoneDebug.java @@ -20,9 +20,8 @@ import org.apache.hadoop.hdds.cli.DebugSubcommand; import org.apache.hadoop.hdds.cli.ExtensibleParentCommand; -import org.apache.hadoop.hdds.cli.GenericCli; import org.apache.hadoop.hdds.cli.HddsVersionProvider; - +import org.apache.hadoop.ozone.shell.Shell; import picocli.CommandLine; /** @@ -32,7 +31,7 @@ description = "Developer tools for Ozone Debug operations", versionProvider = HddsVersionProvider.class, mixinStandardHelpOptions = true) -public class OzoneDebug extends GenericCli implements ExtensibleParentCommand { +public class OzoneDebug extends Shell implements ExtensibleParentCommand { public static void main(String[] argv) { new OzoneDebug().run(argv); diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java index c324618bfe4..782ecd4beb5 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/OzoneShell.java @@ -18,7 +18,6 @@ package org.apache.hadoop.ozone.shell; import org.apache.hadoop.hdds.cli.HddsVersionProvider; -import org.apache.hadoop.hdds.tracing.TracingUtil; import org.apache.hadoop.ozone.shell.bucket.BucketCommands; import org.apache.hadoop.ozone.shell.keys.KeyCommands; import org.apache.hadoop.ozone.shell.prefix.PrefixCommands; @@ -47,21 +46,7 @@ mixinStandardHelpOptions = true) public class OzoneShell extends Shell { - /** - * Main for the ozShell Command handling. - * - * @param argv - System Args Strings[] - */ public static void main(String[] argv) throws Exception { new OzoneShell().run(argv); } - - @Override - public int execute(String[] argv) { - TracingUtil.initTracing("shell", getOzoneConf()); - String spanName = "ozone sh " + String.join(" ", argv); - return TracingUtil.executeInNewSpan(spanName, - () -> super.execute(argv)); - } - } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/Shell.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/Shell.java index 3291ce87b08..8bca492f042 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/Shell.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/Shell.java @@ -19,7 +19,9 @@ package org.apache.hadoop.ozone.shell; import org.apache.hadoop.hdds.cli.GenericCli; +import org.apache.hadoop.hdds.tracing.TracingUtil; import org.apache.hadoop.ozone.om.exceptions.OMException; + import picocli.CommandLine; import picocli.shell.jline3.PicocliCommands.PicocliCommandsFactory; @@ -85,7 +87,9 @@ public void run(String[] argv) { spec.name(""); // use short name (e.g. "token get" instead of "ozone sh token get") new REPL(this, getCmd(), (PicocliCommandsFactory) getCmd().getFactory()); } else { - super.run(argv); + TracingUtil.initTracing("shell", getOzoneConf()); + String spanName = spec.name() + " " + String.join(" ", argv); + TracingUtil.executeInNewSpan(spanName, () -> super.run(argv)); } } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java index 53324ba03d6..c0b6c6f2f80 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/s3/S3Shell.java @@ -17,7 +17,6 @@ */ package org.apache.hadoop.ozone.shell.s3; -import org.apache.hadoop.hdds.tracing.TracingUtil; import org.apache.hadoop.ozone.shell.Shell; import picocli.CommandLine.Command; @@ -34,19 +33,6 @@ }) public class S3Shell extends Shell { - @Override - public int execute(String[] argv) { - TracingUtil.initTracing("s3shell", getOzoneConf()); - String spanName = "ozone s3 " + String.join(" ", argv); - return TracingUtil.executeInNewSpan(spanName, - () -> super.execute(argv)); - } - - /** - * Main for the S3Shell Command handling. - * - * @param argv - System Args Strings[] - */ public static void main(String[] argv) { new S3Shell().run(argv); } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java index c7baf789f19..857f24748df 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantShell.java @@ -17,8 +17,8 @@ */ package org.apache.hadoop.ozone.shell.tenant; -import org.apache.hadoop.hdds.tracing.TracingUtil; import org.apache.hadoop.ozone.shell.Shell; + import picocli.CommandLine.Command; /** @@ -35,19 +35,6 @@ }) public class TenantShell extends Shell { - @Override - public int execute(String[] argv) { - TracingUtil.initTracing("tenant-shell", getOzoneConf()); - String spanName = "ozone tenant " + String.join(" ", argv); - return TracingUtil.executeInNewSpan(spanName, - () -> super.execute(argv)); - } - - /** - * Main for the TenantShell Command handling. - * - * @param argv - System Args Strings[] - */ public static void main(String[] argv) { new TenantShell().run(argv); }