Class TableUtils


  • public final class TableUtils
    extends Object
    Static utilities used in the creation and maintenance of accumulo tables.
    • 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 the AgeOffFilter for the specified time period.
        Parameters:
        store - the accumulo store
        Throws:
        StoreException - failure to create accumulo connection or add iterator settings
        org.apache.accumulo.core.client.TableExistsException - failure to create table
      • createBatchWriter

        public static org.apache.accumulo.core.client.BatchWriter createBatchWriter​(AccumuloStore store)
                                                                             throws StoreException
        Creates a BatchWriter

        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 name
        zookeepers - the zoo keepers
        userName - the user name
        password - 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 name
        zookeepers - the zoo keepers
        principal - the Kerberos principal
        keytabPath - 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 provided AccumuloProperties.
        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 - An AccumuloProperties potentially containing namespace information
        graphId - 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 graph
        currentGraphId - Current graph ID to rename from
        newGraphId - 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 the Authorizations 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