Interface AccumuloClient
- All Superinterfaces:
AutoCloseable
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
}
An important difference with the legacy Connector to consider is that Connector reused global static resources. AccumuloClient, however, attempts to clean up its resources on close. So, creating many AccumuloClient objects will perform worse than creating many Connectors did. Therefore, it is suggested to reuse AccumuloClient instances where possible, rather than create many of them.
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:
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Builder methods for authenticationstatic interface
Builds AccumuloClient or client Properties after all options have been specifiedstatic interface
Build methods for connection optionsstatic interface
static interface
Builder method for setting Accumulo instance and zookeepersstatic interface
Builder methods for creating AccumuloClient using propertiesstatic interface
Build methods for SASLstatic interface
Build methods for SSL/TLS -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Cleans up any resources created by an AccumuloClient like threads and sockets.createBatchDeleter
(String tableName, Authorizations authorizations, int numQueryThreads) Factory method to create BatchDeleter.createBatchDeleter
(String tableName, Authorizations authorizations, int numQueryThreads, BatchWriterConfig config) Factory method to create BatchDeletercreateBatchScanner
(String tableName) Factory method to create a BatchScanner with all of user's authorizations and the number of query threads configured when AccumuloClient was created.createBatchScanner
(String tableName, Authorizations authorizations) Factory method to create a BatchScanner connected to Accumulo.createBatchScanner
(String tableName, Authorizations authorizations, int numQueryThreads) Factory method to create a BatchScanner connected to Accumulo.createBatchWriter
(String tableName) Factory method to create a BatchWriter.createBatchWriter
(String tableName, BatchWriterConfig config) Factory method to create a BatchWriter connected to Accumulo.createConditionalWriter
(String tableName) Factory method to create a ConditionalWriter connected to Accumulo.createConditionalWriter
(String tableName, ConditionalWriterConfig config) Factory method to create a ConditionalWriter connected to Accumulo.Factory method to create a Multi-Table BatchWriter.Factory method to create a Multi-Table BatchWriter connected to Accumulo.createScanner
(String tableName) Factory method to create a Scanner with all of the user's authorizations.createScanner
(String tableName, Authorizations authorizations) Factory method to create a Scanner connected to Accumulo.Retrieves an InstanceOperations object to modify instance configuration.Retrieves a NamespaceOperations object to perform namespace functions, such as create and delete.Retrieves a SecurityOperations object to perform user security operations, such as creating users.Retrieves a TableOperations object to perform table functions, such as create and delete.whoami()
Get the current user for this AccumuloClient
-
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 queryauthorizations
- 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 queryauthorizations
- 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
BatchScanner createBatchScanner(String tableName) throws TableNotFoundException, AccumuloSecurityException, AccumuloException 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 existAccumuloSecurityException
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 fromauthorizations
- 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 queryingconfig
- 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 fromauthorizations
- 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 intoconfig
- 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
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
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 fromauthorizations
- 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
Scanner createScanner(String tableName) throws TableNotFoundException, AccumuloSecurityException, AccumuloException 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 existAccumuloSecurityException
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 fromconfig
- configuration used to create conditional writer- Returns:
- ConditionalWriter object for writing ConditionalMutations
- Throws:
TableNotFoundException
- when the specified table doesn't exist
-
createConditionalWriter
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
-
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 interfaceAutoCloseable
-