This is an automated email from the ASF dual-hosted git repository.
sarvekshayr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 08a23a92e87 HDDS-15596. Hide deprecated CLI options (#10542)
08a23a92e87 is described below
commit 08a23a92e87f2e33163867ebe1abdf6c272a0ee7
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Tue Jun 23 10:57:39 2026 +0200
HDDS-15596. Hide deprecated CLI options (#10542)
---
.../hadoop/hdds/cli/DeprecatedCliOption.java | 33 +++++----
.../org/apache/hadoop/hdds/cli/GenericCli.java | 38 ++--------
.../hdds/cli/TestGenericCliConfiguration.java | 39 +++++-----
.../org/apache/hadoop/hdds/scm/cli/ScmOption.java | 18 +----
.../scm/cli/pipeline/FilterPipelineOptions.java | 18 +----
.../scm/cli/pipeline/ListPipelinesSubcommand.java | 22 +-----
.../ozone/admin/om/DecommissionOMSubcommand.java | 74 +++++--------------
.../hadoop/ozone/admin/om/OmAddressOptions.java | 27 +------
.../hadoop/ozone/admin/om/PrepareSubCommand.java | 84 ++++------------------
.../ozone/admin/scm/DecommissionScmSubcommand.java | 33 ++-------
...n.java => TestOzoneAdminDeprecatedOptions.java} | 48 +++++++------
.../cli/pipeline/TestClosePipelinesSubCommand.java | 4 +-
.../cli/pipeline/TestListPipelinesSubCommand.java | 6 +-
.../java/org/apache/hadoop/ozone/shell/Shell.java | 2 -
.../apache/hadoop/ozone/shell/acl/AclOption.java | 47 +++++-------
.../src/main/smoketest/admincli/pipeline.robot | 24 +++++--
16 files changed, 157 insertions(+), 360 deletions(-)
diff --git
a/hadoop-hdds/cli-common/src/main/java/org/apache/hadoop/hdds/cli/DeprecatedCliOption.java
b/hadoop-hdds/cli-common/src/main/java/org/apache/hadoop/hdds/cli/DeprecatedCliOption.java
index d455c29ece7..13c154b96a2 100644
---
a/hadoop-hdds/cli-common/src/main/java/org/apache/hadoop/hdds/cli/DeprecatedCliOption.java
+++
b/hadoop-hdds/cli-common/src/main/java/org/apache/hadoop/hdds/cli/DeprecatedCliOption.java
@@ -20,7 +20,7 @@
import java.io.PrintWriter;
import java.util.LinkedHashMap;
import java.util.Map;
-import picocli.CommandLine;
+import java.util.Objects;
/**
* Emits warnings when deprecated multi-character short CLI options are used.
@@ -51,24 +51,27 @@ private static Map<String, String> buildDeprecatedOptions()
{
}
/**
- * Print a warning to stderr for each deprecated option present on the
command line.
+ * If {@code arg} is a deprecated option (with or without {@code =value}
part),
+ * print a warning to stderr and return with the recommended replacement
option.
*/
- public static void warnIfMatched(CommandLine.ParseResult parseResult) {
- if (parseResult == null) {
- return;
+ public static String toNonDeprecated(String arg, PrintWriter err) {
+ if (arg == null || arg.isEmpty()) {
+ return arg;
}
- for (CommandLine cli : parseResult.asCommandLineList()) {
- CommandLine.ParseResult subcommandResult = cli.getParseResult();
- if (subcommandResult.matchedOptions().isEmpty()) {
- continue;
- }
- for (Map.Entry<String, String> entry : DEPRECATED_OPTIONS.entrySet()) {
- if (subcommandResult.hasMatchedOption(entry.getKey())) {
- warn(cli.getErr(), entry.getKey(), entry.getValue());
- }
- }
+ String result = arg;
+ String[] parts = arg.split("=", 2);
+ String opt = parts[0];
+ String optToUse = DEPRECATED_OPTIONS.getOrDefault(opt, opt);
+
+ if (!Objects.equals(opt, optToUse)) {
+ warn(err, opt, optToUse);
+ result = parts.length == 2
+ ? optToUse + '=' + parts[1]
+ : optToUse;
}
+
+ return result;
}
private static void warn(PrintWriter err, String deprecated, String
replacement) {
diff --git
a/hadoop-hdds/cli-common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java
b/hadoop-hdds/cli-common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java
index 6fcdd686219..b90bf49ce2d 100644
---
a/hadoop-hdds/cli-common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java
+++
b/hadoop-hdds/cli-common/src/main/java/org/apache/hadoop/hdds/cli/GenericCli.java
@@ -46,10 +46,6 @@ public abstract class GenericCli implements
GenericParentCommand {
private UserGroupInformation user;
- private String configurationPath;
- private String deprecatedConfigurationPath;
- private boolean isConfigurationPathAdded = false;
-
@Option(names = {"--verbose"},
scope = CommandLine.ScopeType.INHERIT,
description = "More verbose output. Show the stack trace of the errors.")
@@ -63,22 +59,7 @@ public void setConfigurationOverrides(Map<String, String>
configOverrides) {
@Option(names = {"--conf"},
description = "Path to custom configuration file.")
public void setConfigurationPath(String configPath) {
- configurationPath = configPath;
- }
-
- /** For backward compatibility. */
- @Option(names = {"-conf"}, hidden = true)
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- public void setDeprecatedConfigurationPath(String configPath) {
- deprecatedConfigurationPath = configPath;
- }
-
- private String getConfigurationPath() {
- if (configurationPath != null) {
- return configurationPath;
- }
- return deprecatedConfigurationPath;
+ config.addResource(new Path(configPath));
}
public GenericCli() {
@@ -87,16 +68,16 @@ public GenericCli() {
public GenericCli(CommandLine.IFactory factory) {
cmd = new CommandLine(this, factory);
+ ExtensibleParentCommand.addSubcommands(cmd);
+ cmd.getCommandSpec().preprocessor((args, commandSpec, argSpec, info) -> {
+ args.replaceAll(arg -> DeprecatedCliOption.toNonDeprecated(arg,
cmd.getErr()));
+ return false;
+ });
+
cmd.setExecutionExceptionHandler((ex, commandLine, parseResult) -> {
printError(ex);
return EXECUTION_ERROR_EXIT_CODE;
});
- cmd.setExecutionStrategy(parseResult -> {
- DeprecatedCliOption.warnIfMatched(parseResult);
- return new CommandLine.RunLast().execute(parseResult);
- });
-
- ExtensibleParentCommand.addSubcommands(cmd);
}
public void run(String[] argv) {
@@ -135,11 +116,6 @@ public void printError(Throwable error) {
@Override
public OzoneConfiguration getOzoneConf() {
- String path = getConfigurationPath();
- if (path != null && !isConfigurationPathAdded) {
- config.addResource(new Path(path));
- isConfigurationPathAdded = true;
- }
return config;
}
diff --git
a/hadoop-hdds/cli-common/src/test/java/org/apache/hadoop/hdds/cli/TestGenericCliConfiguration.java
b/hadoop-hdds/cli-common/src/test/java/org/apache/hadoop/hdds/cli/TestGenericCliConfiguration.java
index 5334d4b86c3..b61b847fec6 100644
---
a/hadoop-hdds/cli-common/src/test/java/org/apache/hadoop/hdds/cli/TestGenericCliConfiguration.java
+++
b/hadoop-hdds/cli-common/src/test/java/org/apache/hadoop/hdds/cli/TestGenericCliConfiguration.java
@@ -18,49 +18,44 @@
package org.apache.hadoop.hdds.cli;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
+import picocli.CommandLine;
/**
* Tests for {@link GenericCli} configuration option handling.
*/
public class TestGenericCliConfiguration {
+ private static Path deprecatedConf;
+ private static Path preferredConf;
+
private static final class TestGenericCli extends GenericCli {
}
- @Test
- public void nonDeprecatedConfWinsWhenBothAreProvided() throws IOException {
- Path deprecatedConf = writeConf("deprecated");
- Path preferredConf = writeConf("preferred");
-
- TestGenericCli cli = new TestGenericCli();
- cli.getCmd().parseArgs("-conf", deprecatedConf.toString(), "--conf",
- preferredConf.toString());
-
- assertThat(cli.getOzoneConf().get("test.key")).isEqualTo("preferred");
+ @BeforeAll
+ static void setup() throws IOException {
+ deprecatedConf = writeConf("deprecated");
+ preferredConf = writeConf("preferred");
}
@Test
- public void nonDeprecatedConfWinsRegardlessOfOrder() throws IOException {
- Path deprecatedConf = writeConf("deprecated");
- Path preferredConf = writeConf("preferred");
-
- TestGenericCli cli = new TestGenericCli();
- cli.getCmd().parseArgs("--conf", preferredConf.toString(), "-conf",
- deprecatedConf.toString());
-
- assertThat(cli.getOzoneConf().get("test.key")).isEqualTo("preferred");
+ void confOptionsAreExclusive() {
+ CommandLine cmd = new TestGenericCli().getCmd();
+ assertThrows(CommandLine.OverwrittenOptionException.class,
+ () -> cmd.parseArgs("-conf", deprecatedConf.toString(), "--conf",
preferredConf.toString()));
+ assertThrows(CommandLine.OverwrittenOptionException.class,
+ () -> cmd.parseArgs("--conf", deprecatedConf.toString(), "-conf",
preferredConf.toString()));
}
@Test
- public void deprecatedConfIsUsedWhenNonDeprecatedIsAbsent() throws
IOException {
- Path deprecatedConf = writeConf("deprecated");
-
+ void deprecatedConfIsUsedWhenNonDeprecatedIsAbsent() {
TestGenericCli cli = new TestGenericCli();
cli.getCmd().parseArgs("-conf", deprecatedConf.toString());
diff --git
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmOption.java
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmOption.java
index acb7a4424b9..95f26775d0d 100644
---
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmOption.java
+++
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/ScmOption.java
@@ -46,12 +46,6 @@ public class ScmOption extends AbstractMixin {
"ServiceId of SCM HA Cluster")
private String scmServiceId;
- /** For backward compatibility. */
- @CommandLine.Option(names = {"-id"}, hidden = true)
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private String deprecatedScmServiceId;
-
public ScmClient createScmClient() throws IOException {
OzoneConfiguration conf = getOzoneConf();
checkAndSetSCMAddressArg(conf);
@@ -76,9 +70,8 @@ private void
checkAndSetSCMAddressArg(MutableConfigurationSource conf) {
// Use the scm service Id passed from the client.
- String serviceId = getScmServiceId();
- if (StringUtils.isNotEmpty(serviceId)) {
- conf.set(ScmConfigKeys.OZONE_SCM_DEFAULT_SERVICE_ID, serviceId);
+ if (StringUtils.isNotEmpty(scmServiceId)) {
+ conf.set(ScmConfigKeys.OZONE_SCM_DEFAULT_SERVICE_ID, scmServiceId);
} else if (StringUtils.isBlank(HddsUtils.getScmServiceId(conf))) {
// Scm service id is not passed, and scm service id is not defined in
// the config, assuming it should be non-HA cluster.
@@ -105,11 +98,4 @@ public SCMSecurityProtocol createScmSecurityClient() {
public String getScm() {
return scm;
}
-
- public String getScmServiceId() {
- if (StringUtils.isNotEmpty(scmServiceId)) {
- return scmServiceId;
- }
- return deprecatedScmServiceId;
- }
}
diff --git
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/FilterPipelineOptions.java
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/FilterPipelineOptions.java
index b30f2c45071..c82d5cfe88f 100644
---
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/FilterPipelineOptions.java
+++
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/FilterPipelineOptions.java
@@ -49,26 +49,16 @@ public class FilterPipelineOptions {
description = "[deprecated] Filter pipelines by factor (e.g. ONE, THREE)
(implies RATIS replication type)")
private ReplicationFactor factor;
- /** For backward compatibility. */
- @CommandLine.Option(
- names = {"-ffc"},
- hidden = true
- )
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private ReplicationFactor deprecatedFactor;
-
Optional<Predicate<? super Pipeline>> getReplicationFilter() {
- ReplicationFactor effectiveFactor = getFactor();
boolean hasReplication = !Strings.isNullOrEmpty(replication);
- boolean hasFactor = effectiveFactor != null;
+ boolean hasFactor = factor != null;
boolean hasReplicationType = !Strings.isNullOrEmpty(replicationType);
if (hasFactor) {
if (hasReplication) {
throw new IllegalArgumentException("Factor and replication are
mutually exclusive");
}
- ReplicationConfig replicationConfig =
RatisReplicationConfig.getInstance(effectiveFactor.toProto());
+ ReplicationConfig replicationConfig =
RatisReplicationConfig.getInstance(factor.toProto());
return Optional.of(p ->
replicationConfig.equals(p.getReplicationConfig()));
}
@@ -91,8 +81,4 @@ Optional<Predicate<? super Pipeline>> getReplicationFilter() {
return Optional.empty();
}
-
- private ReplicationFactor getFactor() {
- return factor != null ? factor : deprecatedFactor;
- }
}
diff --git
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ListPipelinesSubcommand.java
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ListPipelinesSubcommand.java
index b1e5ec6d3ae..fb3ef26775c 100644
---
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ListPipelinesSubcommand.java
+++
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/pipeline/ListPipelinesSubcommand.java
@@ -49,16 +49,6 @@ public class ListPipelinesSubcommand extends ScmSubcommand {
defaultValue = "")
private String state;
- /** For backward compatibility. */
- @CommandLine.Option(
- names = {"-fst"},
- hidden = true,
- defaultValue = ""
- )
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private String deprecatedState;
-
@CommandLine.Option(
names = {"--json"},
defaultValue = "false",
@@ -73,10 +63,9 @@ public void execute(ScmClient scmClient) throws IOException {
if (replicationFilter.isPresent()) {
stream = stream.filter(replicationFilter.get());
}
- String effectiveState = getState();
- if (!Strings.isNullOrEmpty(effectiveState)) {
+ if (!Strings.isNullOrEmpty(state)) {
stream = stream.filter(p -> p.getPipelineState().toString()
- .compareToIgnoreCase(effectiveState) == 0);
+ .compareToIgnoreCase(state) == 0);
}
if (json) {
@@ -87,11 +76,4 @@ public void execute(ScmClient scmClient) throws IOException {
stream.forEach(System.out::println);
}
}
-
- private String getState() {
- if (!Strings.isNullOrEmpty(state)) {
- return state;
- }
- return deprecatedState;
- }
}
diff --git
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/DecommissionOMSubcommand.java
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/DecommissionOMSubcommand.java
index 1b1a46f6654..3da4c0c043b 100644
---
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/DecommissionOMSubcommand.java
+++
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/DecommissionOMSubcommand.java
@@ -67,11 +67,15 @@ public class DecommissionOMSubcommand implements
Callable<Void> {
@CommandLine.Mixin
private OmAddressOptions.MandatoryServiceIdMixin omServiceOption;
- @CommandLine.ArgGroup(multiplicity = "1")
- private NodeIdOptions nodeIdOptions;
+ @CommandLine.Option(names = {"--nodeid"},
+ description = "NodeID of the OM to be decommissioned.",
+ required = true)
+ private String decommNodeId;
- @CommandLine.ArgGroup(multiplicity = "1")
- private HostnameOptions hostnameOptions;
+ @CommandLine.Option(names = {"--node-host-address"},
+ description = "Host name/address of the OM to be decommissioned.",
+ required = true)
+ private String hostname;
private InetAddress hostInetAddress;
@@ -102,14 +106,14 @@ public Void call() throws IOException {
OMAdminProtocolClientSideImpl.createProxyForOMHA(ozoneConf, user,
omServiceOption.getServiceID())) {
OMNodeDetails decommNodeDetails = new OMNodeDetails.Builder()
- .setOMNodeId(nodeIdOptions.getNodeId())
+ .setOMNodeId(decommNodeId)
.setHostAddress(hostInetAddress.getHostAddress())
.build();
omAdminProtocolClient.decommission(decommNodeDetails);
- System.out.println("Successfully decommissioned OM " +
nodeIdOptions.getNodeId());
+ System.out.println("Successfully decommissioned OM " + decommNodeId);
} catch (IOException e) {
- System.out.println("Failed to decommission OM " +
nodeIdOptions.getNodeId());
+ System.out.println("Failed to decommission OM " + decommNodeId);
throw e;
}
return null;
@@ -121,19 +125,19 @@ public Void call() throws IOException {
*/
private void verifyNodeIdAndHostAddress() throws IOException {
String rpcAddrKey = ConfUtils.addKeySuffixes(OZONE_OM_ADDRESS_KEY,
- omServiceOption.getServiceID(), nodeIdOptions.getNodeId());
+ omServiceOption.getServiceID(), decommNodeId);
String rpcAddrStr = OmUtils.getOmRpcAddress(ozoneConf, rpcAddrKey);
if (rpcAddrStr == null || rpcAddrStr.isEmpty()) {
- throw new IOException("There is no OM corresponding to " +
nodeIdOptions.getNodeId()
+ throw new IOException("There is no OM corresponding to " + decommNodeId
+ "in the configuration.");
}
- hostInetAddress = InetAddress.getByName(hostnameOptions.getHostname());
+ hostInetAddress = InetAddress.getByName(hostname);
InetAddress rpcAddressFromConfig = InetAddress.getByName(
rpcAddrStr.split(":")[0]);
if (!hostInetAddress.equals(rpcAddressFromConfig)) {
- throw new IOException("OM " + nodeIdOptions.getNodeId() + "'s host
address in " +
+ throw new IOException("OM " + decommNodeId + "'s host address in " +
"config - " + rpcAddressFromConfig.getHostAddress() + " does not " +
"match the provided host address " + hostInetAddress);
}
@@ -149,9 +153,9 @@ private void verifyConfigUpdatedOnAllOMs() throws
IOException {
OZONE_OM_DECOMMISSIONED_NODES_KEY, omServiceOption.getServiceID());
Collection<String> decommNodes =
OmUtils.getDecommissionedNodeIds(ozoneConf, decommNodesKey);
- if (!decommNodes.contains(nodeIdOptions.getNodeId())) {
+ if (!decommNodes.contains(decommNodeId)) {
throw new IOException("Please add the to be decommissioned OM "
- + nodeIdOptions.getNodeId() + " to the " + decommNodesKey + " config
in " +
+ + decommNodeId + " to the " + decommNodesKey + " config in " +
"ozone-site.xml of all nodes.");
}
@@ -161,7 +165,7 @@ private void verifyConfigUpdatedOnAllOMs() throws
IOException {
List<OMNodeDetails> activeOMNodeDetails = OmUtils.getAllOMHAAddresses(
ozoneConf, omServiceOption.getServiceID(), false);
if (activeOMNodeDetails.isEmpty()) {
- throw new IOException("Cannot decommission OM " +
nodeIdOptions.getNodeId() + " as " +
+ throw new IOException("Cannot decommission OM " + decommNodeId + " as " +
"it is the only node in the ring.");
}
@@ -190,7 +194,7 @@ private boolean checkOMConfig(OMNodeDetails omNodeDetails)
user, omNodeDetails)) {
OMConfiguration omConfig = omAdminProtocolClient.getOMConfiguration();
OMNodeDetails decommNodeDetails = omConfig
- .getDecommissionedNodesInNewConf().get(nodeIdOptions.getNodeId());
+ .getDecommissionedNodesInNewConf().get(decommNodeId);
if (decommNodeDetails == null) {
return false;
}
@@ -201,44 +205,4 @@ private boolean checkOMConfig(OMNodeDetails omNodeDetails)
}
return true;
}
-
- /** Options for OM node ID. */
- static class NodeIdOptions {
- @CommandLine.Option(names = {"--nodeid"},
- description = "NodeID of the OM to be decommissioned.",
- required = true)
- private String nodeId;
-
- /** For backward compatibility. */
- @CommandLine.Option(names = {"-nodeid"},
- hidden = true,
- required = true)
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private String deprecatedNodeId;
-
- String getNodeId() {
- return nodeId != null ? nodeId : deprecatedNodeId;
- }
- }
-
- /** Options for OM host name/address. */
- static class HostnameOptions {
- @CommandLine.Option(names = {"--node-host-address"},
- description = "Host name/address of the OM to be decommissioned.",
- required = true)
- private String hostname;
-
- /** For backward compatibility. */
- @CommandLine.Option(names = {"-hostname"},
- hidden = true,
- required = true)
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private String deprecatedHostname;
-
- String getHostname() {
- return hostname != null ? hostname : deprecatedHostname;
- }
- }
}
diff --git
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/OmAddressOptions.java
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/OmAddressOptions.java
index b5336ec8940..843ae8a0edc 100644
---
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/OmAddressOptions.java
+++
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/OmAddressOptions.java
@@ -126,21 +126,8 @@ protected static class ServiceIdOptions {
)
private String serviceID;
- /** For backward compatibility. */
- @CommandLine.Option(
- names = {"-id"},
- hidden = true,
- required = true
- )
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private String deprecatedID;
-
public String getServiceID() {
- if (serviceID != null) {
- return serviceID;
- }
- return deprecatedID;
+ return serviceID;
}
@Override
@@ -159,18 +146,8 @@ protected static class ServiceIdAndHostOptions extends
ServiceIdOptions {
)
private String host;
- /** For backward compatibility. */
- @CommandLine.Option(
- names = {"-host"},
- hidden = true,
- required = true
- )
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private String deprecatedHost;
-
public String getHost() {
- return host != null ? host : deprecatedHost;
+ return host;
}
@Override
diff --git
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/PrepareSubCommand.java
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/PrepareSubCommand.java
index 4dad5f979e7..f1e0c92e691 100644
---
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/PrepareSubCommand.java
+++
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/om/PrepareSubCommand.java
@@ -60,68 +60,36 @@ public class PrepareSubCommand implements Callable<Void> {
names = {"--transaction-apply-wait-timeout"},
description = "Max time in SECONDS to wait for all transactions before" +
"the prepare request to be applied to the OM DB.",
+ defaultValue = "120",
hidden = true
)
- private Long txnApplyWaitTimeSeconds;
-
- /** For backward compatibility. */
- @CommandLine.Option(
- names = {"-tawt"},
- hidden = true
- )
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private Long deprecatedTxnApplyWaitTimeSeconds;
+ private long txnApplyWaitTimeSeconds;
@CommandLine.Option(
names = {"--transaction-apply-check-interval"},
description = "Time in SECONDS to wait between successive checks for " +
"all transactions to be applied to the OM DB.",
+ defaultValue = "5",
hidden = true
)
- private Long txnApplyCheckIntervalSeconds;
-
- /** For backward compatibility. */
- @CommandLine.Option(
- names = {"-tact"},
- hidden = true
- )
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private Long deprecatedTxnApplyCheckIntervalSeconds;
+ private long txnApplyCheckIntervalSeconds;
@CommandLine.Option(
names = {"--prepare-check-interval"},
description = "Time in SECONDS to wait between successive checks for OM"
+
" preparation.",
+ defaultValue = "10",
hidden = true
)
- private Long prepareCheckInterval;
-
- /** For backward compatibility. */
- @CommandLine.Option(
- names = {"-pct"},
- hidden = true
- )
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private Long deprecatedPrepareCheckInterval;
+ private long prepareCheckInterval;
@CommandLine.Option(
names = {"--prepare-timeout"},
description = "Max time in SECONDS to wait for all OMs to be prepared",
+ defaultValue = "300",
hidden = true
)
- private Long prepareTimeOut;
-
- /** For backward compatibility. */
- @CommandLine.Option(
- names = {"-pt"},
- hidden = true
- )
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private Long deprecatedPrepareTimeOut;
+ private long prepareTimeOut;
@Override
public Void call() throws Exception {
@@ -132,8 +100,8 @@ public Void call() throws Exception {
}
private void execute(OzoneManagerProtocol client) throws Exception {
- long prepareTxnId =
client.prepareOzoneManager(getTxnApplyWaitTimeSeconds(),
- getTxnApplyCheckIntervalSeconds());
+ long prepareTxnId = client.prepareOzoneManager(txnApplyWaitTimeSeconds,
+ txnApplyCheckIntervalSeconds);
System.out.println("Ozone Manager Prepare Request successfully returned " +
"with Transaction Id : [" + prepareTxnId + "].");
@@ -141,8 +109,8 @@ private void execute(OzoneManagerProtocol client) throws
Exception {
Set<String> omHosts = getOmHostsFromConfig(
parent.getParent().getOzoneConf(), omServiceOption.getServiceID());
omHosts.forEach(h -> omPreparedStatusMap.put(h, false));
- Duration pTimeout = Duration.of(getPrepareTimeOut(), ChronoUnit.SECONDS);
- Duration pInterval = Duration.of(getPrepareCheckInterval(),
ChronoUnit.SECONDS);
+ Duration pTimeout = Duration.of(prepareTimeOut, ChronoUnit.SECONDS);
+ Duration pInterval = Duration.of(prepareCheckInterval, ChronoUnit.SECONDS);
System.out.println();
System.out.println("Checking individual OM instances for prepare request "
+
@@ -175,7 +143,7 @@ private void execute(OzoneManagerProtocol client) throws
Exception {
}
}
if (currentNumPreparedOms < expectedNumPreparedOms) {
- System.out.println("Waiting for " + getPrepareCheckInterval() +
+ System.out.println("Waiting for " + prepareCheckInterval +
" seconds before retrying...");
Thread.sleep(pInterval.toMillis());
}
@@ -201,30 +169,4 @@ private void execute(OzoneManagerProtocol client) throws
Exception {
}
}
- private long getTxnApplyWaitTimeSeconds() {
- return resolveOption(txnApplyWaitTimeSeconds,
deprecatedTxnApplyWaitTimeSeconds, 120L);
- }
-
- private long getTxnApplyCheckIntervalSeconds() {
- return resolveOption(txnApplyCheckIntervalSeconds,
deprecatedTxnApplyCheckIntervalSeconds, 5L);
- }
-
- private long getPrepareCheckInterval() {
- return resolveOption(prepareCheckInterval, deprecatedPrepareCheckInterval,
10L);
- }
-
- private long getPrepareTimeOut() {
- return resolveOption(prepareTimeOut, deprecatedPrepareTimeOut, 300L);
- }
-
- private static long resolveOption(Long value, Long deprecatedValue, long
defaultValue) {
- if (value != null) {
- return value;
- }
- if (deprecatedValue != null) {
- return deprecatedValue;
- }
- return defaultValue;
- }
-
}
diff --git
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/scm/DecommissionScmSubcommand.java
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/scm/DecommissionScmSubcommand.java
index cb0f5634736..4d6a1113698 100644
---
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/scm/DecommissionScmSubcommand.java
+++
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/ozone/admin/scm/DecommissionScmSubcommand.java
@@ -39,42 +39,23 @@ public class DecommissionScmSubcommand extends
ScmSubcommand {
@CommandLine.ParentCommand
private ScmAdmin parent;
- @CommandLine.ArgGroup(multiplicity = "1")
- private NodeIdOptions nodeIdOptions;
+ @CommandLine.Option(names = {"--nodeid"},
+ description = "NodeID of the SCM to be decommissioned.",
+ required = true)
+ private String nodeId;
@Override
public void execute(ScmClient scmClient) throws IOException {
- DecommissionScmResponseProto response = scmClient.decommissionScm(
- nodeIdOptions.getNodeId());
+ DecommissionScmResponseProto response = scmClient.decommissionScm(nodeId);
if (!response.getSuccess()) {
- String errorMsg = "Error decommissioning Scm " +
nodeIdOptions.getNodeId();
+ String errorMsg = "Error decommissioning Scm " + nodeId;
if (response.hasErrorMsg()) {
errorMsg = errorMsg + ", " + response.getErrorMsg();
}
// Throwing exception to create non-zero exit code in case of failure.
throw new IOException(errorMsg);
} else {
- System.out.println("Decommissioned Scm " + nodeIdOptions.getNodeId());
- }
- }
-
- /** Options for SCM node ID. */
- static class NodeIdOptions {
- @CommandLine.Option(names = {"--nodeid"},
- description = "NodeID of the SCM to be decommissioned.",
- required = true)
- private String nodeId;
-
- /** For backward compatibility. */
- @CommandLine.Option(names = {"-nodeid"},
- hidden = true,
- required = true)
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private String deprecatedNodeId;
-
- String getNodeId() {
- return nodeId != null ? nodeId : deprecatedNodeId;
+ System.out.println("Decommissioned Scm " + nodeId);
}
}
}
diff --git
a/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/cli/TestDeprecatedCliOption.java
b/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/cli/TestOzoneAdminDeprecatedOptions.java
similarity index 59%
rename from
hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/cli/TestDeprecatedCliOption.java
rename to
hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/cli/TestOzoneAdminDeprecatedOptions.java
index 85e00cf8f46..c70cc921eb5 100644
---
a/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/cli/TestDeprecatedCliOption.java
+++
b/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/cli/TestOzoneAdminDeprecatedOptions.java
@@ -21,36 +21,39 @@
import java.io.PrintWriter;
import java.io.StringWriter;
-import org.apache.hadoop.hdds.scm.cli.pipeline.ListPipelinesSubcommand;
+import org.apache.hadoop.ozone.admin.OzoneAdmin;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
import picocli.CommandLine;
/**
- * Tests for deprecated CLI option warnings.
+ * Tests for deprecated CLI option warnings of @{code ozone admin}.
*/
-public class TestDeprecatedCliOption {
+class TestOzoneAdminDeprecatedOptions {
+
+ private CommandLine cli;
private StringWriter err;
@BeforeEach
public void setup() {
err = new StringWriter();
+ cli = createCommandLine();
}
- private CommandLine createCommandLine(Object command) {
- CommandLine cli = new CommandLine(command);
- cli.setErr(new PrintWriter(err, true));
- cli.setExecutionStrategy(parseResult -> {
- DeprecatedCliOption.warnIfMatched(parseResult);
- return CommandLine.ExitCode.OK;
- });
- return cli;
+ private CommandLine createCommandLine() {
+ OzoneAdmin command = new OzoneAdmin();
+ CommandLine cmd = command.getCmd();
+ cmd.setErr(new PrintWriter(err, true));
+ cmd.setExecutionStrategy(parseResult -> CommandLine.ExitCode.OK);
+ return cmd;
}
- @Test
- public void warnsForDeprecatedOption() {
- createCommandLine(new ListPipelinesSubcommand())
- .execute("-ffc", "THREE");
+ @ParameterizedTest
+ @ValueSource(strings = {"-ffc THREE", "-ffc=ONE"})
+ public void warnsForDeprecatedOption(String arg) {
+ execute("pipeline list " + arg);
assertThat(err.toString())
.contains("WARNING: Option '-ffc' is deprecated")
@@ -59,19 +62,22 @@ public void warnsForDeprecatedOption() {
@Test
public void warnsForMultipleDeprecatedOptions() {
- createCommandLine(new ListPipelinesSubcommand())
- .execute("-ffc", "THREE", "-fst", "OPEN");
+ execute("pipeline list -ffc THREE -fst OPEN");
assertThat(err.toString())
.contains("WARNING: Option '-ffc' is deprecated")
.contains("WARNING: Option '-fst' is deprecated");
}
- @Test
- public void doesNotWarnForLongOption() {
- createCommandLine(new ListPipelinesSubcommand())
- .execute("--filter-by-factor", "THREE");
+ @ParameterizedTest
+ @ValueSource(strings = {"--filter-by-factor=THREE", "--filter-by-factor
ONE"})
+ public void doesNotWarnForLongOption(String arg) {
+ execute("pipeline list " + arg);
assertThat(err.toString()).isEmpty();
}
+
+ private void execute(String cmd) {
+ cli.execute(cmd.split(" "));
+ }
}
diff --git
a/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/pipeline/TestClosePipelinesSubCommand.java
b/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/pipeline/TestClosePipelinesSubCommand.java
index ad63c84c860..4a938ac0745 100644
---
a/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/pipeline/TestClosePipelinesSubCommand.java
+++
b/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/pipeline/TestClosePipelinesSubCommand.java
@@ -69,12 +69,12 @@ public static Stream<Arguments> values() {
"with empty parameters"
),
arguments(
- new String[]{"--all", "-ffc", "THREE"},
+ new String[]{"--all", "--filter-by-factor", "THREE"},
"Sending close command for 1 pipelines...\n",
"by filter factor, opened"
),
arguments(
- new String[]{"--all", "-ffc", "ONE"},
+ new String[]{"--all", "--filter-by-factor", "ONE"},
"Sending close command for 0 pipelines...\n",
"by filter factor, closed"
),
diff --git
a/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/pipeline/TestListPipelinesSubCommand.java
b/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/pipeline/TestListPipelinesSubCommand.java
index 2dc57b55265..803a3b7324c 100644
---
a/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/pipeline/TestListPipelinesSubCommand.java
+++
b/hadoop-ozone/cli-admin/src/test/java/org/apache/hadoop/hdds/scm/cli/pipeline/TestListPipelinesSubCommand.java
@@ -124,7 +124,7 @@ public void testReplicationAndType() throws IOException {
@Test
public void testLegacyFactorWithoutType() throws IOException {
CommandLine c = new CommandLine(cmd);
- c.parseArgs("-ffc", "THREE");
+ c.parseArgs("--filter-by-factor", "THREE");
cmd.execute(scmClient);
String output = outContent.toString(DEFAULT_ENCODING);
@@ -135,7 +135,7 @@ public void testLegacyFactorWithoutType() throws
IOException {
@Test
public void factorAndReplicationAreMutuallyExclusive() {
CommandLine c = new CommandLine(cmd);
- c.parseArgs("-r", "THREE", "-ffc", "ONE");
+ c.parseArgs("-r", "THREE", "--filter-by-factor", "ONE");
assertThrows(IllegalArgumentException.class, () -> cmd.execute(scmClient));
}
@@ -165,7 +165,7 @@ public void testReplicationAndTypeAndState() throws
IOException {
@Test
public void testLegacyFactorAndState() throws IOException {
CommandLine c = new CommandLine(cmd);
- c.parseArgs("-ffc", "THREE", "-fst", "OPEN");
+ c.parseArgs("--filter-by-factor", "THREE", "--state", "OPEN");
cmd.execute(scmClient);
String output = outContent.toString(DEFAULT_ENCODING);
diff --git
a/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/Shell.java
b/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/Shell.java
index 267bf4eedba..5106497a8d1 100644
---
a/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/Shell.java
+++
b/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/Shell.java
@@ -19,7 +19,6 @@
import java.util.Collections;
import java.util.List;
-import org.apache.hadoop.hdds.cli.DeprecatedCliOption;
import org.apache.hadoop.hdds.cli.GenericCli;
import org.apache.hadoop.hdds.tracing.TracingUtil;
import org.apache.hadoop.ozone.om.exceptions.OMException;
@@ -90,7 +89,6 @@ protected List<String> interactiveWelcomeLines() {
}
private int execute(CommandLine.ParseResult parseResult) {
- DeprecatedCliOption.warnIfMatched(parseResult);
name = spec.name();
if (parseResult.hasMatchedOption("--interactive") ||
parseResult.hasMatchedOption("--execute")) {
diff --git
a/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/acl/AclOption.java
b/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/acl/AclOption.java
index e15980ff805..8acf81bdb05 100644
---
a/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/acl/AclOption.java
+++
b/hadoop-ozone/cli-shell/src/main/java/org/apache/hadoop/ozone/shell/acl/AclOption.java
@@ -31,39 +31,24 @@
*/
public class AclOption implements CommandLine.ITypeConverter<OzoneAcl> {
- @CommandLine.ArgGroup(multiplicity = "1")
- private Exclusive exclusive = new Exclusive();
-
- private static final class Exclusive {
- @CommandLine.Option(names = {"--acls", "--acl", "-a"}, split = ",",
- required = true,
- converter = AclOption.class,
- description = "Comma separated ACL list:%n" +
- "Example: user:user2:a OR user:user1:rw,group:hadoop:a%n" +
- "r = READ, " +
- "w = WRITE, " +
- "c = CREATE, " +
- "d = DELETE, " +
- "l = LIST, " +
- "a = ALL, " +
- "n = NONE, " +
- "x = READ_ACL, " +
- "y = WRITE_ACL.")
- private OzoneAcl[] values;
-
- /** For backward compatibility. */
- @CommandLine.Option(names = {"-al"}, split = ",", hidden = true,
- required = true, converter = AclOption.class)
- @Deprecated
- @SuppressWarnings("DeprecatedIsStillUsed")
- private OzoneAcl[] deprecatedValues;
- }
+ @CommandLine.Option(names = {"--acls", "--acl", "-a"}, split = ",",
+ required = true,
+ converter = AclOption.class,
+ description = "Comma separated ACL list:%n" +
+ "Example: user:user2:a OR user:user1:rw,group:hadoop:a%n" +
+ "r = READ, " +
+ "w = WRITE, " +
+ "c = CREATE, " +
+ "d = DELETE, " +
+ "l = LIST, " +
+ "a = ALL, " +
+ "n = NONE, " +
+ "x = READ_ACL, " +
+ "y = WRITE_ACL.")
+ private OzoneAcl[] values;
private List<OzoneAcl> getAclList() {
- OzoneAcl[] acls = exclusive.values != null
- ? exclusive.values
- : exclusive.deprecatedValues;
- return ImmutableList.copyOf(acls);
+ return ImmutableList.copyOf(values);
}
public void addTo(OzoneObj obj, ObjectStore objectStore, PrintWriter out)
diff --git a/hadoop-ozone/dist/src/main/smoketest/admincli/pipeline.robot
b/hadoop-ozone/dist/src/main/smoketest/admincli/pipeline.robot
index 90b119dac73..4499d1a600c 100644
--- a/hadoop-ozone/dist/src/main/smoketest/admincli/pipeline.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/admincli/pipeline.robot
@@ -24,23 +24,39 @@ Test Timeout 5 minutes
${PIPELINE}
${SCM} scm
+*** Keywords ***
+List Should Have Ratis Pipeline
+ [arguments] ${json} ${factor} ${expected}=${TRUE}
+ ${actual} = Execute echo '${json}' | jq 'map(.replicationConfig) |
contains([{"replicationFactor": "${factor}", "replicationType": "RATIS"}])'
+ Should Be Equal '${expected}' '${actual}' ignore_case=True
+
*** Test Cases ***
List pipelines
${output} = Execute ozone admin pipeline list
Should contain ${output} RATIS/ONE
- ${pipeline} = Execute ozone admin pipeline list | grep
'ReplicationConfig: RATIS/ONE' | head -n 1 | cut -d' ' -f3 | sed 's/,$//'
+ ${pipeline} = Execute echo '${output}' | grep
'ReplicationConfig: RATIS/ONE' | head -n 1 | cut -d' ' -f3 | sed 's/,$//'
Set Suite Variable ${PIPELINE} ${pipeline}
List pipeline with json option
- ${output} = Execute ozone admin pipeline list --json | jq
'map(.replicationConfig) | contains([{"replicationFactor": "ONE",
"replicationType": "RATIS"}])'
- Should be true $output
+ ${output} = Execute ozone admin pipeline list --json
+ List Should Have Ratis Pipeline ${output} ONE
List pipelines with explicit host
${output} = Execute ozone admin pipeline list --scm ${SCM}
Should contain ${output} RATIS/ONE
List pipelines with explicit host and json option
- ${output} = Execute ozone admin pipeline list --scm ${SCM}
--json | jq 'map(.replicationConfig) | contains([{"replicationFactor": "ONE",
"replicationType": "RATIS"}])'
+ ${output} = Execute ozone admin pipeline list --scm ${SCM} --json
+ List Should Have Ratis Pipeline ${output} ONE
+
+List pipeline respects deprecated option -ffc
+ ${output} = Execute ozone admin pipeline list --json -ffc
ONE 2>/dev/null
+ List Should Have Ratis Pipeline ${output} ONE
+ List Should Have Ratis Pipeline ${output} THREE ${FALSE}
+
+List pipeline respects deprecated option -fst
+ ${output} = Execute ozone admin pipeline list -fst DORMANT
+ Should Not Contain ${output} DORMANT
Deactivate pipeline
Execute ozone admin pipeline deactivate
"${PIPELINE}"
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]