You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ec...@apache.org on 2013/06/20 19:32:32 UTC
svn commit: r1495111 -
/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
Author: ecn
Date: Thu Jun 20 17:32:32 2013
New Revision: 1495111
URL: http://svn.apache.org/r1495111
Log:
ACCUMULO-1513 add -t argument to make du more like other commands
Modified:
accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java?rev=1495111&r1=1495110&r2=1495111&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java (original)
+++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java Thu Jun 20 17:32:32 2013
@@ -36,25 +36,33 @@ public class DUCommand extends Command {
public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, TableNotFoundException {
- final SortedSet<String> tablesToFlush = new TreeSet<String>(Arrays.asList(cl.getArgs()));
+ final SortedSet<String> tables = new TreeSet<String>(Arrays.asList(cl.getArgs()));
+
+ if (cl.hasOption(Shell.tableOption)) {
+ String tableName = cl.getOptionValue(Shell.tableOption);
+ if (!shellState.getConnector().tableOperations().exists(tableName)) {
+ throw new TableNotFoundException(tableName, tableName, "specified table that doesn't exist");
+ }
+ tables.add(tableName);
+ }
boolean prettyPrint = cl.hasOption(optHumanReadble.getOpt()) ? true : false;
if (cl.hasOption(optTablePattern.getOpt())) {
for (String table : shellState.getConnector().tableOperations().list()) {
if (table.matches(cl.getOptionValue(optTablePattern.getOpt()))) {
- tablesToFlush.add(table);
+ tables.add(table);
}
}
} else {
- if (tablesToFlush.isEmpty()) {
+ if (tables.isEmpty()) {
shellState.checkTableState();
- tablesToFlush.add(shellState.getTableName());
+ tables.add(shellState.getTableName());
}
}
try {
String valueFormat = prettyPrint ? "%9s" : "%,24d";
- for (DiskUsage usage : shellState.getConnector().tableOperations().getDiskUsage(tablesToFlush)) {
+ for (DiskUsage usage : shellState.getConnector().tableOperations().getDiskUsage(tables)) {
Object value = prettyPrint ? NumUtil.bigNumberForSize(usage.getUsage()) : usage.getUsage();
shellState.getReader().println(String.format(valueFormat + " %s", value, usage.getTables()));
}
@@ -78,6 +86,8 @@ public class DUCommand extends Command {
optHumanReadble = new Option("h", "human-readable", false, "format large sizes to human readable units");
optHumanReadble.setArgName("human readable output");
+
+ o.addOption(OptUtil.tableOpt("table to examine"));
o.addOption(optTablePattern);
o.addOption(optHumanReadble);