Class TableUtils
- java.lang.Object
-
- uk.gov.gchq.gaffer.accumulostore.utils.TableUtils
-
public final class TableUtils extends Object
Static utilities used in the creation and maintenance of accumulo tables.
-
-
Field Summary
Fields Modifier and Type Field Description static String
COLUMN_FAMILIES_OPTION
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.apache.accumulo.core.client.BatchWriter
createBatchWriter(AccumuloStore store)
Creates aBatchWriter
static void
createTable(AccumuloStore store)
Creates a table for Gaffer data and enables the correct Bloom filter; removes the versioning iterator and adds an aggregator Iterator theAgeOffFilter
for the specified time period.static void
ensureTableExists(AccumuloStore store)
Ensures that the table exists, otherwise it creates it and sets it up to receive Gaffer datastatic org.apache.accumulo.core.client.Connector
getConnector(String instanceName, String zookeepers, String userName, String password)
Creates a connection (using password-based authentication) to an accumulo instance using the provided parametersstatic org.apache.accumulo.core.client.Connector
getConnector(AccumuloProperties accumuloProperties)
Creates a connection to an accumulo instance using parameters from the providedAccumuloProperties
.static org.apache.accumulo.core.client.Connector
getConnectorKerberos(String instanceName, String zookeepers, String principal, String keytabPath)
Creates a connection (using Kerberos authentication) to an accumulo instance using the provided parametersstatic org.apache.accumulo.core.security.Authorizations
getCurrentAuthorizations(org.apache.accumulo.core.client.Connector connection)
Returns theAuthorizations
of the current userstatic String
getTableName(AccumuloProperties accumuloProperties, String graphId)
Gets the name of an Accumulo tablestatic void
renameTable(AccumuloProperties accumuloProperties, String currentGraphId, String newGraphId)
Renames the Accumulo table (if it exists) that is associated with the provided parameters.static void
setLocalityGroups(AccumuloStore store)
-
-
-
Field Detail
-
COLUMN_FAMILIES_OPTION
public static final String COLUMN_FAMILIES_OPTION
- See Also:
- Constant Field Values
-
-
Method Detail
-
ensureTableExists
public static void ensureTableExists(AccumuloStore store) throws StoreException
Ensures that the table exists, otherwise it creates it and sets it up to receive Gaffer data- Parameters:
store
- the accumulo store- Throws:
StoreException
- if a connection to accumulo could not be created or there is a failure to create a table/iterator
-
createTable
public static void createTable(AccumuloStore store) throws StoreException, org.apache.accumulo.core.client.TableExistsException
Creates a table for Gaffer data and enables the correct Bloom filter; removes the versioning iterator and adds an aggregator Iterator theAgeOffFilter
for the specified time period.- Parameters:
store
- the accumulo store- Throws:
StoreException
- failure to create accumulo connection or add iterator settingsorg.apache.accumulo.core.client.TableExistsException
- failure to create table
-
setLocalityGroups
public static void setLocalityGroups(AccumuloStore store) throws StoreException
- Throws:
StoreException
-
createBatchWriter
public static org.apache.accumulo.core.client.BatchWriter createBatchWriter(AccumuloStore store) throws StoreException
Creates aBatchWriter
- Parameters:
store
- the accumulo store- Returns:
- A new BatchWriter with the settings defined in the gaffer.accumulostore properties
- Throws:
StoreException
- if the table could not be found or other table issues
-
getConnector
public static org.apache.accumulo.core.client.Connector getConnector(String instanceName, String zookeepers, String userName, String password) throws StoreException
Creates a connection (using password-based authentication) to an accumulo instance using the provided parameters- Parameters:
instanceName
- the instance namezookeepers
- the zoo keepersuserName
- the user namepassword
- the password- Returns:
- A connection to an accumulo instance
- Throws:
StoreException
- failure to create an accumulo connection
-
getConnectorKerberos
public static org.apache.accumulo.core.client.Connector getConnectorKerberos(String instanceName, String zookeepers, String principal, String keytabPath) throws StoreException
Creates a connection (using Kerberos authentication) to an accumulo instance using the provided parameters- Parameters:
instanceName
- the instance namezookeepers
- the zoo keepersprincipal
- the Kerberos principalkeytabPath
- the path to the Kerberos keytab- Returns:
- A connection to an accumulo instance
- Throws:
StoreException
- failure to create an accumulo connection
-
getConnector
public static org.apache.accumulo.core.client.Connector getConnector(AccumuloProperties accumuloProperties) throws StoreException
Creates a connection to an accumulo instance using parameters from the providedAccumuloProperties
.- Parameters:
accumuloProperties
- the configuration properties- Returns:
- A connection to an accumulo instance
- Throws:
StoreException
- failure to create an accumulo connection
-
getTableName
public static String getTableName(AccumuloProperties accumuloProperties, String graphId)
Gets the name of an Accumulo table- Parameters:
accumuloProperties
- AnAccumuloProperties
potentially containing namespace informationgraphId
- Graph ID- Returns:
- Accumulo Table Name derived from the parameters
-
renameTable
public static void renameTable(AccumuloProperties accumuloProperties, String currentGraphId, String newGraphId) throws StoreException
Renames the Accumulo table (if it exists) that is associated with the provided parameters.This will not modify any table namespace component of an Accumulo table name.
- Parameters:
accumuloProperties
-AccumuloProperties
for the graphcurrentGraphId
- Current graph ID to rename fromnewGraphId
- New graph ID to rename to- Throws:
StoreException
- failure to rename Accumulo table
-
getCurrentAuthorizations
public static org.apache.accumulo.core.security.Authorizations getCurrentAuthorizations(org.apache.accumulo.core.client.Connector connection) throws StoreException
Returns theAuthorizations
of the current user- Parameters:
connection
- the connection to an accumulo instance- Returns:
- The accumulo Authorisations of the current user specified in the properties file
- Throws:
StoreException
- if the table could not be found or other table/security issues
-
-