Return-Path: X-Original-To: apmail-accumulo-commits-archive@www.apache.org Delivered-To: apmail-accumulo-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8BED410B65 for ; Wed, 1 May 2013 20:23:01 +0000 (UTC) Received: (qmail 82595 invoked by uid 500); 1 May 2013 20:23:01 -0000 Delivered-To: apmail-accumulo-commits-archive@accumulo.apache.org Received: (qmail 82570 invoked by uid 500); 1 May 2013 20:23:01 -0000 Mailing-List: contact commits-help@accumulo.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@accumulo.apache.org Delivered-To: mailing list commits@accumulo.apache.org Received: (qmail 82563 invoked by uid 99); 1 May 2013 20:23:01 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 May 2013 20:23:01 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 May 2013 20:23:00 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D8E502388B34; Wed, 1 May 2013 20:22:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1478176 - in /accumulo/trunk: ./ core/src/main/java/org/apache/accumulo/core/client/admin/ core/src/main/java/org/apache/accumulo/core/util/ core/src/main/java/org/apache/accumulo/core/util/shell/commands/ test/ Date: Wed, 01 May 2013 20:22:39 -0000 To: commits@accumulo.apache.org From: ecn@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130501202239.D8E502388B34@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ecn Date: Wed May 1 20:22:39 2013 New Revision: 1478176 URL: http://svn.apache.org/r1478176 Log: ACCUMULO-1370 ignore configuration files for rat check Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/shell/commands/DUCommand.java accumulo/trunk/pom.xml accumulo/trunk/test/pom.xml Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java?rev=1478176&r1=1478175&r2=1478176&view=diff ============================================================================== --- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java (original) +++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/client/admin/TableOperations.java Wed May 1 20:22:39 2013 @@ -24,7 +24,6 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.SortedSet; -import java.util.TreeSet; import org.apache.accumulo.core.client.AccumuloException; import org.apache.accumulo.core.client.AccumuloSecurityException; Modified: accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java?rev=1478176&r1=1478175&r2=1478176&view=diff ============================================================================== --- accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java (original) +++ accumulo/trunk/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java Wed May 1 20:22:39 2013 @@ -116,17 +116,18 @@ public class TableDiskUsage { void print(String line); } - public static void printDiskUsage(AccumuloConfiguration acuConf, Collection tables, FileSystem fs, Connector conn) throws TableNotFoundException, + public static void printDiskUsage(AccumuloConfiguration acuConf, Collection tables, FileSystem fs, Connector conn, boolean humanReadable) + throws TableNotFoundException, IOException { printDiskUsage(acuConf, tables, fs, conn, new Printer() { @Override public void print(String line) { System.out.println(line); } - }); + }, humanReadable); } - public static Map,Long> getDiskUsage(AccumuloConfiguration acuConf, Collection tables, FileSystem fs, Connector conn) + public static Map,Long> getDiskUsage(AccumuloConfiguration acuConf, Collection tables, FileSystem fs, Connector conn, boolean humanReadable) throws TableNotFoundException, IOException { TableDiskUsage tdu = new TableDiskUsage(); @@ -232,12 +233,24 @@ public class TableDiskUsage { return usage; } - public static void printDiskUsage(AccumuloConfiguration acuConf, Collection tables, FileSystem fs, Connector conn, Printer printer) + public static void printDiskUsage(AccumuloConfiguration acuConf, Collection tables, FileSystem fs, Connector conn, Printer printer, boolean humanReadable) throws TableNotFoundException, IOException { - Map,Long> usage = getDiskUsage(acuConf, tables, fs, conn); + Map,Long> usage = getDiskUsage(acuConf, tables, fs, conn, humanReadable); - for (Entry,Long> entry : usage.entrySet()) - printer.print(String.format("%,24d %s", entry.getValue(), entry.getKey())); + for (Entry,Long> entry : usage.entrySet()) { + String valueFormat = humanReadable ? "%s" : "%,24d"; + Object value = humanReadable ? humanReadableBytes(entry.getValue()) : entry.getValue(); + printer.print(String.format(valueFormat + " %s", value, entry.getKey())); + } + } + + public static String humanReadableBytes(long bytes) { + if (bytes < 1024) return String.format("%4dB", bytes); + int exp = (int) (Math.log(bytes) / Math.log(1024)); + String pre = "KMGTPE".charAt(exp-1) + ""; + double val = bytes / Math.pow(1024, exp); + return String.format(val >= 1000 ? "%4.0f%s" : " %3.1f%s", val, pre); } + } 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=1478176&r1=1478175&r2=1478176&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 Wed May 1 20:22:39 2013 @@ -36,11 +36,14 @@ import org.apache.hadoop.fs.FileSystem; public class DUCommand extends Command { - private Option optTablePattern; - + private Option optTablePattern, optHumanReadble; + public int execute(final String fullCommand, final CommandLine cl, final Shell shellState) throws IOException, TableNotFoundException { - + final SortedSet tablesToFlush = new TreeSet(Arrays.asList(cl.getArgs())); + + 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()))) { @@ -63,7 +66,7 @@ public class DUCommand extends Command { } } - }); + }, prettyPrint); } catch (Exception ex) { throw new RuntimeException(ex); } @@ -81,8 +84,12 @@ public class DUCommand extends Command { optTablePattern = new Option("p", "pattern", true, "regex pattern of table names"); optTablePattern.setArgName("pattern"); - + + optHumanReadble = new Option("h", "human-readable", false, "format large sizes to human readable units"); + optHumanReadble.setArgName("human readable output"); + o.addOption(optTablePattern); + o.addOption(optHumanReadble); return o; } Modified: accumulo/trunk/pom.xml URL: http://svn.apache.org/viewvc/accumulo/trunk/pom.xml?rev=1478176&r1=1478175&r2=1478176&view=diff ============================================================================== --- accumulo/trunk/pom.xml (original) +++ accumulo/trunk/pom.xml Wed May 1 20:22:39 2013 @@ -446,6 +446,11 @@ docs/apidocs/package-list + conf/slaves + conf/masters + conf/gc + conf/tracers + conf/monitor Modified: accumulo/trunk/test/pom.xml URL: http://svn.apache.org/viewvc/accumulo/trunk/test/pom.xml?rev=1478176&r1=1478175&r2=1478176&view=diff ============================================================================== --- accumulo/trunk/test/pom.xml (original) +++ accumulo/trunk/test/pom.xml Wed May 1 20:22:39 2013 @@ -122,6 +122,7 @@ system/bench/lib/*splits + system/continuous/*.txt