Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -186,4 +186,4 @@ Verify Container Balancer for RATIS/EC containers
#We need to ensure that after balancing, the amount of data recorded on each datanode falls within the following ranges:
#{SIZE}*3 < used < {SIZE}*3.5 for RATIS containers, and {SIZE}*0.7 < used < {SIZE}*1.5 for EC containers.
Should Be True ${datanodeOzoneUsedBytesInfoAfterContainerBalancing} < ${SIZE} * ${UPPER_LIMIT}
Should Be True ${datanodeOzoneUsedBytesInfoAfterContainerBalancing} > ${SIZE} * ${LOWER_LIMIT}
Should Be True ${datanodeOzoneUsedBytesInfoAfterContainerBalancing} > ${SIZE} * ${LOWER_LIMIT}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -324,7 +319,7 @@ public void init() {
LOG.error("HTTP server can't be stopped.", ex);
}
printReport();
if (verbose) {
if (freonCommand.isVerbose()) {
printOption();
}
}, 10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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.");
}
}
Expand Down Expand Up @@ -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);
Expand Down