Interface AccumuloClient

All Superinterfaces:
AutoCloseable

public interface AccumuloClient extends AutoCloseable
Client connection to an Accumulo instance. Allows the user to request a scanner, deleter or writer for the instance as well as various objects that permit administrative operations. Enforces security on the client side by requiring user credentials.

Supports fluent API for creation. Various options can be provided to Accumulo.newClient() and when finished a call to build() will return the AccumuloClient object. For example:

 
 try (AccumuloClient client = Accumulo.newClient()
        .to(instanceName, zookeepers)
        .as(user, password).build())
 {
   // use the client
 }
 
 

If migrating code from Connector to AccumuloClient an important difference to consider is that AccumuloClient is closable and Connector is not. Connector uses static resources and therefore creating them is cheap. AccumuloClient attempts to clean up resources on close, so constantly creating them could perform worse than Connector. Therefore, it would be better to create an AccumuloClient and pass it around.

AccumuloClient objects are intended to be thread-safe, and can be used by multiple threads. However, care should be taken to ensure that the client is eventually closed, to clean up any resources in use in the client application when all threads are finished with the AccumuloClient object. Additionally, while the client itself is thread-safe, it is not necessarily true that all objects produced from the client (such as Scanners) are thread-safe.

Since:
2.0.0
See Also:
  • Method Details

    • createBatchScanner

      BatchScanner createBatchScanner(String tableName, Authorizations authorizations, int numQueryThreads) throws TableNotFoundException
      Factory method to create a BatchScanner connected to Accumulo.
      Parameters:
      tableName - the name of the table to query
      authorizations - A set of authorization labels that will be checked against the column visibility of each key in order to filter data. The authorizations passed in must be a subset of the accumulo user's set of authorizations. If the accumulo user has authorizations (A1, A2) and authorizations (A2, A3) are passed, then an exception will be thrown.
      numQueryThreads - the number of concurrent threads to spawn for querying
      Returns:
      BatchScanner object for configuring and querying
      Throws:
      TableNotFoundException - when the specified table doesn't exist
    • createBatchScanner

      BatchScanner createBatchScanner(String tableName, Authorizations authorizations) throws TableNotFoundException
      Factory method to create a BatchScanner connected to Accumulo. This method uses the number of query threads configured when AccumuloClient was created. If none were configured, defaults will be used.
      Parameters:
      tableName - the name of the table to query
      authorizations - A set of authorization labels that will be checked against the column visibility of each key in order to filter data. The authorizations passed in must be a subset of the accumulo user's set of authorizations. If the accumulo user has authorizations (A1, A2) and authorizations (A2, A3) are passed, then an exception will be thrown.
      Returns:
      BatchScanner object for configuring and querying
      Throws:
      TableNotFoundException - when the specified table doesn't exist
    • createBatchScanner

      Factory method to create a BatchScanner with all of user's authorizations and the number of query threads configured when AccumuloClient was created. If no query threads were configured, defaults will be used.
      Parameters:
      tableName - the name of the table to query
      Returns:
      BatchScanner object for configuring and querying
      Throws:
      TableNotFoundException - when the specified table doesn't exist
      AccumuloSecurityException
      AccumuloException
    • createBatchDeleter

      BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads, BatchWriterConfig config) throws TableNotFoundException
      Factory method to create BatchDeleter
      Parameters:
      tableName - the name of the table to query and delete from
      authorizations - A set of authorization labels that will be checked against the column visibility of each key in order to filter data. The authorizations passed in must be a subset of the accumulo user's set of authorizations. If the accumulo user has authorizations (A1, A2) and authorizations (A2, A3) are passed, then an exception will be thrown.
      numQueryThreads - the number of concurrent threads to spawn for querying
      config - configuration used to create batch writer. This config takes precedence. Any unset values will be merged with config set when the AccumuloClient was created. If no config was set during AccumuloClient creation, BatchWriterConfig defaults will be used.
      Returns:
      BatchDeleter object for configuring and deleting
      Throws:
      TableNotFoundException
    • createBatchDeleter

      BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads) throws TableNotFoundException
      Factory method to create BatchDeleter. This method uses BatchWriterConfig set when AccumuloClient was created. If none was set, BatchWriterConfig defaults will be used.
      Parameters:
      tableName - the name of the table to query and delete from
      authorizations - A set of authorization labels that will be checked against the column visibility of each key in order to filter data. The authorizations passed in must be a subset of the accumulo user's set of authorizations. If the accumulo user has authorizations (A1, A2) and authorizations (A2, A3) are passed, then an exception will be thrown.
      numQueryThreads - the number of concurrent threads to spawn for querying
      Returns:
      BatchDeleter object
      Throws:
      TableNotFoundException - if table not found
    • createBatchWriter

      BatchWriter createBatchWriter(String tableName, BatchWriterConfig config) throws TableNotFoundException
      Factory method to create a BatchWriter connected to Accumulo.
      Parameters:
      tableName - the name of the table to insert data into
      config - configuration used to create batch writer. This config will take precedence. Any unset values will be merged with the config set when the AccumuloClient was created. If no config was set during AccumuloClient creation, BatchWriterConfig defaults will be used.
      Returns:
      BatchWriter object for configuring and writing data to
      Throws:
      TableNotFoundException
    • createBatchWriter

      BatchWriter createBatchWriter(String tableName) throws TableNotFoundException
      Factory method to create a BatchWriter. This method uses BatchWriterConfig set when AccumuloClient was created. If none was set, BatchWriterConfig defaults will be used.
      Parameters:
      tableName - the name of the table to insert data into
      Returns:
      BatchWriter object
      Throws:
      TableNotFoundException - if table not found
    • createMultiTableBatchWriter

      MultiTableBatchWriter createMultiTableBatchWriter(BatchWriterConfig config)
      Factory method to create a Multi-Table BatchWriter connected to Accumulo. Multi-table batch writers can queue data for multiple tables. Also data for multiple tables can be sent to a server in a single batch. It's an efficient way to ingest data into multiple tables from a single process.
      Parameters:
      config - configuration used to create multi-table batch writer. This config will take precedence. Any unset values will be merged with the config set when the AccumuloClient was created. If no config was set during AccumuloClient creation, BatchWriterConfig defaults will be used.
      Returns:
      MultiTableBatchWriter object for configuring and writing data to
    • createMultiTableBatchWriter

      MultiTableBatchWriter createMultiTableBatchWriter()
      Factory method to create a Multi-Table BatchWriter. This method uses BatchWriterConfig set when AccumuloClient was created. If none was set, BatchWriterConfig defaults will be used.
      Returns:
      MultiTableBatchWriter object
    • createScanner

      Scanner createScanner(String tableName, Authorizations authorizations) throws TableNotFoundException
      Factory method to create a Scanner connected to Accumulo.
      Parameters:
      tableName - the name of the table to query data from
      authorizations - A set of authorization labels that will be checked against the column visibility of each key in order to filter data. The authorizations passed in must be a subset of the accumulo user's set of authorizations. If the accumulo user has authorizations (A1, A2) and authorizations (A2, A3) are passed, then an exception will be thrown.
      Returns:
      Scanner object for configuring and querying data with
      Throws:
      TableNotFoundException - when the specified table doesn't exist
      See Also:
    • createScanner

      Factory method to create a Scanner with all of the user's authorizations.
      Parameters:
      tableName - the name of the table to query data from
      Returns:
      Scanner object for configuring and querying data with
      Throws:
      TableNotFoundException - when the specified table doesn't exist
      AccumuloSecurityException
      AccumuloException
      See Also:
    • createConditionalWriter

      ConditionalWriter createConditionalWriter(String tableName, ConditionalWriterConfig config) throws TableNotFoundException
      Factory method to create a ConditionalWriter connected to Accumulo.
      Parameters:
      tableName - the name of the table to query data from
      config - configuration used to create conditional writer
      Returns:
      ConditionalWriter object for writing ConditionalMutations
      Throws:
      TableNotFoundException - when the specified table doesn't exist
    • createConditionalWriter

      ConditionalWriter createConditionalWriter(String tableName) throws TableNotFoundException
      Factory method to create a ConditionalWriter connected to Accumulo.
      Parameters:
      tableName - the name of the table to query data from
      Returns:
      ConditionalWriter object for writing ConditionalMutations
      Throws:
      TableNotFoundException - when the specified table doesn't exist
      Since:
      2.1.0
    • whoami

      String whoami()
      Get the current user for this AccumuloClient
      Returns:
      the user name
    • tableOperations

      TableOperations tableOperations()
      Retrieves a TableOperations object to perform table functions, such as create and delete.
      Returns:
      an object to manipulate tables
    • namespaceOperations

      NamespaceOperations namespaceOperations()
      Retrieves a NamespaceOperations object to perform namespace functions, such as create and delete.
      Returns:
      an object to manipulate namespaces
    • securityOperations

      SecurityOperations securityOperations()
      Retrieves a SecurityOperations object to perform user security operations, such as creating users.
      Returns:
      an object to modify users and permissions
    • instanceOperations

      InstanceOperations instanceOperations()
      Retrieves an InstanceOperations object to modify instance configuration.
      Returns:
      an object to modify instance configuration
    • replicationOperations

      @Deprecated(since="2.1.0") ReplicationOperations replicationOperations()
      Deprecated.
      Retrieves a ReplicationOperations object to manage replication configuration.
      Returns:
      an object to modify replication configuration
    • properties

      Properties properties()
      Returns:
      All Properties used to create client except 'auth.token'
    • close

      void close()
      Cleans up any resources created by an AccumuloClient like threads and sockets. Anything created from this client will likely not work after calling this method. For example a Scanner created using this client will likely fail after close is called.
      Specified by:
      close in interface AutoCloseable