accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
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 GMT
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<String>
tables, FileSystem fs, Connector conn) throws TableNotFoundException,
+  public static void printDiskUsage(AccumuloConfiguration acuConf, Collection<String>
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<TreeSet<String>,Long> getDiskUsage(AccumuloConfiguration
acuConf, Collection<String> tables, FileSystem fs, Connector conn)
+  public static Map<TreeSet<String>,Long> getDiskUsage(AccumuloConfiguration
acuConf, Collection<String> 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<String>
tables, FileSystem fs, Connector conn, Printer printer)
+  public static void printDiskUsage(AccumuloConfiguration acuConf, Collection<String>
tables, FileSystem fs, Connector conn, Printer printer, boolean humanReadable)
       throws TableNotFoundException, IOException {
     
-    Map<TreeSet<String>,Long> usage = getDiskUsage(acuConf, tables, fs, conn);
+    Map<TreeSet<String>,Long> usage = getDiskUsage(acuConf, tables, fs, conn,
humanReadable);
     
-    for (Entry<TreeSet<String>,Long> entry : usage.entrySet())
-      printer.print(String.format("%,24d %s", entry.getValue(), entry.getKey()));
+    for (Entry<TreeSet<String>,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<String> tablesToFlush = new TreeSet<String>(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 @@
           <configuration>
             <excludes>
               <exclude>docs/apidocs/package-list</exclude>
+              <exclude>conf/slaves</exclude>
+              <exclude>conf/masters</exclude>
+              <exclude>conf/gc</exclude>
+              <exclude>conf/tracers</exclude>
+              <exclude>conf/monitor</exclude>
             </excludes>
           </configuration>
         </plugin>

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 @@
           <configuration>
             <excludes>
               <exclude>system/bench/lib/*splits</exclude>
+              <exclude>system/continuous/*.txt</exclude>
             </excludes>
           </configuration>
         </plugin>



Mime
View raw message