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/11/06 15:31:30 UTC

[2/3] git commit: ACCUMULO-1761 use file size information from !METADATA instead of asking the namenode, avoids using ServerConstants.getTablesDirs()

ACCUMULO-1761 use file size information from !METADATA instead of asking the namenode, avoids using ServerConstants.getTablesDirs()


Project: http://git-wip-us.apache.org/repos/asf/accumulo/repo
Commit: http://git-wip-us.apache.org/repos/asf/accumulo/commit/dcb55916
Tree: http://git-wip-us.apache.org/repos/asf/accumulo/tree/dcb55916
Diff: http://git-wip-us.apache.org/repos/asf/accumulo/diff/dcb55916

Branch: refs/heads/master
Commit: dcb559165b587eca9e5bf0b64df8031c748d3f37
Parents: 82896bd
Author: Eric Newton <er...@gmail.com>
Authored: Wed Nov 6 09:31:20 2013 -0500
Committer: Eric Newton <er...@gmail.com>
Committed: Wed Nov 6 09:31:20 2013 -0500

----------------------------------------------------------------------
 .../accumulo/server/util/TableDiskUsage.java    | 26 +++++++-------------
 1 file changed, 9 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/dcb55916/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java
----------------------------------------------------------------------
diff --git a/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java b/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java
index b7019e6..2d87a43 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/util/TableDiskUsage.java
@@ -43,12 +43,9 @@ import org.apache.accumulo.core.metadata.MetadataTable;
 import org.apache.accumulo.core.metadata.schema.MetadataSchema.TabletsSection.DataFileColumnFamily;
 import org.apache.accumulo.core.security.Authorizations;
 import org.apache.accumulo.core.util.NumUtil;
-import org.apache.accumulo.server.ServerConstants;
 import org.apache.accumulo.server.cli.ClientOpts;
 import org.apache.accumulo.server.fs.VolumeManager;
 import org.apache.accumulo.server.fs.VolumeManagerImpl;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.io.Text;
 import org.apache.log4j.Logger;
 
@@ -158,11 +155,13 @@ public class TableDiskUsage {
       mdScanner.fetchColumnFamily(DataFileColumnFamily.NAME);
       mdScanner.setRange(new KeyExtent(new Text(tableId), null, null).toMetadataRange());
       
-      if (!mdScanner.iterator().hasNext()) {
+      Iterator<Entry<Key,Value>> mdIter = mdScanner.iterator();
+      if (!mdIter.hasNext()) {
         emptyTableIds.add(tableId);
       }
       
-      for (Entry<Key,Value> entry : mdScanner) {
+      while (mdIter.hasNext()) {
+        Entry<Key,Value> entry = mdIter.next();
         String file = entry.getKey().getColumnQualifier().toString();
         String parts[] = file.split("/");
         String uniqueName = parts[parts.length - 1];
@@ -174,18 +173,11 @@ public class TableDiskUsage {
         }
         
         tdu.linkFileAndTable(tableId, uniqueName);
-      }
-    }
-    
-    for (String tableId : tablesReferenced) {
-      for (String tableDir : ServerConstants.getTablesDirs()) {
-        FileStatus[] files = fs.globStatus(new Path(tableDir + "/" + tableId + "/*/*"));
-        if (files != null) {
-          for (FileStatus fileStatus : files) {
-            // Assumes that all filenames are unique
-            String name = fileStatus.getPath().getName();
-            tdu.addFileSize(name, fileStatus.getLen());
-          }
+        String sizeKeys = entry.getValue().toString();
+        parts = sizeKeys.split(",");
+        // defensive: all file entries should have a size
+        if (parts.length == 2) {
+          tdu.addFileSize(uniqueName, Long.parseLong(parts[0]));
         }
       }
     }