accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1459788 - in /accumulo/branches/1.5/core/src: main/java/org/apache/accumulo/core/util/TableDiskUsage.java test/java/org/apache/accumulo/core/util/shell/ShellTest.java
Date Fri, 22 Mar 2013 14:13:15 GMT
Author: ecn
Date: Fri Mar 22 14:13:15 2013
New Revision: 1459788

URL: http://svn.apache.org/r1459788
Log:
ACCUMULO-1192 applying Kevin Faro's patch to fix du on an empty table

Modified:
    accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java
    accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java

Modified: accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java?rev=1459788&r1=1459787&r2=1459788&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java
(original)
+++ accumulo/branches/1.5/core/src/main/java/org/apache/accumulo/core/util/TableDiskUsage.java
Fri Mar 22 14:13:15 2013
@@ -144,12 +144,17 @@ public class TableDiskUsage {
       tdu.addTable(tableId);
     
     HashSet<String> tablesReferenced = new HashSet<String>(tableIds);
+    HashSet<String> emptyTableIds = new HashSet<String>();
     
     for (String tableId : tableIds) {
       Scanner mdScanner = conn.createScanner(Constants.METADATA_TABLE_NAME, Constants.NO_AUTHS);
       mdScanner.fetchColumnFamily(Constants.METADATA_DATAFILE_COLUMN_FAMILY);
       mdScanner.setRange(new KeyExtent(new Text(tableId), null, null).toMetadataRange());
       
+      if(!mdScanner.iterator().hasNext()) {
+        emptyTableIds.add(tableId);
+      }
+      
       for (Entry<Key,Value> entry : mdScanner) {
         String file = entry.getKey().getColumnQualifier().toString();
         if (file.startsWith("../")) {
@@ -215,6 +220,14 @@ public class TableDiskUsage {
       
       usage.put(tableNames, entry.getValue());
     }
+
+    if(!emptyTableIds.isEmpty()) {
+      TreeSet<String> emptyTables = new TreeSet<String>();
+      for (String tableId : emptyTableIds) {
+        emptyTables.add(reverseTableIdMap.get(tableId));
+      }
+      usage.put(emptyTables, 0L);
+    }
     
     for (Entry<TreeSet<String>,Long> entry : usage.entrySet())
       printer.print(String.format("%,24d %s", entry.getValue(), entry.getKey()));

Modified: accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
URL: http://svn.apache.org/viewvc/accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java?rev=1459788&r1=1459787&r2=1459788&view=diff
==============================================================================
--- accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
(original)
+++ accumulo/branches/1.5/core/src/test/java/org/apache/accumulo/core/util/shell/ShellTest.java
Fri Mar 22 14:13:15 2013
@@ -165,4 +165,21 @@ public class ShellTest {
     //exec("createuser root", false, "user exists");
   }
   
+  @Test
+  public void duTest() throws IOException {
+    Shell.log.debug("Starting DU test --------------------------");
+    exec("createtable t", true);
+    exec("du t", true, "0 [t]");
+    exec("deletetable t -f", true, "Table: [t] has been deleted");
+  }
+  
+  @Test
+  public void duPatternTest() throws IOException {
+    Shell.log.debug("Starting DU with pattern test --------------------------");
+    exec("createtable t", true);
+    exec("createtable tt", true);
+    exec("du -p t.*", true, "0 [t, tt]");
+    exec("deletetable t -f", true, "Table: [t] has been deleted");
+    exec("deletetable tt -f", true, "Table: [tt] has been deleted");
+  }
 }



Mime
View raw message