diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java index 14d454431f9..158bd9270b7 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java @@ -105,7 +105,6 @@ public Void call() throws Exception { throw new MissingSubcommandException(cmd); } - @Override public OzoneConfiguration createOzoneConfiguration() { OzoneConfiguration ozoneConf = new OzoneConfiguration(); if (configurationPath != null) { @@ -119,6 +118,7 @@ public OzoneConfiguration createOzoneConfiguration() { return ozoneConf; } + @Override public OzoneConfiguration getOzoneConf() { if (conf == null) { conf = createOzoneConfiguration(); diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericParentCommand.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericParentCommand.java index 6abad3e32b8..e4dcd8d4ab5 100644 --- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericParentCommand.java +++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/cli/GenericParentCommand.java @@ -25,5 +25,6 @@ public interface GenericParentCommand { boolean isVerbose(); - OzoneConfiguration createOzoneConfiguration(); + /** Returns a cached configuration, i.e. it is created only once, subsequent calls return the same instance. */ + OzoneConfiguration getOzoneConf(); } diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/AbstractMixin.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/AbstractMixin.java new file mode 100644 index 00000000000..1201f2058c6 --- /dev/null +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/AbstractMixin.java @@ -0,0 +1,44 @@ +/* + * 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.cli; + +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import picocli.CommandLine; + +import static picocli.CommandLine.Spec.Target.MIXEE; + +/** Base functionality for all Ozone CLI mixins. */ +@CommandLine.Command +public abstract class AbstractMixin { + + @CommandLine.Spec(MIXEE) + private CommandLine.Model.CommandSpec spec; + + protected CommandLine.Model.CommandSpec spec() { + return spec; + } + + protected GenericParentCommand rootCommand() { + return AbstractSubcommand.findRootCommand(spec); + } + + protected OzoneConfiguration getOzoneConf() { + return rootCommand().getOzoneConf(); + } + +} diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/AbstractSubcommand.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/AbstractSubcommand.java new file mode 100644 index 00000000000..550a68ae07e --- /dev/null +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/cli/AbstractSubcommand.java @@ -0,0 +1,80 @@ +/* + * 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.cli; + +import org.apache.hadoop.hdds.conf.OzoneConfiguration; +import org.apache.ratis.util.MemoizedSupplier; +import picocli.CommandLine; + +import java.util.function.Supplier; + +/** Base functionality for all Ozone subcommands. */ +@CommandLine.Command( + mixinStandardHelpOptions = true, + versionProvider = HddsVersionProvider.class +) +public abstract class AbstractSubcommand { + + @CommandLine.Spec + private CommandLine.Model.CommandSpec spec; + + private final Supplier rootSupplier = + MemoizedSupplier.valueOf(() -> findRootCommand(spec)); + + protected CommandLine.Model.CommandSpec spec() { + return spec; + } + + /** Get the Ozone object annotated with {@link CommandLine.Command}) that was used to run this command. + * Usually this is some subclass of {@link GenericCli}, but in unit tests it could be any subcommand. */ + protected GenericParentCommand rootCommand() { + return rootSupplier.get(); + } + + protected boolean isVerbose() { + return rootCommand().isVerbose(); + } + + /** @see GenericParentCommand#getOzoneConf() */ + protected OzoneConfiguration getOzoneConf() { + return rootCommand().getOzoneConf(); + } + + static GenericParentCommand findRootCommand(CommandLine.Model.CommandSpec spec) { + Object root = spec.root().userObject(); + return root instanceof GenericParentCommand + ? (GenericParentCommand) root + : new NoParentCommand(); + } + + /** No-op implementation for unit tests, which may bypass creation of GenericCli object. */ + private static class NoParentCommand implements GenericParentCommand { + + private final OzoneConfiguration conf = new OzoneConfiguration(); + + @Override + public boolean isVerbose() { + return false; + } + + @Override + public OzoneConfiguration getOzoneConf() { + return conf; + } + } +} diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmOption.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmOption.java index dea8ac0ec87..faff193fa93 100644 --- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmOption.java +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmOption.java @@ -19,7 +19,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.hadoop.hdds.HddsUtils; -import org.apache.hadoop.hdds.cli.GenericParentCommand; +import org.apache.hadoop.hdds.cli.AbstractMixin; import org.apache.hadoop.hdds.conf.ConfigurationException; import org.apache.hadoop.hdds.conf.MutableConfigurationSource; import org.apache.hadoop.hdds.conf.OzoneConfiguration; @@ -33,15 +33,11 @@ import static org.apache.hadoop.hdds.scm.ScmConfigKeys.OZONE_SCM_CLIENT_ADDRESS_KEY; import static org.apache.hadoop.hdds.utils.HddsServerUtil.getScmSecurityClient; -import static picocli.CommandLine.Spec.Target.MIXEE; /** * Defines command-line option for SCM address. */ -public class ScmOption { - - @CommandLine.Spec(MIXEE) - private CommandLine.Model.CommandSpec spec; +public class ScmOption extends AbstractMixin { @CommandLine.Option(names = {"--scm"}, description = "The destination scm (host:port)") @@ -53,9 +49,7 @@ public class ScmOption { private String scmServiceId; public ScmClient createScmClient() throws IOException { - GenericParentCommand parent = (GenericParentCommand) - spec.root().userObject(); - OzoneConfiguration conf = parent.createOzoneConfiguration(); + OzoneConfiguration conf = getOzoneConf(); checkAndSetSCMAddressArg(conf); return new ContainerOperationClient(conf); @@ -91,13 +85,10 @@ private void checkAndSetSCMAddressArg(MutableConfigurationSource conf) { public SCMSecurityProtocol createScmSecurityClient() { try { - GenericParentCommand parent = (GenericParentCommand) - spec.root().userObject(); - return getScmSecurityClient(parent.createOzoneConfiguration()); + return getScmSecurityClient(getOzoneConf()); } catch (IOException ex) { throw new IllegalArgumentException( "Can't create SCM Security client", ex); } } - } diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmSubcommand.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmSubcommand.java index 6dc09c2cbec..a0afddd9a40 100644 --- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmSubcommand.java +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmSubcommand.java @@ -17,6 +17,7 @@ */ package org.apache.hadoop.hdds.scm.cli; +import org.apache.hadoop.hdds.cli.AbstractSubcommand; import org.apache.hadoop.hdds.scm.client.ScmClient; import picocli.CommandLine; @@ -26,7 +27,7 @@ /** * Base class for admin commands that connect via SCM client. */ -public abstract class ScmSubcommand implements Callable { +public abstract class ScmSubcommand extends AbstractSubcommand implements Callable { @CommandLine.Mixin private ScmOption scmOption; diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ContainerCommands.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ContainerCommands.java index a38b98c53a9..cf0c63adca3 100644 --- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ContainerCommands.java +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ContainerCommands.java @@ -22,11 +22,9 @@ import org.apache.hadoop.hdds.cli.AdminSubcommand; import org.apache.hadoop.hdds.cli.GenericCli; import org.apache.hadoop.hdds.cli.HddsVersionProvider; -import org.apache.hadoop.hdds.cli.OzoneAdmin; import org.kohsuke.MetaInfServices; import picocli.CommandLine.Command; -import picocli.CommandLine.ParentCommand; import picocli.CommandLine.Model.CommandSpec; import picocli.CommandLine.Spec; @@ -52,16 +50,9 @@ public class ContainerCommands implements Callable, AdminSubcommand { @Spec private CommandSpec spec; - @ParentCommand - private OzoneAdmin parent; - @Override public Void call() throws Exception { GenericCli.missingSubcommand(spec); return null; } - - public OzoneAdmin getParent() { - return parent; - } } diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/InfoSubcommand.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/InfoSubcommand.java index 0e67661bba1..3665a7d3fa7 100644 --- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/InfoSubcommand.java +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/InfoSubcommand.java @@ -27,7 +27,6 @@ import java.util.Scanner; import java.util.stream.Collectors; -import org.apache.hadoop.hdds.cli.GenericParentCommand; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.client.ReplicationConfig; import org.apache.hadoop.hdds.protocol.DatanodeDetails; @@ -47,9 +46,7 @@ import org.apache.hadoop.hdds.server.JsonUtils; import picocli.CommandLine; import picocli.CommandLine.Command; -import picocli.CommandLine.Model.CommandSpec; import picocli.CommandLine.Parameters; -import picocli.CommandLine.Spec; /** * This is the handler that process container info command. @@ -61,9 +58,6 @@ versionProvider = HddsVersionProvider.class) public class InfoSubcommand extends ScmSubcommand { - @Spec - private CommandSpec spec; - @CommandLine.Option(names = { "--json" }, defaultValue = "false", description = "Format output as JSON") @@ -181,10 +175,7 @@ private void printDetails(ScmClient scmClient, long containerID, } else { // Print container report info. System.out.printf("Container id: %s%n", containerID); - boolean verbose = spec != null - && spec.root().userObject() instanceof GenericParentCommand - && ((GenericParentCommand) spec.root().userObject()).isVerbose(); - if (verbose) { + if (isVerbose()) { System.out.printf("Pipeline Info: %s%n", container.getPipeline()); } else { System.out.printf("Pipeline id: %s%n", container.getPipeline().getId().getId()); diff --git a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java index 88ccef702b3..cf338c7d774 100644 --- a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java +++ b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java @@ -38,7 +38,6 @@ import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import picocli.CommandLine.Command; -import picocli.CommandLine.ParentCommand; import picocli.CommandLine.Help.Visibility; import picocli.CommandLine.Option; @@ -82,9 +81,6 @@ public class ListSubcommand extends ScmSubcommand { private static final ObjectWriter WRITER; - @ParentCommand - private ContainerCommands parent; - static { ObjectMapper mapper = new ObjectMapper() .registerModule(new JavaTimeModule()) @@ -116,7 +112,7 @@ public void execute(ScmClient scmClient) throws IOException { replication, new OzoneConfiguration()); } - int maxCountAllowed = parent.getParent().getOzoneConf() + int maxCountAllowed = getOzoneConf() .getInt(ScmConfigKeys.OZONE_SCM_CONTAINER_LIST_MAX_COUNT, ScmConfigKeys.OZONE_SCM_CONTAINER_LIST_MAX_COUNT_DEFAULT); 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 ef9be49abfb..20a145b56fb 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 @@ -66,10 +66,6 @@ public class NSSummaryAdmin implements AdminSubcommand { @CommandLine.ParentCommand private OzoneAdmin parent; - public OzoneAdmin getParent() { - return parent; - } - 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/debug/container/InspectSubcommand.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/container/InspectSubcommand.java index 79a0a84c649..f924277d27f 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/container/InspectSubcommand.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/container/InspectSubcommand.java @@ -18,6 +18,7 @@ package org.apache.hadoop.ozone.debug.container; +import org.apache.hadoop.hdds.cli.AbstractSubcommand; import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.ozone.container.common.impl.ContainerData; import org.apache.hadoop.ozone.container.common.interfaces.Container; @@ -39,14 +40,14 @@ name = "inspect", description = "Check the metadata of all container replicas on this datanode.") -public class InspectSubcommand implements Callable { +public class InspectSubcommand extends AbstractSubcommand implements Callable { @CommandLine.ParentCommand private ContainerCommands parent; @Override public Void call() throws IOException { - final OzoneConfiguration conf = parent.getOzoneConf(); + final OzoneConfiguration conf = getOzoneConf(); parent.loadContainersFromVolumes(); final KeyValueContainerMetadataInspector inspector diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaRepair.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaRepair.java index 6ead713e148..5c7b6b2fc4b 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaRepair.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaRepair.java @@ -113,8 +113,4 @@ private Collection getConfiguredServiceIds() { public UserGroupInformation getUser() throws IOException { return UserGroupInformation.getCurrentUser(); } - - protected OzoneRepair getParent() { - return parent; - } } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaStatus.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaStatus.java index 820ac6f8eaf..cd9ef42da8e 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaStatus.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaStatus.java @@ -64,8 +64,4 @@ public Void call() throws Exception { System.out.println(ozoneManagerClient.getQuotaRepairStatus()); return null; } - - protected QuotaRepair getParent() { - return parent; - } } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaTrigger.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaTrigger.java index 04d78f05dc6..daa1f332e3f 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaTrigger.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/quota/QuotaTrigger.java @@ -84,9 +84,4 @@ public Void call() throws Exception { } return null; } - - protected QuotaRepair getParent() { - return parent; - } - } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/Handler.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/Handler.java index d1755a68806..db7294e2795 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/Handler.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/Handler.java @@ -24,8 +24,7 @@ import java.util.concurrent.Callable; import com.fasterxml.jackson.databind.node.ArrayNode; -import org.apache.hadoop.hdds.cli.GenericParentCommand; -import org.apache.hadoop.hdds.cli.HddsVersionProvider; +import org.apache.hadoop.hdds.cli.AbstractSubcommand; import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.hdds.server.JsonUtils; @@ -34,36 +33,17 @@ import org.apache.hadoop.ozone.client.OzoneClientException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import picocli.CommandLine; -import picocli.CommandLine.Command; -import picocli.CommandLine.ParentCommand; /** * Base class for shell commands that connect via Ozone client. */ -@Command(mixinStandardHelpOptions = true, - versionProvider = HddsVersionProvider.class) @SuppressWarnings("squid:S106") // CLI -public abstract class Handler implements Callable { +public abstract class Handler extends AbstractSubcommand implements Callable { protected static final Logger LOG = LoggerFactory.getLogger(Handler.class); private OzoneConfiguration conf; - @ParentCommand - private GenericParentCommand parent; - - @CommandLine.Spec - private CommandLine.Model.CommandSpec spec; - - public boolean isVerbose() { - return parent.isVerbose(); - } - - public OzoneConfiguration createOzoneConfiguration() { - return parent.createOzoneConfiguration(); - } - protected OzoneAddress getAddress() throws OzoneClientException { return new OzoneAddress(); } @@ -84,7 +64,7 @@ protected boolean isApplicable() { @Override public Void call() throws Exception { - conf = createOzoneConfiguration(); + conf = getOzoneConf(); if (!isApplicable()) { return null; @@ -111,7 +91,7 @@ protected boolean securityEnabled() { if (!enabled) { err().printf("Error: '%s' operation works only when security is " + "enabled. To enable security set ozone.security.enabled to " + - "true.%n", spec.qualifiedName().trim()); + "true.%n", spec().qualifiedName().trim()); } return enabled; } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/BucketCommands.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/BucketCommands.java index 8a92de696a7..f4be05aab7d 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/BucketCommands.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/bucket/BucketCommands.java @@ -20,10 +20,8 @@ import java.util.concurrent.Callable; -import org.apache.hadoop.hdds.cli.GenericParentCommand; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.MissingSubcommandException; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.ozone.shell.Shell; import picocli.CommandLine.Command; @@ -52,7 +50,7 @@ }, mixinStandardHelpOptions = true, versionProvider = HddsVersionProvider.class) -public class BucketCommands implements GenericParentCommand, Callable { +public class BucketCommands implements Callable { @ParentCommand private Shell shell; @@ -62,14 +60,4 @@ public Void call() throws Exception { throw new MissingSubcommandException( this.shell.getCmd().getSubcommands().get("bucket")); } - - @Override - public boolean isVerbose() { - return shell.isVerbose(); - } - - @Override - public OzoneConfiguration createOzoneConfiguration() { - return shell.createOzoneConfiguration(); - } } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/KeyCommands.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/KeyCommands.java index f4ac9e1fe8f..390db103899 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/KeyCommands.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/keys/KeyCommands.java @@ -20,10 +20,8 @@ import java.util.concurrent.Callable; -import org.apache.hadoop.hdds.cli.GenericParentCommand; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.MissingSubcommandException; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.ozone.shell.Shell; import picocli.CommandLine.Command; @@ -52,8 +50,7 @@ }, mixinStandardHelpOptions = true, versionProvider = HddsVersionProvider.class) -public class KeyCommands - implements GenericParentCommand, Callable { +public class KeyCommands implements Callable { @ParentCommand private Shell shell; @@ -63,14 +60,4 @@ public Void call() throws Exception { throw new MissingSubcommandException( this.shell.getCmd().getSubcommands().get("key")); } - - @Override - public boolean isVerbose() { - return shell.isVerbose(); - } - - @Override - public OzoneConfiguration createOzoneConfiguration() { - return shell.createOzoneConfiguration(); - } } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/prefix/PrefixCommands.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/prefix/PrefixCommands.java index f058c4214d2..6216fce08d7 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/prefix/PrefixCommands.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/prefix/PrefixCommands.java @@ -20,10 +20,8 @@ import java.util.concurrent.Callable; -import org.apache.hadoop.hdds.cli.GenericParentCommand; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.MissingSubcommandException; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.ozone.shell.Shell; import picocli.CommandLine.Command; @@ -42,7 +40,7 @@ }, mixinStandardHelpOptions = true, versionProvider = HddsVersionProvider.class) -public class PrefixCommands implements GenericParentCommand, Callable { +public class PrefixCommands implements Callable { @ParentCommand private Shell shell; @@ -52,14 +50,4 @@ public Void call() throws Exception { throw new MissingSubcommandException( this.shell.getCmd().getSubcommands().get("prefix")); } - - @Override - public boolean isVerbose() { - return shell.isVerbose(); - } - - @Override - public OzoneConfiguration createOzoneConfiguration() { - return shell.createOzoneConfiguration(); - } } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/snapshot/SnapshotCommands.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/snapshot/SnapshotCommands.java index e4ae7f5ad7a..dbeb6cda0a4 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/snapshot/SnapshotCommands.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/snapshot/SnapshotCommands.java @@ -20,10 +20,8 @@ import java.util.concurrent.Callable; -import org.apache.hadoop.hdds.cli.GenericParentCommand; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.MissingSubcommandException; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.ozone.shell.Shell; import picocli.CommandLine.Command; @@ -45,7 +43,7 @@ }, mixinStandardHelpOptions = true, versionProvider = HddsVersionProvider.class) -public class SnapshotCommands implements GenericParentCommand, Callable { +public class SnapshotCommands implements Callable { @ParentCommand private Shell shell; @@ -55,14 +53,4 @@ public Void call() throws Exception { throw new MissingSubcommandException( this.shell.getCmd().getSubcommands().get("snapshot")); } - - @Override - public boolean isVerbose() { - return shell.isVerbose(); - } - - @Override - public OzoneConfiguration createOzoneConfiguration() { - return shell.createOzoneConfiguration(); - } } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantUserCommands.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantUserCommands.java index baff85d0bf2..8caeb232a9e 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantUserCommands.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/tenant/TenantUserCommands.java @@ -17,10 +17,8 @@ */ package org.apache.hadoop.ozone.shell.tenant; -import org.apache.hadoop.hdds.cli.GenericParentCommand; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.MissingSubcommandException; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.ozone.shell.Shell; import picocli.CommandLine; @@ -43,8 +41,7 @@ }, mixinStandardHelpOptions = true, versionProvider = HddsVersionProvider.class) -public class TenantUserCommands implements - GenericParentCommand, Callable { +public class TenantUserCommands implements Callable { @CommandLine.ParentCommand private Shell shell; @@ -54,14 +51,4 @@ public Void call() throws Exception { throw new MissingSubcommandException( this.shell.getCmd().getSubcommands().get("user")); } - - @Override - public boolean isVerbose() { - return shell.isVerbose(); - } - - @Override - public OzoneConfiguration createOzoneConfiguration() { - return shell.createOzoneConfiguration(); - } } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/token/TokenCommands.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/token/TokenCommands.java index 3223b5b49ed..df504313840 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/token/TokenCommands.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/token/TokenCommands.java @@ -20,10 +20,8 @@ import java.util.concurrent.Callable; -import org.apache.hadoop.hdds.cli.GenericParentCommand; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.MissingSubcommandException; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.ozone.shell.Shell; import picocli.CommandLine.Command; @@ -42,8 +40,7 @@ }, mixinStandardHelpOptions = true, versionProvider = HddsVersionProvider.class) -public class TokenCommands - implements GenericParentCommand, Callable { +public class TokenCommands implements Callable { @ParentCommand private Shell shell; @@ -53,14 +50,4 @@ public Void call() throws Exception { throw new MissingSubcommandException( this.shell.getCmd().getSubcommands().get("token")); } - - @Override - public boolean isVerbose() { - return shell.isVerbose(); - } - - @Override - public OzoneConfiguration createOzoneConfiguration() { - return shell.createOzoneConfiguration(); - } } diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/VolumeCommands.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/VolumeCommands.java index 1cf88552030..0a87e7a4065 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/VolumeCommands.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/shell/volume/VolumeCommands.java @@ -20,10 +20,8 @@ import java.util.concurrent.Callable; -import org.apache.hadoop.hdds.cli.GenericParentCommand; import org.apache.hadoop.hdds.cli.HddsVersionProvider; import org.apache.hadoop.hdds.cli.MissingSubcommandException; -import org.apache.hadoop.hdds.conf.OzoneConfiguration; import org.apache.hadoop.ozone.shell.Shell; import picocli.CommandLine.Command; @@ -50,7 +48,7 @@ }, mixinStandardHelpOptions = true, versionProvider = HddsVersionProvider.class) -public class VolumeCommands implements GenericParentCommand, Callable { +public class VolumeCommands implements Callable { @ParentCommand private Shell shell; @@ -60,14 +58,4 @@ public Void call() throws Exception { throw new MissingSubcommandException( this.shell.getCmd().getSubcommands().get("volume")); } - - @Override - public boolean isVerbose() { - return shell.isVerbose(); - } - - @Override - public OzoneConfiguration createOzoneConfiguration() { - return shell.createOzoneConfiguration(); - } }