This is an automated email from the ASF dual-hosted git repository.
adoroszlai 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 3ebe5e7cd8 HDDS-12660. Allow --verbose option of GenericCli at leaf
subcommands (#8166)
3ebe5e7cd8 is described below
commit 3ebe5e7cd87ced115532284effd9389d5f123dce
Author: Sarveksha Yeshavantha Raju
<[email protected]>
AuthorDate: Thu Mar 27 17:51:44 2025 +0530
HDDS-12660. Allow --verbose option of GenericCli at leaf subcommands (#8166)
---
.../main/java/org/apache/hadoop/hdds/cli/GenericCli.java | 1 +
.../hdds/scm/cli/ContainerBalancerStatusSubcommand.java | 6 +-----
.../hadoop/hdds/scm/cli/SafeModeCheckSubcommand.java | 7 +------
.../cli/datanode/TestContainerBalancerSubCommand.java | 16 ++++++++++++----
.../dist/src/main/smoketest/balancer/testBalancer.robot | 4 ++--
.../apache/hadoop/ozone/freon/BaseFreonGenerator.java | 7 +------
.../org/apache/hadoop/ozone/repair/om/FSORepairTool.java | 8 ++------
7 files changed, 20 insertions(+), 29 deletions(-)
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 152a59d41e..705909fc90 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
@@ -48,6 +48,7 @@ public abstract class GenericCli implements
GenericParentCommand {
private UserGroupInformation user;
@Option(names = {"--verbose"},
+ scope = CommandLine.ScopeType.INHERIT,
description = "More verbose output. Show the stack trace of the errors.")
private boolean verbose;
diff --git
a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ContainerBalancerStatusSubcommand.java
b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ContainerBalancerStatusSubcommand.java
index 7edecd7822..c18491c2da 100644
---
a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ContainerBalancerStatusSubcommand.java
+++
b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/ContainerBalancerStatusSubcommand.java
@@ -49,10 +49,6 @@
versionProvider = HddsVersionProvider.class)
public class ContainerBalancerStatusSubcommand extends ScmSubcommand {
- @CommandLine.Option(names = {"-v", "--verbose"},
- description = "Verbose output. Show current iteration info.")
- private boolean verbose;
-
@CommandLine.Option(names = {"-H", "--history"},
description = "Verbose output with history. Show current iteration info
and history of iterations. " +
"Works only with -v.")
@@ -69,7 +65,7 @@ public void execute(ScmClient scmClient) throws IOException {
LocalDateTime.ofInstant(startedAtInstant, ZoneId.systemDefault());
System.out.println("ContainerBalancer is Running.");
- if (verbose) {
+ if (isVerbose()) {
System.out.printf("Started at: %s %s%n",
dateTime.toLocalDate().format(DateTimeFormatter.ISO_LOCAL_DATE),
dateTime.toLocalTime().format(DateTimeFormatter.ISO_LOCAL_TIME));
diff --git
a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SafeModeCheckSubcommand.java
b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SafeModeCheckSubcommand.java
index 265b23c25d..d15be56410 100644
---
a/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SafeModeCheckSubcommand.java
+++
b/hadoop-hdds/tools/src/main/java/org/apache/hadoop/hdds/scm/cli/SafeModeCheckSubcommand.java
@@ -22,7 +22,6 @@
import org.apache.commons.lang3.tuple.Pair;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.scm.client.ScmClient;
-import picocli.CommandLine;
import picocli.CommandLine.Command;
/**
@@ -35,10 +34,6 @@
versionProvider = HddsVersionProvider.class)
public class SafeModeCheckSubcommand extends ScmSubcommand {
- @CommandLine.Option(names = {"--verbose"},
- description = "Show detailed status of rules.")
- private boolean verbose;
-
@Override
public void execute(ScmClient scmClient) throws IOException {
boolean execReturn = scmClient.inSafeMode();
@@ -49,7 +44,7 @@ public void execute(ScmClient scmClient) throws IOException {
} else {
System.out.println("SCM is out of safe mode.");
}
- if (verbose) {
+ if (isVerbose()) {
for (Map.Entry<String, Pair<Boolean, String>> entry :
scmClient.getSafeModeRuleStatuses().entrySet()) {
Pair<Boolean, String> value = entry.getValue();
diff --git
a/hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestContainerBalancerSubCommand.java
b/hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestContainerBalancerSubCommand.java
index 30919d525f..48fddc6236 100644
---
a/hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestContainerBalancerSubCommand.java
+++
b/hadoop-hdds/tools/src/test/java/org/apache/hadoop/hdds/scm/cli/datanode/TestContainerBalancerSubCommand.java
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.Arrays;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Pattern;
import
org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos;
import
org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.ContainerBalancerStatusInfoProto;
@@ -85,6 +86,7 @@ class TestContainerBalancerSubCommand {
private ContainerBalancerStatusSubcommand statusCmd;
private GenericTestUtils.PrintStreamCapturer out;
private GenericTestUtils.PrintStreamCapturer err;
+ private AtomicBoolean verbose;
private static ContainerBalancerStatusInfoResponseProto
getContainerBalancerStatusInfoResponseProto(
ContainerBalancerConfiguration config) {
@@ -230,9 +232,15 @@ private static ContainerBalancerConfiguration
getContainerBalancerConfiguration(
@BeforeEach
void setup() {
+ verbose = new AtomicBoolean();
stopCmd = new ContainerBalancerStopSubcommand();
startCmd = new ContainerBalancerStartSubcommand();
- statusCmd = new ContainerBalancerStatusSubcommand();
+ statusCmd = new ContainerBalancerStatusSubcommand() {
+ @Override
+ protected boolean isVerbose() {
+ return verbose.get();
+ }
+ };
out = GenericTestUtils.captureOut();
err = GenericTestUtils.captureErr();
}
@@ -294,7 +302,8 @@ void
testContainerBalancerStatusInfoSubcommandVerboseHistory()
//test status is running
when(scmClient.getContainerBalancerStatusInfo()).thenReturn(statusInfoResponseProto);
CommandLine c = new CommandLine(statusCmd);
- c.parseArgs("--verbose", "--history");
+ verbose.set(true);
+ c.parseArgs("--history");
statusCmd.execute(scmClient);
String firstHistoryIterationOutput =
@@ -355,8 +364,7 @@ void testContainerBalancerStatusInfoSubcommandVerbose()
statusInfoResponseProto =
getContainerBalancerStatusInfoResponseProto(config);
//test status is running
when(scmClient.getContainerBalancerStatusInfo()).thenReturn(statusInfoResponseProto);
- CommandLine c = new CommandLine(statusCmd);
- c.parseArgs("--verbose");
+ verbose.set(true);
statusCmd.execute(scmClient);
String currentIterationOutput =
diff --git a/hadoop-ozone/dist/src/main/smoketest/balancer/testBalancer.robot
b/hadoop-ozone/dist/src/main/smoketest/balancer/testBalancer.robot
index 21490e84d6..b180159136 100644
--- a/hadoop-ozone/dist/src/main/smoketest/balancer/testBalancer.robot
+++ b/hadoop-ozone/dist/src/main/smoketest/balancer/testBalancer.robot
@@ -98,13 +98,13 @@ Run Balancer Status
Should Contain ${result}
ContainerBalancer is Running.
Run Balancer Verbose Status
- ${result} = Execute ozone admin
containerbalancer status -v
+ ${result} = Execute ozone admin
containerbalancer status --verbose
Verify Balancer Iteration ${result} 1
Should Contain ${result}
Iteration result - collapse_spaces=True
Run Balancer Verbose History Status
- ${result} = Execute ozone admin
containerbalancer status -v --history
+ ${result} = Execute ozone admin
containerbalancer status --verbose --history
Verify Balancer Iteration ${result} 1
Verify Balancer Iteration History ${result}
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/BaseFreonGenerator.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/BaseFreonGenerator.java
index c7b2ed2807..eb9be2c292 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/BaseFreonGenerator.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/freon/BaseFreonGenerator.java
@@ -117,11 +117,6 @@ public class BaseFreonGenerator implements FreonSubcommand
{
defaultValue = "")
private String prefix = "";
- @Option(names = {"--verbose"},
- description = "More verbose output. "
- + "Show all the command line Option info.")
- private boolean verbose;
-
@CommandLine.Spec
private CommandLine.Model.CommandSpec spec;
@@ -324,7 +319,7 @@ public void init() {
LOG.error("HTTP server can't be stopped.", ex);
}
printReport();
- if (verbose) {
+ if (freonCommand.isVerbose()) {
printOption();
}
}, 10);
diff --git
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/om/FSORepairTool.java
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/om/FSORepairTool.java
index 8b45435a4f..66460b9f85 100644
---
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/om/FSORepairTool.java
+++
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/repair/om/FSORepairTool.java
@@ -93,10 +93,6 @@ public class FSORepairTool extends RepairTool {
description = "Filter by bucket name")
private String bucketFilter;
- @CommandLine.Option(names = {"--verbose"},
- description = "Verbose output. Show all intermediate steps.")
- private boolean verbose;
-
@Nonnull
@Override
protected Component serviceToBeOffline() {
@@ -112,7 +108,7 @@ public void execute() throws Exception {
throw new IllegalArgumentException("FSO repair failed: " +
ex.getMessage());
}
- if (verbose) {
+ if (isVerbose()) {
info("FSO repair finished.");
}
}
@@ -407,7 +403,7 @@ protected void markFileForDeletion(String fileKey,
OmKeyInfo fileInfo) throws IO
// directory delete. It is also not possible here if the file's parent
// is gone. The name of the key does not matter so just use IDs.
deletedTable.putWithBatch(batch, fileKey, updatedRepeatedOmKeyInfo);
- if (verbose) {
+ if (isVerbose()) {
info("Added entry " + fileKey + " to open key table: " +
updatedRepeatedOmKeyInfo);
}
store.commitBatchOperation(batch);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]