Class 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.
    • Method Detail

      • getDeprecatedInstance

        @Deprecated
        public Instance getDeprecatedInstance()
        Deprecated.
        since 2.0.0
        Retrieve the instance used to construct this context
      • getCredentials

        public Credentials getCredentials()
        Retrieve the credentials used to construct this context
      • getPrincipal

        public String getPrincipal()
      • 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
      • 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 interface AccumuloClient
        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

        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 interface AccumuloClient
        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
      • 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 interface AccumuloClient
        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

        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 interface AccumuloClient
        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

        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 interface AccumuloClient
        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 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 interface AccumuloClient
        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 interface AccumuloClient
        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 interface AccumuloClient
        Returns:
        MultiTableBatchWriter object
      • 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 interface AccumuloClient
        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:
        IsolatedScanner
      • whoami

        public String whoami()
        Description copied from interface: AccumuloClient
        Get the current user for this AccumuloClient
        Specified by:
        whoami in interface AccumuloClient
        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 interface AccumuloClient
        Returns:
        an object to manipulate tables
      • 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 interface AccumuloClient
        Returns:
        an object to modify users and permissions
      • 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 interface AccumuloClient
        Specified by:
        close in interface AutoCloseable