accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1477758 [3/6] - in /accumulo/trunk: core/src/main/java/org/apache/accumulo/core/client/admin/ core/src/main/java/org/apache/accumulo/core/client/mock/ core/src/main/java/org/apache/accumulo/core/tabletserver/thrift/ core/src/main/java/org/...
Date Tue, 30 Apr 2013 18:33:09 GMT
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=1477758&r1=1477757&r2=1477758&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 Tue
Apr 30 18:33:06 2013
@@ -117,7 +117,7 @@ public class TableDiskUsage {
   }
   
   public static void printDiskUsage(AccumuloConfiguration acuConf, Collection<String>
tables, FileSystem fs, Connector conn) throws TableNotFoundException,
-  IOException {
+      IOException {
     printDiskUsage(acuConf, tables, fs, conn, new Printer() {
       @Override
       public void print(String line) {
@@ -125,9 +125,9 @@ public class TableDiskUsage {
       }
     });
   }
-  public static void printDiskUsage(AccumuloConfiguration acuConf, Collection<String>
tables, FileSystem fs, Connector conn, Printer printer) throws TableNotFoundException,
-  IOException {
   
+  public static Map<TreeSet<String>,Long> getDiskUsage(AccumuloConfiguration
acuConf, Collection<String> tables, FileSystem fs, Connector conn)
+      throws TableNotFoundException, IOException {
     TableDiskUsage tdu = new TableDiskUsage();
     
     HashSet<String> tableIds = new HashSet<String>();
@@ -151,7 +151,7 @@ public class TableDiskUsage {
       mdScanner.fetchColumnFamily(Constants.METADATA_DATAFILE_COLUMN_FAMILY);
       mdScanner.setRange(new KeyExtent(new Text(tableId), null, null).toMetadataRange());
       
-      if(!mdScanner.iterator().hasNext()) {
+      if (!mdScanner.iterator().hasNext()) {
         emptyTableIds.add(tableId);
       }
       
@@ -220,8 +220,8 @@ public class TableDiskUsage {
       
       usage.put(tableNames, entry.getValue());
     }
-
-    if(!emptyTableIds.isEmpty()) {
+    
+    if (!emptyTableIds.isEmpty()) {
       TreeSet<String> emptyTables = new TreeSet<String>();
       for (String tableId : emptyTableIds) {
         emptyTables.add(reverseTableIdMap.get(tableId));
@@ -229,9 +229,15 @@ public class TableDiskUsage {
       usage.put(emptyTables, 0L);
     }
     
+    return usage;
+  }
+  
+  public static void printDiskUsage(AccumuloConfiguration acuConf, Collection<String>
tables, FileSystem fs, Connector conn, Printer printer)
+      throws TableNotFoundException, IOException {
+    
+    Map<TreeSet<String>,Long> usage = getDiskUsage(acuConf, tables, fs, conn);
+    
     for (Entry<TreeSet<String>,Long> entry : usage.entrySet())
       printer.print(String.format("%,24d %s", entry.getValue(), entry.getKey()));
-    
   }
-  
 }

Modified: accumulo/trunk/core/src/main/thrift/tabletserver.thrift
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/main/thrift/tabletserver.thrift?rev=1477758&r1=1477757&r2=1477758&view=diff
==============================================================================
--- accumulo/trunk/core/src/main/thrift/tabletserver.thrift (original)
+++ accumulo/trunk/core/src/main/thrift/tabletserver.thrift Tue Apr 30 18:33:06 2013
@@ -87,6 +87,11 @@ struct ActiveScan {
     13:list<binary> authorizations
 }
 
+struct DiskUsage {
+    1:list<string> tables
+    2:i64 usage
+}
+
 enum CompactionType {
    MINOR,
    MERGE,
@@ -187,6 +192,7 @@ service TabletClientService extends clie
   
   list<ActiveScan> getActiveScans(2:trace.TInfo tinfo, 1:security.TCredentials credentials)
throws (1:client.ThriftSecurityException sec)
   list<ActiveCompaction> getActiveCompactions(2:trace.TInfo tinfo, 1:security.TCredentials
credentials) throws (1:client.ThriftSecurityException sec)
+  list<DiskUsage> getDiskUsage(2:set<string> tables, 1:security.TCredentials
credentials) throws (1:client.ThriftSecurityException sec, 2:client.ThriftTableOperationException
toe)
   oneway void removeLogs(1:trace.TInfo tinfo, 2:security.TCredentials credentials, 3:list<string>
filenames)
 }
 

Modified: accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java?rev=1477758&r1=1477757&r2=1477758&view=diff
==============================================================================
--- accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
(original)
+++ accumulo/trunk/core/src/test/java/org/apache/accumulo/core/client/admin/TableOperationsHelperTest.java
Tue Apr 30 18:33:06 2013
@@ -184,7 +184,12 @@ public class TableOperationsHelperTest {
     public Map<String,String> tableIdMap() {
       return null;
     }
-    
+
+    @Override
+    public List<DiskUsage> getDiskUsage(Set<String> tables) throws AccumuloException,
AccumuloSecurityException, TableNotFoundException {
+      return null;
+    }
+
     void check(String tablename, String[] values) {
       Map<String,String> expected = new TreeMap<String,String>();
       for (String value : values) {

Modified: accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java
URL: http://svn.apache.org/viewvc/accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java?rev=1477758&r1=1477757&r2=1477758&view=diff
==============================================================================
--- accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java (original)
+++ accumulo/trunk/proxy/src/main/java/org/apache/accumulo/proxy/ProxyServer.java Tue Apr
30 18:33:06 2013
@@ -76,6 +76,7 @@ import org.apache.accumulo.proxy.thrift.
 import org.apache.accumulo.proxy.thrift.ColumnUpdate;
 import org.apache.accumulo.proxy.thrift.CompactionReason;
 import org.apache.accumulo.proxy.thrift.CompactionType;
+import org.apache.accumulo.proxy.thrift.DiskUsage;
 import org.apache.accumulo.proxy.thrift.KeyValue;
 import org.apache.accumulo.proxy.thrift.KeyValueAndPeek;
 import org.apache.accumulo.proxy.thrift.NoMoreEntriesException;
@@ -305,7 +306,7 @@ public class ProxyServer implements Accu
       org.apache.accumulo.proxy.thrift.AccumuloException, TException {
     try {
       getConnector(login).tableOperations().compact(tableName, ByteBufferUtil.toText(startRow),
ByteBufferUtil.toText(endRow), getIteratorSettings(iterators),
-          flush, wait);
+              flush, wait);
     } catch (Exception e) {
       handleExceptionTNF(e);
     }
@@ -581,6 +582,25 @@ public class ProxyServer implements Accu
       throw new TException(e);
     }
   }
+
+  @Override
+  public List<DiskUsage> getDiskUsage(ByteBuffer login, Set<String> tables) throws
org.apache.accumulo.proxy.thrift.AccumuloException,
+          org.apache.accumulo.proxy.thrift.AccumuloSecurityException, org.apache.accumulo.proxy.thrift.TableNotFoundException,
TException {
+    try {
+      List<org.apache.accumulo.core.client.admin.DiskUsage> diskUsages = getConnector(login).tableOperations().getDiskUsage(tables);
+      List<DiskUsage> retUsages = new ArrayList<DiskUsage>();
+      for(org.apache.accumulo.core.client.admin.DiskUsage diskUsage : diskUsages) {
+        DiskUsage usage = new DiskUsage();
+        usage.setTables(new ArrayList<String>(diskUsage.getTables()));
+        usage.setUsage(diskUsage.getUsage());
+        retUsages.add(usage);
+      }
+      return retUsages;
+    } catch(Exception e) {
+      handleExceptionTNF(e);
+      return null;
+    }
+  }
   
   @Override
   public Map<String,String> getSiteConfiguration(ByteBuffer login) throws org.apache.accumulo.proxy.thrift.AccumuloException,



Mime
View raw message