Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASSANDRA-19335 Default nodetool tablestats to Human-Readable Output #3069

Open
wants to merge 7 commits into
base: trunk
Choose a base branch
from
10 changes: 5 additions & 5 deletions src/java/org/apache/cassandra/tools/nodetool/TableStats.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public class TableStats extends NodeToolCmd
@Option(name = "-i", description = "Ignore the list of tables and display the remaining tables")
private boolean ignore = false;

@Option(title = "human_readable",
name = {"-H", "--human-readable"},
description = "Display bytes in human readable form, i.e. KiB, MiB, GiB, TiB")
private boolean humanReadable = false;
@Option(title = "no_human_readable",
name = {"-r", "--no-human-readable"},
description = "Disable displaying bytes in human readable form")
private boolean noHumanReadable = false;

@Option(title = "format",
name = {"-F", "--format"},
Expand Down Expand Up @@ -98,7 +98,7 @@ public void execute(NodeProbe probe)
throw new IllegalArgumentException("argument for top must be a positive integer.");
}

StatsHolder holder = new TableStatsHolder(probe, humanReadable, ignore, tableNames, sortKey, top, locationCheck);
StatsHolder holder = new TableStatsHolder(probe, outputFormat.isEmpty() && !noHumanReadable, ignore, tableNames, sortKey, top, locationCheck);
// print out the keyspace and table statistics
StatsPrinter printer = TableStatsPrinter.from(outputFormat, !sortKey.isEmpty());
printer.print(holder, probe.output().out);
Expand Down
29 changes: 15 additions & 14 deletions test/unit/org/apache/cassandra/tools/nodetool/TableStatsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,26 +61,24 @@ public void testMaybeChangeDocs()
" [(-pp | --print-port)] [(-pw <password> | --password <password>)]\n" +
" [(-pwf <passwordFilePath> | --password-file <passwordFilePath>)]\n" +
" [(-u <username> | --username <username>)] tablestats\n" +
" [(-F <format> | --format <format>)] [(-H | --human-readable)] [-i]\n" +
" [(-l | --sstable-location-check)] [(-s <sort_key> | --sort <sort_key>)]\n" +
" [(-t <top> | --top <top>)] [--] [<keyspace.table>...]\n" +
"\n" +
" [(-F <format> | --format <format>)] [-i]\n" +
" [(-l | --sstable-location-check)] [(-r | --no-human-readable)]\n" +
" [(-s <sort_key> | --sort <sort_key>)] [(-t <top> | --top <top>)] [--]\n" +
" [<keyspace.table>...]\n" +
"\n" +
"OPTIONS\n" +
" -F <format>, --format <format>\n" +
" Output format (json, yaml)\n" +
"\n" +
"\n" +
" -h <host>, --host <host>\n" +
" Node hostname or ip address\n" +
"\n" +
" -H, --human-readable\n" +
" Display bytes in human readable form, i.e. KiB, MiB, GiB, TiB\n" +
"\n" +
"\n" +
" -i\n" +
" Ignore the list of tables and display the remaining tables\n" +
"\n" +
" -l, --sstable-location-check\n" +
" Check whether or not the SSTables are in the correct location.\n" +
"\n" +
"\n" +
" -p <port>, --port <port>\n" +
" Remote jmx agent port number\n" +
"\n" +
Expand All @@ -91,7 +89,10 @@ public void testMaybeChangeDocs()
" Remote jmx agent password\n" +
"\n" +
" -pwf <passwordFilePath>, --password-file <passwordFilePath>\n" +
" Path to the JMX password file\n" +
" Path to the JMX password file\n" +
"\n" +
" -r, --no-human-readable\n" +
" Disable displaying bytes in human readable form\n" +
"\n" +
" -s <sort_key>, --sort <sort_key>\n" +
" Sort tables by specified sort key\n" +
Expand Down Expand Up @@ -159,12 +160,12 @@ public void testTableIgnoreArg()
}

@Test
public void testHumanReadableArg()
public void testNoHumanReadableArg()
{
Arrays.asList("-H", "--human-readable").forEach(arg -> {
Arrays.asList("-r", "--no-human-readable").forEach(arg -> {
ToolRunner.ToolResult tool = ToolRunner.invokeNodetool("tablestats", arg);
tool.assertOnCleanExit();
assertThat(tool.getStdout()).contains(" KiB");
assertThat(tool.getStdout()).doesNotContain(" KiB");
});
}

Expand Down