Class ClientContext
- java.lang.Object
-
- org.apache.accumulo.core.clientImpl.ClientContext
-
- All Implemented Interfaces:
AutoCloseable
,AccumuloClient
public class ClientContext extends Object implements AccumuloClient
This class represents any essential configuration and credentials needed to initiate RPC operations throughout the code. It is intended to represent a shared object that contains these things from when the client was first constructed. It is not public API, and is only an internal representation of the context in which a client is executing RPCs. If additional parameters are added to the public API that need to be used in the internals of Accumulo, they should be added to this object for later retrieval, rather than as a separate parameter. Any state in this object should be available at the time of its construction.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ClientContext.ClientBuilderImpl<T>
-
Nested classes/interfaces inherited from interface org.apache.accumulo.core.client.AccumuloClient
AccumuloClient.AuthenticationArgs<T>, AccumuloClient.ClientFactory<T>, AccumuloClient.ConnectionOptions<T>, AccumuloClient.FromOptions<T>, AccumuloClient.InstanceArgs<T>, AccumuloClient.PropertyOptions<T>, AccumuloClient.SaslOptions<T>, AccumuloClient.SslOptions<T>
-
-
Constructor Summary
Constructors Constructor Description ClientContext(Properties clientProperties)
ClientContext(ClientInfo info)
ClientContext(ClientInfo info, AccumuloConfiguration serverConf)
ClientContext(SingletonReservation reservation, ClientInfo info)
ClientContext(SingletonReservation reservation, ClientInfo info, AccumuloConfiguration serverConf)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
close()
Cleans up any resources created by an AccumuloClient like threads and sockets.BatchDeleter
createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads)
Factory method to create BatchDeleter.BatchDeleter
createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads, BatchWriterConfig config)
Factory method to create BatchDeleterBatchScanner
createBatchScanner(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.BatchScanner
createBatchScanner(String tableName, Authorizations authorizations)
Factory method to create a BatchScanner connected to Accumulo.BatchScanner
createBatchScanner(String tableName, Authorizations authorizations, int numQueryThreads)
Factory method to create a BatchScanner connected to Accumulo.BatchWriter
createBatchWriter(String tableName)
Factory method to create a BatchWriter.BatchWriter
createBatchWriter(String tableName, BatchWriterConfig config)
Factory method to create a BatchWriter connected to Accumulo.ConditionalWriter
createConditionalWriter(String tableName, ConditionalWriterConfig config)
Factory method to create a ConditionalWriter connected to Accumulo.MultiTableBatchWriter
createMultiTableBatchWriter()
Factory method to create a Multi-Table BatchWriter.MultiTableBatchWriter
createMultiTableBatchWriter(BatchWriterConfig config)
Factory method to create a Multi-Table BatchWriter connected to Accumulo.Scanner
createScanner(String tableName)
Factory method to create a Scanner with all of the user's authorizations.Scanner
createScanner(String tableName, Authorizations authorizations)
Factory method to create a Scanner connected to Accumulo.AuthenticationToken
getAuthenticationToken()
BatchWriterConfig
getBatchWriterConfig()
SslConnectionParams
getClientSslParams()
Retrieve SSL/TLS configuration to initiate an RPC connection to a serverlong
getClientTimeoutInMillis()
Retrieve the universal RPC client timeout from the configurationAccumuloConfiguration
getConfiguration()
Retrieve the configuration used to construct this contextCredentials
getCredentials()
Retrieve the credentials used to construct this contextInstance
getDeprecatedInstance()
Deprecated.since 2.0.0org.apache.hadoop.conf.Configuration
getHadoopConf()
Retrieve the hadoop configurationString
getInstanceID()
Returns a unique string that identifies this instance of accumulo.String
getInstanceName()
Returns the instance name given at system initialization time.List<String>
getMasterLocations()
Returns the location(s) of the accumulo master and any redundant servers.String
getPrincipal()
Properties
getProperties()
String
getRootTabletLocation()
Returns the location of the tablet server that is serving the root tablet.SaslConnectionParams
getSaslParams()
Retrieve SASL configuration to initiate an RPC connection to a serverZooCache
getZooCache()
String
getZooKeeperRoot()
String
getZooKeepers()
Returns a comma-separated list of zookeeper servers the instance is using.int
getZooKeepersSessionTimeOut()
Returns the zookeeper connection timeout.InstanceOperations
instanceOperations()
Retrieves an InstanceOperations object to modify instance configuration.NamespaceOperations
namespaceOperations()
Retrieves a NamespaceOperations object to perform namespace functions, such as create and delete.Properties
properties()
ReplicationOperations
replicationOperations()
Retrieves a ReplicationOperations object to manage replication configuration.TCredentials
rpcCreds()
Serialize the credentials just before initiating the RPC callSecurityOperations
securityOperations()
Retrieves a SecurityOperations object to perform user security operations, such as creating users.void
setCredentials(Credentials newCredentials)
Update the credentials in the current context after changing the current user's password or other auth tokenTableOperations
tableOperations()
Retrieves a TableOperations object to perform table functions, such as create and delete.AuthenticationToken
token()
String
whoami()
Get the current user for this AccumuloClient
-
-
-
Constructor Detail
-
ClientContext
public ClientContext(Properties clientProperties)
-
ClientContext
public ClientContext(SingletonReservation reservation, ClientInfo info)
-
ClientContext
public ClientContext(ClientInfo info)
-
ClientContext
public ClientContext(ClientInfo info, AccumuloConfiguration serverConf)
-
ClientContext
public ClientContext(SingletonReservation reservation, ClientInfo info, AccumuloConfiguration serverConf)
-
-
Method Detail
-
getDeprecatedInstance
@Deprecated public Instance getDeprecatedInstance()
Deprecated.since 2.0.0Retrieve the instance used to construct this context
-
getCredentials
public Credentials getCredentials()
Retrieve the credentials used to construct this context
-
getPrincipal
public String getPrincipal()
-
getAuthenticationToken
public AuthenticationToken getAuthenticationToken()
-
getProperties
public Properties getProperties()
-
setCredentials
public void setCredentials(Credentials newCredentials)
Update the credentials in the current context after changing the current user's password or other auth token
-
getConfiguration
public AccumuloConfiguration getConfiguration()
Retrieve the configuration used to construct this context
-
getHadoopConf
public org.apache.hadoop.conf.Configuration getHadoopConf()
Retrieve the hadoop configuration
-
getClientTimeoutInMillis
public long getClientTimeoutInMillis()
Retrieve the universal RPC client timeout from the configuration
-
getClientSslParams
public SslConnectionParams getClientSslParams()
Retrieve SSL/TLS configuration to initiate an RPC connection to a server
-
getSaslParams
public SaslConnectionParams getSaslParams()
Retrieve SASL configuration to initiate an RPC connection to a server
-
getBatchWriterConfig
public BatchWriterConfig getBatchWriterConfig()
-
rpcCreds
public TCredentials rpcCreds()
Serialize the credentials just before initiating the RPC call
-
getRootTabletLocation
public String getRootTabletLocation()
Returns the location of the tablet server that is serving the root tablet.- Returns:
- location in "hostname:port" form
-
getMasterLocations
public List<String> getMasterLocations()
Returns the location(s) of the accumulo master and any redundant servers.- Returns:
- a list of locations in "hostname:port" form
-
getInstanceID
public String getInstanceID()
Returns a unique string that identifies this instance of accumulo.- Returns:
- a UUID
-
getZooKeeperRoot
public String getZooKeeperRoot()
-
getInstanceName
public String getInstanceName()
Returns the instance name given at system initialization time.- Returns:
- current instance name
-
getZooKeepers
public String getZooKeepers()
Returns a comma-separated list of zookeeper servers the instance is using.- Returns:
- the zookeeper servers this instance is using in "hostname:port" form
-
getZooKeepersSessionTimeOut
public int getZooKeepersSessionTimeOut()
Returns the zookeeper connection timeout.- Returns:
- the configured timeout to connect to zookeeper
-
getZooCache
public ZooCache getZooCache()
-
createBatchScanner
public BatchScanner createBatchScanner(String tableName, Authorizations authorizations, int numQueryThreads) throws TableNotFoundException
Description copied from interface:AccumuloClient
Factory method to create a BatchScanner connected to Accumulo.- Specified by:
createBatchScanner
in interfaceAccumuloClient
- 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
public BatchScanner createBatchScanner(String tableName, Authorizations authorizations) throws TableNotFoundException
Description copied from interface:AccumuloClient
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.- Specified by:
createBatchScanner
in interfaceAccumuloClient
- 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
public BatchScanner createBatchScanner(String tableName) throws TableNotFoundException, AccumuloSecurityException, AccumuloException
Description copied from interface:AccumuloClient
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.- Specified by:
createBatchScanner
in interfaceAccumuloClient
- 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
public BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads, BatchWriterConfig config) throws TableNotFoundException
Description copied from interface:AccumuloClient
Factory method to create BatchDeleter- Specified by:
createBatchDeleter
in interfaceAccumuloClient
- 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
public BatchDeleter createBatchDeleter(String tableName, Authorizations authorizations, int numQueryThreads) throws TableNotFoundException
Description copied from interface:AccumuloClient
Factory method to create BatchDeleter. This method uses BatchWriterConfig set when AccumuloClient was created. If none was set, BatchWriterConfig defaults will be used.- Specified by:
createBatchDeleter
in interfaceAccumuloClient
- 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
public BatchWriter createBatchWriter(String tableName, BatchWriterConfig config) throws TableNotFoundException
Description copied from interface:AccumuloClient
Factory method to create a BatchWriter connected to Accumulo.- Specified by:
createBatchWriter
in interfaceAccumuloClient
- 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 merged with 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
public BatchWriter createBatchWriter(String tableName) throws TableNotFoundException
Description copied from interface:AccumuloClient
Factory method to create a BatchWriter. This method uses BatchWriterConfig set when AccumuloClient was created. If none was set, BatchWriterConfig defaults will be used.- Specified by:
createBatchWriter
in interfaceAccumuloClient
- Parameters:
tableName
- the name of the table to insert data into- Returns:
- BatchWriter object
- Throws:
TableNotFoundException
- if table not found
-
createMultiTableBatchWriter
public MultiTableBatchWriter createMultiTableBatchWriter(BatchWriterConfig config)
Description copied from interface:AccumuloClient
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. Its an efficient way to ingest data into multiple tables from a single process.- Specified by:
createMultiTableBatchWriter
in interfaceAccumuloClient
- Parameters:
config
- configuration used to create multi-table batch writer. This config will take precedence. Any unset values will merged with 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
public MultiTableBatchWriter createMultiTableBatchWriter()
Description copied from interface:AccumuloClient
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.- Specified by:
createMultiTableBatchWriter
in interfaceAccumuloClient
- Returns:
- MultiTableBatchWriter object
-
createConditionalWriter
public ConditionalWriter createConditionalWriter(String tableName, ConditionalWriterConfig config) throws TableNotFoundException
Description copied from interface:AccumuloClient
Factory method to create a ConditionalWriter connected to Accumulo.- Specified by:
createConditionalWriter
in interfaceAccumuloClient
- 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
-
createScanner
public Scanner createScanner(String tableName, Authorizations authorizations) throws TableNotFoundException
Description copied from interface:AccumuloClient
Factory method to create a Scanner connected to Accumulo.- Specified by:
createScanner
in interfaceAccumuloClient
- 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:
IsolatedScanner
-
createScanner
public Scanner createScanner(String tableName) throws TableNotFoundException, AccumuloSecurityException, AccumuloException
Description copied from interface:AccumuloClient
Factory method to create a Scanner with all of the user's authorizations.- Specified by:
createScanner
in interfaceAccumuloClient
- 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:
IsolatedScanner
-
whoami
public String whoami()
Description copied from interface:AccumuloClient
Get the current user for this AccumuloClient- Specified by:
whoami
in interfaceAccumuloClient
- Returns:
- the user name
-
tableOperations
public TableOperations tableOperations()
Description copied from interface:AccumuloClient
Retrieves a TableOperations object to perform table functions, such as create and delete.- Specified by:
tableOperations
in interfaceAccumuloClient
- Returns:
- an object to manipulate tables
-
namespaceOperations
public NamespaceOperations namespaceOperations()
Description copied from interface:AccumuloClient
Retrieves a NamespaceOperations object to perform namespace functions, such as create and delete.- Specified by:
namespaceOperations
in interfaceAccumuloClient
- Returns:
- an object to manipulate namespaces
-
securityOperations
public SecurityOperations securityOperations()
Description copied from interface:AccumuloClient
Retrieves a SecurityOperations object to perform user security operations, such as creating users.- Specified by:
securityOperations
in interfaceAccumuloClient
- Returns:
- an object to modify users and permissions
-
instanceOperations
public InstanceOperations instanceOperations()
Description copied from interface:AccumuloClient
Retrieves an InstanceOperations object to modify instance configuration.- Specified by:
instanceOperations
in interfaceAccumuloClient
- Returns:
- an object to modify instance configuration
-
replicationOperations
public ReplicationOperations replicationOperations()
Description copied from interface:AccumuloClient
Retrieves a ReplicationOperations object to manage replication configuration.- Specified by:
replicationOperations
in interfaceAccumuloClient
- Returns:
- an object to modify replication configuration
-
properties
public Properties properties()
- Specified by:
properties
in interfaceAccumuloClient
- Returns:
- All
Properties
used to create client except 'auth.token'
-
token
public AuthenticationToken token()
-
close
public void close()
Description copied from interface:AccumuloClient
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 interfaceAccumuloClient
- Specified by:
close
in interfaceAutoCloseable
-
-