Package org.apache.accumulo.server.util
Class TableDiskUsage
- java.lang.Object
-
- org.apache.accumulo.server.util.TableDiskUsage
-
public class TableDiskUsage extends Object
This utility class will scan the Accumulo Metadata table to compute the disk usage for a table or table(s) by using the size value stored in columns that contain the column familyMetadataSchema.TabletsSection.DataFileColumnFamily
. This class will also track shared files to computed shared usage across all tables that are provided as part of the Set of tables when getting disk usage. Because the metadata table is used for computing usage and not the actual files in HDFS the results will be an estimate. Older entries may exist with no file metadata (resulting in size 0) and other actions in the cluster can impact the estimated size such as flushes, tablet splits, compactions, etc. For more accurate information a compaction should first be run on all files for the set of tables being computed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TableDiskUsage.Printer
-
Constructor Summary
Constructors Constructor Description TableDiskUsage()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static Map<SortedSet<String>,Long>
buildSharedUsageMap(TableDiskUsage tdu, ClientContext clientContext, Set<TableId> emptyTableIds)
static Map<SortedSet<String>,Long>
getDiskUsage(Set<TableId> tableIds, AccumuloClient client)
Compute the estimated disk usage for the given set of tables by scanning the Metadata table for file sizes.static void
main(String[] args)
static void
printDiskUsage(Collection<String> tableNames, AccumuloClient client, boolean humanReadable)
static void
printDiskUsage(Collection<String> tableNames, AccumuloClient client, TableDiskUsage.Printer printer, boolean humanReadable)
-
-
-
Method Detail
-
printDiskUsage
public static void printDiskUsage(Collection<String> tableNames, AccumuloClient client, boolean humanReadable) throws TableNotFoundException, IOException
- Throws:
TableNotFoundException
IOException
-
getDiskUsage
public static Map<SortedSet<String>,Long> getDiskUsage(Set<TableId> tableIds, AccumuloClient client) throws TableNotFoundException
Compute the estimated disk usage for the given set of tables by scanning the Metadata table for file sizes. Optionally computes shared usage across tables.- Parameters:
tableIds
- set of tables to compute an estimated disk usage forclient
- accumulo client used to scan- Returns:
- the computed estimated usage results
- Throws:
TableNotFoundException
- if the table(s) do not exist
-
buildSharedUsageMap
protected static Map<SortedSet<String>,Long> buildSharedUsageMap(TableDiskUsage tdu, ClientContext clientContext, Set<TableId> emptyTableIds)
-
printDiskUsage
public static void printDiskUsage(Collection<String> tableNames, AccumuloClient client, TableDiskUsage.Printer printer, boolean humanReadable) throws TableNotFoundException, IOException
- Throws:
TableNotFoundException
IOException
-
-