Class TableOperationsImpl
- java.lang.Object
-
- org.apache.accumulo.core.clientImpl.TableOperationsHelper
-
- org.apache.accumulo.core.clientImpl.TableOperationsImpl
-
- All Implemented Interfaces:
TableOperations
public class TableOperationsImpl extends TableOperationsHelper
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.accumulo.core.client.admin.TableOperations
TableOperations.ImportDestinationArguments, TableOperations.ImportMappingOptions, TableOperations.ImportOptions
-
-
Field Summary
Fields Modifier and Type Field Description static String
COMPACTION_CANCELED_MSG
static String
PROPERTY_EXCLUDE_PREFIX
static String
TABLE_DELETED_MSG
-
Constructor Summary
Constructors Constructor Description TableOperationsImpl(ClientContext context)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description int
addConstraint(String tableName, String constraintClassName)
Add a new constraint to a table.void
addSplits(String tableName, SortedSet<org.apache.hadoop.io.Text> partitionKeys)
Ensures that tablets are split along a set of keys.void
addSummarizers(String tableName, SummarizerConfiguration... newConfigs)
Enables summary generation for this table for future compactions.void
attachIterator(String tableName, IteratorSetting setting, EnumSet<IteratorUtil.IteratorScope> scopes)
Add an iterator to a table on the given scopes.void
cancelCompaction(String tableName)
Cancels a user initiated major compaction of a table initiated withTableOperations.compact(String, Text, Text, boolean, boolean)
orTableOperations.compact(String, Text, Text, List, boolean, boolean)
.void
clearLocatorCache(String tableName)
Clears the tablet locator cache for a specified tablevoid
clearSamplerConfiguration(String tableName)
Clear all sampling configuration properties on the table.void
clone(String srcTableName, String newTableName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude)
Clone a table from an existing table.void
clone(String srcTableName, String newTableName, CloneConfiguration config)
Clone a table from an existing table.void
compact(String tableName, CompactionConfig config)
Starts a full major compaction of the tablets in the range (start, end].void
compact(String tableName, org.apache.hadoop.io.Text start, org.apache.hadoop.io.Text end, boolean flush, boolean wait)
Starts a full major compaction of the tablets in the range (start, end].void
compact(String tableName, org.apache.hadoop.io.Text start, org.apache.hadoop.io.Text end, List<IteratorSetting> iterators, boolean flush, boolean wait)
Starts a full major compaction of the tablets in the range (start, end].void
create(String tableName)
Create a table with no special configuration.void
create(String tableName, NewTableConfiguration ntc)
Create a table with specified configuration.void
delete(String tableName)
Delete a tablevoid
deleteRows(String tableName, org.apache.hadoop.io.Text start, org.apache.hadoop.io.Text end)
Delete rows between (start, end]String
doBulkFateOperation(List<ByteBuffer> args, String tableName)
boolean
exists(String tableName)
A method to check if a table exists in Accumulo.void
exportTable(String tableName, String exportDir)
Exports a table.static org.apache.hadoop.fs.Path
findExportFile(ClientContext context, Set<String> importDirs)
Search multiple directories for exportMetadata.zip, the control file used for the importable command.void
flush(String tableName)
Initiate a flush of a table's data that is in memory.void
flush(String tableName, org.apache.hadoop.io.Text start, org.apache.hadoop.io.Text end, boolean wait)
Flush a table's data that is currently in memory.Map<String,String>
getConfiguration(String tableName)
Gets properties of a table.List<DiskUsage>
getDiskUsage(Set<String> tableNames)
Gets the number of bytes being used by the files for a set of tables.static Map<String,String>
getExportedProps(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path)
Map<String,Set<org.apache.hadoop.io.Text>>
getLocalityGroups(String tableName)
Gets the locality groups currently set for a table.org.apache.hadoop.io.Text
getMaxRow(String tableName, Authorizations auths, org.apache.hadoop.io.Text startRow, boolean startInclusive, org.apache.hadoop.io.Text endRow, boolean endInclusive)
Finds the max row within a given range.SamplerConfiguration
getSamplerConfiguration(String tableName)
Reads the sampling configuration properties for a table.Map<String,String>
getTableProperties(String tableName)
Gets per-table properties of a table.TimeType
getTimeType(String tableName)
Return the TimeType for the given tableTableOperations.ImportDestinationArguments
importDirectory(String directory)
Bulk import the files in a directory into a table.void
importDirectory(String tableName, String dir, String failureDir, boolean setTime)
Deprecated.void
importTable(String tableName, Set<String> importDirs, ImportConfiguration ic)
Imports a table exported viaTableOperations.exportTable(String, String)
and then copied via hadoop distcp.boolean
isOnline(String tableName)
Check if a table is online through its current goal state only.SortedSet<String>
list()
Retrieve a list of tables in Accumulo.Collection<org.apache.hadoop.io.Text>
listSplits(String tableName)
Collection<org.apache.hadoop.io.Text>
listSplits(String tableName, int maxSplits)
This version of listSplits is called when the maxSplits options is provided.List<SummarizerConfiguration>
listSummarizers(String tableName)
Locations
locate(String tableName, Collection<Range> ranges)
Locates the tablet servers and tablets that would service a collections of ranges.void
merge(String tableName, org.apache.hadoop.io.Text start, org.apache.hadoop.io.Text end)
Merge tablets between (start, end]Map<String,String>
modifyProperties(String tableName, Consumer<Map<String,String>> mapMutator)
For a detailed overview of the behavior of this method seeInstanceOperations.modifyProperties(Consumer)
which operates on a different layer of properties but has the same behavior and better documentation.void
offline(String tableName)
Initiates taking a table offline, but does not wait for action to completevoid
offline(String tableName, boolean wait)
void
online(String tableName)
Initiates bringing a table online, but does not wait for action to completevoid
online(String tableName, boolean wait)
void
removeProperty(String tableName, String property)
Removes a property from a table.void
removeSummarizers(String tableName, Predicate<SummarizerConfiguration> predicate)
Removes summary generation for this table for the matching summarizers.void
rename(String oldTableName, String newTableName)
Rename a tablevoid
setLocalityGroups(String tableName, Map<String,Set<org.apache.hadoop.io.Text>> groups)
Sets a table's locality groups.void
setProperty(String tableName, String property, String value)
Sets a property on a table.void
setSamplerConfiguration(String tableName, SamplerConfiguration samplerConfiguration)
Set or update the sampler configuration for a table.Set<Range>
splitRangeByTablets(String tableName, Range range, int maxSplits)
SummaryRetriever
summaries(String tableName)
Entry point for retrieving summaries with optional restrictions.Map<String,String>
tableIdMap()
Get a mapping of table name to internal table id.boolean
testClassLoad(String tableName, String className, String asTypeName)
Test to see if the instance can load the given class as the given type.-
Methods inherited from class org.apache.accumulo.core.clientImpl.TableOperationsHelper
attachIterator, checkIteratorConflicts, checkIteratorConflicts, getIteratorSetting, listConstraints, listIterators, removeConstraint, removeIterator
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.accumulo.core.client.admin.TableOperations
create, create, getProperties, getSplits, getSplits, importTable
-
-
-
-
Field Detail
-
PROPERTY_EXCLUDE_PREFIX
public static final String PROPERTY_EXCLUDE_PREFIX
- See Also:
- Constant Field Values
-
COMPACTION_CANCELED_MSG
public static final String COMPACTION_CANCELED_MSG
- See Also:
- Constant Field Values
-
TABLE_DELETED_MSG
public static final String TABLE_DELETED_MSG
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
TableOperationsImpl
public TableOperationsImpl(ClientContext context)
-
-
Method Detail
-
list
public SortedSet<String> list()
Description copied from interface:TableOperations
Retrieve a list of tables in Accumulo.- Returns:
- List of tables in accumulo
-
exists
public boolean exists(String tableName)
Description copied from interface:TableOperations
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(String tableName) throws AccumuloException, AccumuloSecurityException, TableExistsException
Description copied from interface:TableOperations
Create a table with no special configuration. A safe way to ignore tables that do something like the following:try { connector.tableOperations().create("mynamespace.mytable"); } catch (TableExistsException e) { // ignore or log }
- Parameters:
tableName
- the name of the table- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionTableExistsException
- if the table already exists
-
create
public void create(String tableName, NewTableConfiguration ntc) throws AccumuloException, AccumuloSecurityException, TableExistsException
Description copied from interface:TableOperations
Create a table with specified configuration. A safe way to ignore tables that do exist would be to do something like the following:try { connector.tableOperations().create("mynamespace.mytable"); } catch (TableExistsException e) { // ignore or log }
- Parameters:
tableName
- the name of the tablentc
- specifies the new table's configuration variable, which are: 1. enable/disable the versioning iterator, which will limit the number of Key versions kept; 2. specifies logical or real-time based time recording for entries in the table; 3. user defined properties to be merged into the initial properties of the table- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionTableExistsException
- if the table already exists
-
doBulkFateOperation
public String doBulkFateOperation(List<ByteBuffer> args, String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException
-
addSplits
public void addSplits(String tableName, SortedSet<org.apache.hadoop.io.Text> partitionKeys) throws TableNotFoundException, AccumuloException, AccumuloSecurityException
Description copied from interface:TableOperations
Ensures that tablets are split along a set of keys.Note that while the documentation for Text specifies that its bytestream should be UTF-8, the encoding is not enforced by operations that work with byte arrays.
For example, you can create 256 evenly-sliced splits via the following code sample even though the given byte sequences are not valid UTF-8.
TableOperations tableOps = client.tableOperations(); TreeSet<Text> splits = new TreeSet<Text>(); for (int i = 0; i < 256; i++) { byte[] bytes = {(byte) i}; splits.add(new Text(bytes)); } tableOps.addSplits(TABLE_NAME, splits);
- Parameters:
tableName
- the name of the tablepartitionKeys
- a sorted set of row key values to pre-split the table on- Throws:
TableNotFoundException
- if the table does not existAccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permission
-
merge
public void merge(String tableName, org.apache.hadoop.io.Text start, org.apache.hadoop.io.Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException
Description copied from interface:TableOperations
Merge tablets between (start, end]- Parameters:
tableName
- the table to mergestart
- first tablet to be merged contains the row after this row, null means the first tabletend
- last tablet to be merged contains this row, null means the last tablet- Throws:
AccumuloException
AccumuloSecurityException
TableNotFoundException
-
deleteRows
public void deleteRows(String tableName, org.apache.hadoop.io.Text start, org.apache.hadoop.io.Text end) throws AccumuloException, AccumuloSecurityException, TableNotFoundException
Description copied from interface:TableOperations
Delete rows between (start, end]- Parameters:
tableName
- the table to mergestart
- delete rows after this, null means the first row of the tableend
- last row to be deleted, inclusive, null means the last row of the table- Throws:
AccumuloException
AccumuloSecurityException
TableNotFoundException
-
listSplits
public Collection<org.apache.hadoop.io.Text> listSplits(String tableName) throws TableNotFoundException, AccumuloSecurityException
- 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 existAccumuloSecurityException
- if the user does not have permission
-
listSplits
public Collection<org.apache.hadoop.io.Text> listSplits(String tableName, int maxSplits) throws TableNotFoundException, AccumuloSecurityException
This version of listSplits is called when the maxSplits options is provided. If the value of maxSplits is greater than the number of existing splits, then all splits are returned and no additional processing is performed. But, if the value of maxSplits is less than the number of existing splits, maxSplit split values are returned. These split values are "evenly" selected from the existing splits based upon the algorithm implemented in the method. A stepSize is calculated based upon the number of splits requested and the total split count. A running sum adjusted by this stepSize is calculated as each split is parsed. Once this sum exceeds a value of 1, the current split point is selected to be returned. The sum is then decremented by 1 and the process continues until all existing splits have been parsed or maxSplits splits have been selected.- Parameters:
tableName
- the name of the tablemaxSplits
- specifies the maximum number of splits to return- Returns:
- a Collection containing a subset of evenly selected splits
- Throws:
AccumuloSecurityException
- if the user does not have permissionTableNotFoundException
-
delete
public void delete(String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException
Description copied from interface:TableOperations
Delete a table- Parameters:
tableName
- the name of the table- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionTableNotFoundException
- if the table does not exist
-
clone
public void clone(String srcTableName, String newTableName, boolean flush, Map<String,String> propertiesToSet, Set<String> propertiesToExclude) throws AccumuloSecurityException, TableNotFoundException, AccumuloException, TableExistsException
Description copied from interface:TableOperations
Clone a table from an existing table. The cloned table will have the same data as the source table it was created from. After cloning, the two tables can mutate independently. Initially the cloned table should not use any extra space, however as the source table and cloned table major compact extra space will be used by the clone. Initially the cloned table is only readable and writable by the user who created it.- Parameters:
srcTableName
- the table to clonenewTableName
- the name of the cloneflush
- determines if memory is flushed in the source table before cloning.propertiesToSet
- the sources tables properties are copied, this allows overriding of those propertiespropertiesToExclude
- do not copy these properties from the source table, just revert to system defaults- Throws:
AccumuloSecurityException
TableNotFoundException
AccumuloException
TableExistsException
-
clone
public void clone(String srcTableName, String newTableName, CloneConfiguration config) throws AccumuloSecurityException, TableNotFoundException, AccumuloException, TableExistsException
Description copied from interface:TableOperations
Clone a table from an existing table. The cloned table will have the same data as the source table it was created from. After cloning, the two tables can mutate independently. Initially the cloned table should not use any extra space, however as the source table and cloned table major compact extra space will be used by the clone. Initially the cloned table is only readable and writable by the user who created it.- Parameters:
srcTableName
- the table to clonenewTableName
- the name of the cloneconfig
- the clone command configuration- Throws:
AccumuloSecurityException
TableNotFoundException
AccumuloException
TableExistsException
-
rename
public void rename(String oldTableName, String newTableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException, TableExistsException
Description copied from interface:TableOperations
Rename a table- Parameters:
oldTableName
- the old table namenewTableName
- the new table name, which must be in the same namespace as the oldTableName- Throws:
AccumuloSecurityException
- if the user does not have permissionTableNotFoundException
- if the old table name does not existAccumuloException
- if a general error occursTableExistsException
- if the new table name already exists
-
flush
public void flush(String tableName) throws AccumuloException, AccumuloSecurityException
Description copied from interface:TableOperations
Initiate a flush of a table's data that is in memory. To specify a range or to wait for flush to complete useTableOperations.flush(String, Text, Text, boolean)
.- Parameters:
tableName
- the name of the table- Throws:
AccumuloException
- if a general error occurs. Wrapped TableNotFoundException if table does not exist.AccumuloSecurityException
- if the user does not have permission
-
flush
public void flush(String tableName, org.apache.hadoop.io.Text start, org.apache.hadoop.io.Text end, boolean wait) throws AccumuloException, AccumuloSecurityException, TableNotFoundException
Description copied from interface:TableOperations
Flush a table's data that is currently in memory.- Parameters:
tableName
- the name of the tablewait
- if true the call will not return until all data present in memory when the call was is flushed if false will initiate a flush of data in memory, but will not wait for it to complete- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionTableNotFoundException
-
compact
public void compact(String tableName, org.apache.hadoop.io.Text start, org.apache.hadoop.io.Text end, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException, AccumuloException
Description copied from interface:TableOperations
Starts a full major compaction of the tablets in the range (start, end]. The compaction is preformed even for tablets that have only one file.- Parameters:
tableName
- the table to compactstart
- first tablet to be compacted contains the row after this row, null means the first tablet in tableend
- last tablet to be compacted contains this row, null means the last tablet in tableflush
- when true, table memory is flushed before compaction startswait
- when true, the call will not return until compactions are finished- Throws:
AccumuloSecurityException
TableNotFoundException
AccumuloException
-
compact
public void compact(String tableName, org.apache.hadoop.io.Text start, org.apache.hadoop.io.Text end, List<IteratorSetting> iterators, boolean flush, boolean wait) throws AccumuloSecurityException, TableNotFoundException, AccumuloException
Description copied from interface:TableOperations
Starts a full major compaction of the tablets in the range (start, end]. The compaction is preformed even for tablets that have only one file.- Parameters:
tableName
- the table to compactstart
- first tablet to be compacted contains the row after this row, null means the first tablet in tableend
- last tablet to be compacted contains this row, null means the last tablet in tableiterators
- A set of iterators that will be applied to each tablet compacted. If two or more concurrent calls to compact pass iterators, then only one will succeed and the others will fail.flush
- when true, table memory is flushed before compaction startswait
- when true, the call will not return until compactions are finished- Throws:
AccumuloSecurityException
TableNotFoundException
AccumuloException
-
compact
public void compact(String tableName, CompactionConfig config) throws AccumuloSecurityException, TableNotFoundException, AccumuloException
Description copied from interface:TableOperations
Starts a full major compaction of the tablets in the range (start, end]. If the config does not specify a compaction selector (or a deprecated strategy), then all files in a tablet are compacted. The compaction is performed even for tablets that have only one file.The following optional settings can only be set by one compact call per table at the same time.
- Execution hints :
CompactionConfig.setExecutionHints(Map)
- Selector :
CompactionConfig.setSelector(PluginConfig)
- Configurer :
CompactionConfig.setConfigurer(PluginConfig)
- Iterators :
CompactionConfig.setIterators(List)
- Compaction strategy (deprecated) :
CompactionConfig.setCompactionStrategy(CompactionStrategyConfig)
If two threads call this method concurrently for the same table and set one or more of the above then one thread will fail.
- Parameters:
tableName
- the table to compactconfig
- the configuration to use- Throws:
AccumuloSecurityException
TableNotFoundException
AccumuloException
- Execution hints :
-
cancelCompaction
public void cancelCompaction(String tableName) throws AccumuloSecurityException, TableNotFoundException, AccumuloException
Description copied from interface:TableOperations
Cancels a user initiated major compaction of a table initiated withTableOperations.compact(String, Text, Text, boolean, boolean)
orTableOperations.compact(String, Text, Text, List, boolean, boolean)
. Compactions of tablets that are currently running may finish, but new compactions of tablets will not start.- Parameters:
tableName
- the name of the table- Throws:
AccumuloSecurityException
- if the user does not have permissionTableNotFoundException
- if the table does not existAccumuloException
- if a general error occurs
-
setProperty
public void setProperty(String tableName, String property, String value) throws AccumuloException, AccumuloSecurityException
Description copied from interface:TableOperations
Sets a property on a table. This operation is asynchronous and eventually consistent. Not all tablets in a table will acknowledge this new value immediately nor at the same time. Within a few seconds without another change, all tablets in a table should see the updated value. The clone table feature can be used if consistency is required.- Parameters:
tableName
- the name of the tableproperty
- the name of a per-table propertyvalue
- the value to set a per-table property to- Throws:
AccumuloException
- if a general error occurs. Wrapped TableNotFoundException if table does not exist.AccumuloSecurityException
- if the user does not have permission
-
modifyProperties
public Map<String,String> modifyProperties(String tableName, Consumer<Map<String,String>> mapMutator) throws AccumuloException, AccumuloSecurityException, IllegalArgumentException
Description copied from interface:TableOperations
For a detailed overview of the behavior of this method seeInstanceOperations.modifyProperties(Consumer)
which operates on a different layer of properties but has the same behavior and better documentation.Accumulo has multiple layers of properties that for many APIs and SPIs are presented as a single merged view. This API does not offer that merged view, it only offers the properties set at this table's layer to the mapMutator.
mapMutator
- This consumer should modify the passed in snapshot of table properties contain the desired keys and values. It should be safe for Accumulo to call this consumer multiple times, this may be done automatically when certain retryable errors happen. The consumer should probably avoid accessing the Accumulo client as that could lead to undefined behavior.- Returns:
- The map that became Accumulo's new properties for this table. This map is immutable and contains the snapshot passed to mapMutator and the changes made by mapMutator.
- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionIllegalArgumentException
- if the Consumer alters the map by adding properties that cannot be stored
-
removeProperty
public void removeProperty(String tableName, String property) throws AccumuloException, AccumuloSecurityException
Description copied from interface:TableOperations
Removes a property from a table. This operation is asynchronous and eventually consistent. Not all tablets in a table will acknowledge this altered value immediately nor at the same time. Within a few seconds without another change, all tablets in a table should see the altered value. The clone table feature can be used if consistency is required.- Parameters:
tableName
- the name of the tableproperty
- the name of a per-table property- Throws:
AccumuloException
- if a general error occurs. Wrapped TableNotFoundException if table does not exist.AccumuloSecurityException
- if the user does not have permission
-
getConfiguration
public Map<String,String> getConfiguration(String tableName) throws AccumuloException, TableNotFoundException
Description copied from interface:TableOperations
Gets properties of a table. This operation is asynchronous and eventually consistent. It is not guaranteed that all tablets in a table will return the same values. Within a few seconds without another change, all tablets in a table should be consistent. The clone table feature can be used if consistency is required. This new method returns a Map instead of an Iterable.- Parameters:
tableName
- the name of the table- Returns:
- all properties visible by this table (system and per-table properties). Note that recently changed properties may not be visible immediately.
- Throws:
TableNotFoundException
- if the table does not existAccumuloException
-
getTableProperties
public Map<String,String> getTableProperties(String tableName) throws AccumuloException, TableNotFoundException
Description copied from interface:TableOperations
Gets per-table properties of a table. This operation is asynchronous and eventually consistent. It is not guaranteed that all tablets in a table will return the same values. Within a few seconds without another change, all tablets in a table should be consistent. The clone table feature can be used if consistency is required.- Parameters:
tableName
- the name of the table- Returns:
- per-table properties visible by this table. Note that recently changed properties may not be visible immediately.
- Throws:
TableNotFoundException
- if the table does not existAccumuloException
-
setLocalityGroups
public void setLocalityGroups(String tableName, Map<String,Set<org.apache.hadoop.io.Text>> groups) throws AccumuloException, AccumuloSecurityException, TableNotFoundException
Description copied from interface:TableOperations
Sets a table's locality groups. A table's locality groups can be changed at any time.- Parameters:
tableName
- the name of the tablegroups
- mapping of locality group names to column families in the locality group- Throws:
AccumuloException
- if a general error occursAccumuloSecurityException
- if the user does not have permissionTableNotFoundException
- if the table does not exist
-
getLocalityGroups
public Map<String,Set<org.apache.hadoop.io.Text>> getLocalityGroups(String tableName) throws AccumuloException, TableNotFoundException
Description copied from interface:TableOperations
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 occursTableNotFoundException
- if the table does not exist
-
splitRangeByTablets
public Set<Range> splitRangeByTablets(String tableName, Range range, int maxSplits) throws AccumuloException, AccumuloSecurityException, TableNotFoundException
- Parameters:
tableName
- the name of the tablerange
- a range to splitmaxSplits
- 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 occursAccumuloSecurityException
- if the user does not have permissionTableNotFoundException
- if the table does not exist
-
importDirectory
@Deprecated(since="2.0.0") public void importDirectory(String tableName, String dir, String failureDir, boolean setTime) throws IOException, AccumuloSecurityException, TableNotFoundException, AccumuloException
Deprecated.Description copied from interface:TableOperations
Bulk import all the files in a directory into a table. Files can be created usingRFile.newWriter()
- Parameters:
tableName
- the name of the tabledir
- the HDFS directory to find files for importingfailureDir
- the HDFS directory to place files that failed to be imported, must exist and be emptysetTime
- override the time values in the input files, and use the current time for all mutations- Throws:
IOException
- when there is an error reading/writing to HDFSAccumuloSecurityException
- when the user does not have the proper permissionsTableNotFoundException
- when the table no longer existsAccumuloException
- when there is a general accumulo error
-
offline
public void offline(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException
Description copied from interface:TableOperations
Initiates taking a table offline, but does not wait for action to complete- Parameters:
tableName
- the table to take offline- Throws:
AccumuloSecurityException
- when the user does not have the proper permissionsAccumuloException
- when there is a general accumulo errorTableNotFoundException
-
offline
public void offline(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException
- Parameters:
tableName
- the table to take offlinewait
- if true, then will not return until table is offline- Throws:
AccumuloSecurityException
- when the user does not have the proper permissionsAccumuloException
- when there is a general accumulo errorTableNotFoundException
-
isOnline
public boolean isOnline(String tableName) throws AccumuloException, TableNotFoundException
Description copied from interface:TableOperations
Check if a table is online through its current goal state only. Could run into issues if the current state of the table is in between states. If you require a specific state, callonline(tableName, true)
oroffline(tableName, true)
, this will wait until the table reaches the desired state before proceeding.- Parameters:
tableName
- the table to check if online- Returns:
- true if table's goal state is online
- Throws:
AccumuloException
- when there is a general accumulo errorTableNotFoundException
-
online
public void online(String tableName) throws AccumuloSecurityException, AccumuloException, TableNotFoundException
Description copied from interface:TableOperations
Initiates bringing a table online, but does not wait for action to complete- Parameters:
tableName
- the table to take online- Throws:
AccumuloSecurityException
- when the user does not have the proper permissionsAccumuloException
- when there is a general accumulo errorTableNotFoundException
-
online
public void online(String tableName, boolean wait) throws AccumuloSecurityException, AccumuloException, TableNotFoundException
- Parameters:
tableName
- the table to take onlinewait
- if true, then will not return until table is online- Throws:
AccumuloSecurityException
- when the user does not have the proper permissionsAccumuloException
- when there is a general accumulo errorTableNotFoundException
-
clearLocatorCache
public void clearLocatorCache(String tableName) throws TableNotFoundException
Description copied from interface:TableOperations
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 Map<String,String> tableIdMap()
Description copied from interface:TableOperations
Get a mapping of table name to internal table id.- Returns:
- the map from table name to internal table id
-
getMaxRow
public org.apache.hadoop.io.Text getMaxRow(String tableName, Authorizations auths, org.apache.hadoop.io.Text startRow, boolean startInclusive, org.apache.hadoop.io.Text endRow, boolean endInclusive) throws TableNotFoundException
Description copied from interface:TableOperations
Finds the max row within a given range. To find the max row in a table, pass null for start and end row.auths
- find the max row that can seen with these authsstartRow
- row to start looking at, null means -InfinitystartInclusive
- determines if the start row is includedendRow
- row to stop looking at, null means InfinityendInclusive
- determines if the end row is included- Returns:
- The max row in the range, or null if there is no visible data in the range.
- Throws:
TableNotFoundException
-
getDiskUsage
public List<DiskUsage> getDiskUsage(Set<String> tableNames) throws AccumuloException, AccumuloSecurityException, TableNotFoundException
Description copied from interface:TableOperations
Gets the number of bytes being used by the files for a set of tables. This operation will scan the metadata table for file size information to compute the size metrics for the tables. 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.- Parameters:
tableNames
- a set of tables- Returns:
- a list of disk usage objects containing linked table names and sizes set of tables to compute usage across
- Throws:
AccumuloException
AccumuloSecurityException
TableNotFoundException
-
findExportFile
public static org.apache.hadoop.fs.Path findExportFile(ClientContext context, Set<String> importDirs) throws AccumuloException
Search multiple directories for exportMetadata.zip, the control file used for the importable command.- Parameters:
context
- used to obtain filesystem based on configurationimportDirs
- the set of directories to search.- Returns:
- the Path representing the location of the file.
- Throws:
AccumuloException
- if zero or more than one copy of the exportMetadata.zip file are found in the directories provided.
-
getExportedProps
public static Map<String,String> getExportedProps(org.apache.hadoop.fs.FileSystem fs, org.apache.hadoop.fs.Path path) throws IOException
- Throws:
IOException
-
importTable
public void importTable(String tableName, Set<String> importDirs, ImportConfiguration ic) throws TableExistsException, AccumuloException, AccumuloSecurityException
Description copied from interface:TableOperations
Imports a table exported viaTableOperations.exportTable(String, String)
and then copied via hadoop distcp.- Parameters:
tableName
- Name of a table to create and import into.importDirs
- A set of directories containing the files copied by distcp from exportTableic
- ImportConfiguration for the table being created. If no configuration is needed passImportConfiguration.empty()
- Throws:
TableExistsException
AccumuloException
AccumuloSecurityException
-
exportTable
public void exportTable(String tableName, String exportDir) throws TableNotFoundException, AccumuloException, AccumuloSecurityException
Description copied from interface:TableOperations
Exports a table. The tables data is not exported, just table metadata and a list of files to distcp. The table being exported must be offline and stay offline for the duration of distcp. To avoid losing access to a table it can be cloned and the clone taken offline for export.See the export example
- Parameters:
tableName
- Name of the table to export.exportDir
- An empty directory in HDFS where files containing table metadata and list of files to distcp will be placed.- Throws:
TableNotFoundException
AccumuloException
AccumuloSecurityException
-
testClassLoad
public boolean testClassLoad(String tableName, String className, String asTypeName) throws TableNotFoundException, AccumuloException, AccumuloSecurityException
Description copied from interface:TableOperations
Test to see if the instance can load the given class as the given type. This check uses the table classpath if it is set.- Returns:
- true if the instance can load the given class as the given type, false otherwise
- Throws:
TableNotFoundException
AccumuloException
AccumuloSecurityException
-
attachIterator
public void attachIterator(String tableName, IteratorSetting setting, EnumSet<IteratorUtil.IteratorScope> scopes) throws AccumuloSecurityException, AccumuloException, TableNotFoundException
Description copied from interface:TableOperations
Add an iterator to a table on the given scopes.- Specified by:
attachIterator
in interfaceTableOperations
- Overrides:
attachIterator
in classTableOperationsHelper
- Parameters:
tableName
- the name of the tablesetting
- object specifying the properties of the iterator- Throws:
AccumuloSecurityException
- thrown if the user does not have the ability to set properties on the tableTableNotFoundException
- throw if the table no longer existsAccumuloException
-
addConstraint
public int addConstraint(String tableName, String constraintClassName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException
Description copied from interface:TableOperations
Add a new constraint to a table.- Specified by:
addConstraint
in interfaceTableOperations
- Overrides:
addConstraint
in classTableOperationsHelper
- Parameters:
tableName
- the name of the tableconstraintClassName
- the full name of the constraint class- Returns:
- the unique number assigned to the constraint
- Throws:
AccumuloException
- thrown if the constraint has already been added to the table or if there are errors in the configuration of existing constraintsAccumuloSecurityException
- thrown if the user doesn't have permission to add the constraintTableNotFoundException
-
setSamplerConfiguration
public void setSamplerConfiguration(String tableName, SamplerConfiguration samplerConfiguration) throws AccumuloException, TableNotFoundException, AccumuloSecurityException
Description copied from interface:TableOperations
Set or update the sampler configuration for a table. If the table has existing sampler configuration, those properties will be cleared before setting the new table properties.- Parameters:
tableName
- the name of the table- Throws:
AccumuloException
TableNotFoundException
AccumuloSecurityException
-
clearSamplerConfiguration
public void clearSamplerConfiguration(String tableName) throws AccumuloException, TableNotFoundException, AccumuloSecurityException
Description copied from interface:TableOperations
Clear all sampling configuration properties on the table.- Parameters:
tableName
- the name of the table- Throws:
AccumuloException
TableNotFoundException
AccumuloSecurityException
-
getSamplerConfiguration
public SamplerConfiguration getSamplerConfiguration(String tableName) throws TableNotFoundException, AccumuloSecurityException, AccumuloException
Description copied from interface:TableOperations
Reads the sampling configuration properties for a table.- Parameters:
tableName
- the name of the table- Throws:
TableNotFoundException
AccumuloSecurityException
AccumuloException
-
locate
public Locations locate(String tableName, Collection<Range> ranges) throws AccumuloException, AccumuloSecurityException, TableNotFoundException
Description copied from interface:TableOperations
Locates the tablet servers and tablets that would service a collections of ranges. If a range covers multiple tablets, it will occur multiple times in the returned map.ranges
- The input ranges that should be mapped to tablet servers and tablets.- Throws:
AccumuloException
AccumuloSecurityException
TableNotFoundException
-
summaries
public SummaryRetriever summaries(String tableName)
Description copied from interface:TableOperations
Entry point for retrieving summaries with optional restrictions.In order to retrieve Summaries, the Accumulo user making the request will need the
TablePermission.GET_SUMMARIES
table permission.Accumulo stores summary data with each file in each tablet. In order to make retrieving it faster there is a per tablet server cache of summary data. When summary data for a file is not present, it will be retrieved using threads on the tserver. The tablet server properties
tserver.summary.partition.threads
,tserver.summary.remote.threads
,tserver.summary.retrieval.threads
, andtserver.cache.summary.size
impact the performance of retrieving summaries.Since summary data is cached, its important to use the summary selection options to only read the needed data into the cache.
Summary data will be merged on the tablet servers and then in this client process. Therefore it's important that the required summarizers are on the clients classpath.
- See Also:
Summarizer
-
addSummarizers
public void addSummarizers(String tableName, SummarizerConfiguration... newConfigs) throws AccumuloException, AccumuloSecurityException, TableNotFoundException
Description copied from interface:TableOperations
Enables summary generation for this table for future compactions.- Parameters:
tableName
- add summarizers to this tablenewConfigs
- summarizers to add- Throws:
AccumuloException
AccumuloSecurityException
TableNotFoundException
- See Also:
SummarizerConfiguration.toTableProperties()
,SummarizerConfiguration.toTableProperties(SummarizerConfiguration...)
,SummarizerConfiguration.toTableProperties(Collection)
-
removeSummarizers
public void removeSummarizers(String tableName, Predicate<SummarizerConfiguration> predicate) throws AccumuloException, TableNotFoundException, AccumuloSecurityException
Description copied from interface:TableOperations
Removes summary generation for this table for the matching summarizers.- Parameters:
tableName
- remove summarizers from this tablepredicate
- removes all summarizers whose configuration that matches this predicate- Throws:
AccumuloException
TableNotFoundException
AccumuloSecurityException
-
listSummarizers
public List<SummarizerConfiguration> listSummarizers(String tableName) throws AccumuloException, TableNotFoundException
- Parameters:
tableName
- list summarizers for this table- Returns:
- the summarizers currently configured for the table
- Throws:
AccumuloException
TableNotFoundException
- See Also:
SummarizerConfiguration.fromTableProperties(Map)
-
importDirectory
public TableOperations.ImportDestinationArguments importDirectory(String directory)
Description copied from interface:TableOperations
Bulk import the files in a directory into a table. Files can be created usingRFile.newWriter()
.This new method of bulk import examines files in the current process outside of holding a table lock. The old bulk import method (
TableOperations.importDirectory(String, String, String, boolean)
) examines files on the server side while holding a table read lock.This API supports adding files to online and offline tables.
For example, to bulk import files from the directory 'dir1' into the table 'table1' use the following code.
client.tableOperations().importDirectory("dir1").to("table1").load();
-
getTimeType
public TimeType getTimeType(String tableName) throws TableNotFoundException
Description copied from interface:TableOperations
Return the TimeType for the given table- Parameters:
tableName
- The name of table to query- Returns:
- the TimeType of the supplied table, representing either Logical or Milliseconds
- Throws:
TableNotFoundException
-
-