org.apache.accumulo.core.client.admin
Class TableOperations

java.lang.Object
  extended by org.apache.accumulo.core.client.admin.TableOperations
Direct Known Subclasses:
MockTableOperations, TableOperationsImpl

public class TableOperations
extends java.lang.Object

Provides a class for administering tables


Constructor Summary
protected TableOperations()
           
 
Method Summary
 void addAggregators(java.lang.String tableName, java.util.List<AggregatorConfiguration> aggregators)
           
 void addSplits(java.lang.String tableName, java.util.SortedSet<org.apache.hadoop.io.Text> partitionKeys)
           
 void clearLocatorCache(java.lang.String tableName)
          Clears the tablet locator cache for a specified table
 void create(java.lang.String tableName)
          Create a table with no special configuration
 void create(java.lang.String tableName, TimeType timeType)
           
 void delete(java.lang.String tableName)
          Delete a table
 boolean exists(java.lang.String tableName)
          A method to check if a table exists in Accumulo.
 void flush(java.lang.String tableName)
          Flush a table
 java.util.Map<java.lang.String,java.util.Set<org.apache.hadoop.io.Text>> getLocalityGroups(java.lang.String tableName)
          Gets the locality groups currently set for a table.
 java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>> getProperties(java.lang.String tableName)
          Gets properties of a table
 java.util.Collection<org.apache.hadoop.io.Text> getSplits(java.lang.String tableName)
           
 java.util.Collection<org.apache.hadoop.io.Text> getSplits(java.lang.String tableName, int maxSplits)
           
 BulkImportHelper.AssignmentStats importDirectory(java.lang.String tableName, java.lang.String dir, java.lang.String failureDir, int numThreads, int numAssignThreads, boolean disableGC)
           
 java.util.SortedSet<java.lang.String> list()
          Retrieve a list of tables in Accumulo.
 void offline(java.lang.String tableName)
           
 void online(java.lang.String tableName)
           
 void removeProperty(java.lang.String tableName, java.lang.String property)
          Removes a property from a table
 void rename(java.lang.String oldTableName, java.lang.String newTableName)
          Rename a table
 void setLocalityGroups(java.lang.String tableName, java.util.Map<java.lang.String,java.util.Set<org.apache.hadoop.io.Text>> groups)
          Sets a tables locality groups.
 void setProperty(java.lang.String tableName, java.lang.String property, java.lang.String value)
          Sets a property on a table
 java.util.Set<Range> splitRangeByTablets(java.lang.String tableName, Range range, int maxSplits)
           
 java.util.Map<java.lang.String,java.lang.String> tableIdMap()
          Get a mapping of table name to internal table id.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableOperations

protected TableOperations()
Method Detail

list

public java.util.SortedSet<java.lang.String> list()
Retrieve a list of tables in Accumulo.

Returns:
List of tables in accumulo

exists

public boolean exists(java.lang.String tableName)
A method to check if a table exists in Accumulo.

Parameters:
tableName - the name of the table
Returns:
true if the table exists

create

public void create(java.lang.String tableName)
            throws AccumuloException,
                   AccumuloSecurityException,
                   TableExistsException
Create a table with no special configuration

Parameters:
tableName - the name of the table
Throws:
AccumuloException - if a general error occurs
AccumuloSecurityException - if the user does not have permission
TableExistsException - if the table already exists

create

public void create(java.lang.String tableName,
                   TimeType timeType)
            throws AccumuloException,
                   AccumuloSecurityException,
                   TableExistsException
Parameters:
tableName - the name of the table
partitionKeys - a sorted set of row key values to pre-split the table on
aggregators - a list of configured aggregators to apply to the table immediately
timeType - specifies logical or real-time based time recording for entries in the table
Throws:
AccumuloException - if a general error occurs
AccumuloSecurityException - if the user does not have permission
TableExistsException - if the table already exists

addAggregators

public void addAggregators(java.lang.String tableName,
                           java.util.List<AggregatorConfiguration> aggregators)
                    throws AccumuloSecurityException,
                           TableNotFoundException,
                           AccumuloException
Parameters:
tableName - the name of the table
aggregators - List of aggregators to add
Throws:
AccumuloSecurityException - if insufficient permissions to do action
TableNotFoundException - if table does not exist
AccumuloException - if a general error occurs

addSplits

public void addSplits(java.lang.String tableName,
                      java.util.SortedSet<org.apache.hadoop.io.Text> partitionKeys)
               throws TableNotFoundException,
                      AccumuloException,
                      AccumuloSecurityException
Parameters:
tableName - the name of the table
partitionKeys - a sorted set of row key values to pre-split the table on
Throws:
AccumuloException - if a general error occurs
AccumuloSecurityException - if the user does not have permission
TableNotFoundException - if the table does not exist

getSplits

public java.util.Collection<org.apache.hadoop.io.Text> getSplits(java.lang.String tableName)
                                                          throws TableNotFoundException
Parameters:
tableName - the name of the table
Returns:
the split points (end-row names) for the table's current split profile
Throws:
TableNotFoundException - if the table does not exist

getSplits

public java.util.Collection<org.apache.hadoop.io.Text> getSplits(java.lang.String tableName,
                                                                 int maxSplits)
                                                          throws TableNotFoundException
Parameters:
tableName - the name of the table
maxSplits - specifies the maximum number of splits to return
Returns:
the split points (end-row names) for the table's current split profile, grouped into fewer splits so as not to exceed maxSplits
Throws:
TableNotFoundException

delete

public void delete(java.lang.String tableName)
            throws AccumuloException,
                   AccumuloSecurityException,
                   TableNotFoundException
Delete a table

Parameters:
tableName - the name of the table
Throws:
AccumuloException - if a general error occurs
AccumuloSecurityException - if the user does not have permission
TableNotFoundException - if the table does not exist

rename

public void rename(java.lang.String oldTableName,
                   java.lang.String newTableName)
            throws AccumuloSecurityException,
                   TableNotFoundException,
                   AccumuloException,
                   TableExistsException
Rename a table

Parameters:
oldTableName - the old table name
newTableName - the new table name
Throws:
AccumuloException - if a general error occurs
AccumuloSecurityException - if the user does not have permission
TableNotFoundException - if the old table name does not exist
TableExistsException - if the new table name already exists

flush

public void flush(java.lang.String tableName)
           throws AccumuloException,
                  AccumuloSecurityException
Flush a table

Parameters:
tableName - the name of the table
Throws:
AccumuloException - if a general error occurs
AccumuloSecurityException - if the user does not have permission

setProperty

public void setProperty(java.lang.String tableName,
                        java.lang.String property,
                        java.lang.String value)
                 throws AccumuloException,
                        AccumuloSecurityException
Sets a property on a table

Parameters:
tableName - the name of the table
property - the name of a per-table property
value - the value to set a per-table property to
Throws:
AccumuloException - if a general error occurs
AccumuloSecurityException - if the user does not have permission

removeProperty

public void removeProperty(java.lang.String tableName,
                           java.lang.String property)
                    throws AccumuloException,
                           AccumuloSecurityException
Removes a property from a table

Parameters:
tableName - the name of the table
property - the name of a per-table property
Throws:
AccumuloException - if a general error occurs
AccumuloSecurityException - if the user does not have permission

getProperties

public java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>> getProperties(java.lang.String tableName)
                                                                                         throws TableNotFoundException
Gets properties of a table

Parameters:
tableName - the name of the table
Returns:
all properties visible by this table (system and per-table properties)
Throws:
TableNotFoundException - if the table does not exist

setLocalityGroups

public void setLocalityGroups(java.lang.String tableName,
                              java.util.Map<java.lang.String,java.util.Set<org.apache.hadoop.io.Text>> groups)
                       throws AccumuloException,
                              AccumuloSecurityException,
                              TableNotFoundException
Sets a tables locality groups. A tables locality groups can be changed at any time.

Parameters:
tableName - the name of the table
groups - mapping of locality group names to column families in the locality group
Throws:
AccumuloException - if a general error occurs
AccumuloSecurityException - if the user does not have permission
TableNotFoundException - if the table does not exist

getLocalityGroups

public java.util.Map<java.lang.String,java.util.Set<org.apache.hadoop.io.Text>> getLocalityGroups(java.lang.String tableName)
                                                                                           throws AccumuloException,
                                                                                                  TableNotFoundException
Gets the locality groups currently set for a table.

Parameters:
tableName - the name of the table
Returns:
mapping of locality group names to column families in the locality group
Throws:
AccumuloException - if a general error occurs
TableNotFoundException - if the table does not exist

splitRangeByTablets

public java.util.Set<Range> splitRangeByTablets(java.lang.String tableName,
                                                Range range,
                                                int maxSplits)
                                         throws AccumuloException,
                                                AccumuloSecurityException,
                                                TableNotFoundException
Parameters:
tableName - the name of the table
range - a range to split
maxSplits - the maximum number of splits
Returns:
the range, split into smaller ranges that fall on boundaries of the table's split points as evenly as possible
Throws:
AccumuloException - if a general error occurs
AccumuloSecurityException - if the user does not have permission
TableNotFoundException - if the table does not exist

importDirectory

public BulkImportHelper.AssignmentStats importDirectory(java.lang.String tableName,
                                                        java.lang.String dir,
                                                        java.lang.String failureDir,
                                                        int numThreads,
                                                        int numAssignThreads,
                                                        boolean disableGC)
                                                 throws java.io.IOException,
                                                        AccumuloException,
                                                        AccumuloSecurityException
Parameters:
tableName - the name of the table
dir - the HDFS directory to find files for importing
failureDir - the HDFS directory to place files that failed to be imported
numThreads - the number of threads to use to process the files
numAssignThreads - the number of threads to use when assigning the files
disableGC - prevents the garbage collector from cleaning up files that were bulk imported
Returns:
the statistics for the operation
Throws:
java.io.IOException - when there is an error reading/writing to HDFS
AccumuloException - when there is a general accumulo error
AccumuloSecurityException - when the user does not have the proper permissions

offline

public void offline(java.lang.String tableName)
             throws AccumuloSecurityException,
                    AccumuloException
Parameters:
tableName - the table to take offline
Throws:
AccumuloException - when there is a general accumulo error
AccumuloSecurityException - when the user does not have the proper permissions

online

public void online(java.lang.String tableName)
            throws AccumuloSecurityException,
                   AccumuloException
Parameters:
tableName - the table to take online
Throws:
AccumuloException - when there is a general accumulo error
AccumuloSecurityException - when the user does not have the proper permissions

clearLocatorCache

public void clearLocatorCache(java.lang.String tableName)
                       throws TableNotFoundException
Clears the tablet locator cache for a specified table

Parameters:
tableName - the name of the table
Throws:
TableNotFoundException - if table does not exist

tableIdMap

public java.util.Map<java.lang.String,java.lang.String> tableIdMap()
Get a mapping of table name to internal table id.

Returns:
the map from table name to internal table id


Copyright © 2012 The Apache Software Foundation. All Rights Reserved.