@InterfaceAudience.Public @InterfaceStability.Evolving public class KuduClient extends Object implements AutoCloseable
This class acts as a wrapper around AsyncKuduClient
which contains all the relevant
documentation.
Modifier and Type | Class and Description |
---|---|
static class |
KuduClient.KuduClientBuilder
Builder class to use in order to connect to Kudu.
|
Modifier and Type | Field and Description |
---|---|
static long |
NO_TIMESTAMP |
Modifier and Type | Method and Description |
---|---|
AlterTableResponse |
alterTable(String name,
AlterTableOptions ato)
Alter a table on the cluster as specified by the builder.
|
void |
close()
Analogous to
shutdown() . |
KuduTable |
createTable(String name,
Schema schema,
CreateTableOptions builder)
Create a table on the cluster with the specified name, schema, and table configurations.
|
DeleteTableResponse |
deleteTable(String name)
Delete a table on the cluster with the specified name.
|
DeleteTableResponse |
deleteTable(String name,
int reserveSeconds)
SoftDelete a table on the cluster with the specified name, the table will be
reserved for reserveSeconds before being purged.
|
byte[] |
exportAuthenticationCredentials()
Export serialized authentication data that may be passed to a different
client instance and imported to provide that client the ability to connect
to the cluster.
|
String |
getClusterId()
Returns the ID of the cluster that this client is connected to.
|
long |
getDefaultAdminOperationTimeoutMs()
Get the timeout used for admin operations.
|
long |
getDefaultOperationTimeoutMs()
Get the timeout used for operations on sessions and scanners.
|
long |
getLastPropagatedTimestamp()
Returns the last timestamp received from a server.
|
String |
getLocationString()
Returns a string representation of this client's location.
|
String |
getMasterAddressesAsString() |
ListTablesResponse |
getSoftDeletedTablesList()
Get the list of all the soft deleted tables.
|
ListTablesResponse |
getSoftDeletedTablesList(String nameFilter)
Get list of soft deleted table names.
|
Statistics |
getStatistics()
Get the statistics object of this client.
|
ListTablesResponse |
getTablesList()
Get the list of all the regular tables.
|
ListTablesResponse |
getTablesList(String nameFilter)
Get a list of regular table names.
|
KuduTableStatistics |
getTableStatistics(String name)
Get table's statistics from master.
|
boolean |
hasLastPropagatedTimestamp()
Checks if the client received any timestamps from a server.
|
void |
importAuthenticationCredentials(byte[] authnData)
Import data allowing this client to authenticate to the cluster.
|
boolean |
isAlterTableDone(String name)
Waits for all of the tablets in a table to be altered, or until the
default admin operation timeout is reached.
|
boolean |
isCreateTableDone(String name)
Waits for all of the tablets in a table to be created, or until the
default admin operation timeout is reached.
|
boolean |
isStatisticsEnabled()
Check if statistics collection is enabled for this client.
|
void |
jwt(String jwt)
Set JWT (JSON Web Token) to authenticate the client to a server.
|
ListTabletServersResponse |
listTabletServers()
Get the list of running tablet servers.
|
KuduScanner.KuduScannerBuilder |
newScannerBuilder(KuduTable table)
Creates a new
KuduScanner.KuduScannerBuilder for a particular table. |
KuduScanToken.KuduScanTokenBuilder |
newScanTokenBuilder(KuduTable table)
Creates a new
KuduScanToken.KuduScanTokenBuilder for a particular table. |
KuduSession |
newSession()
Create a new session for interacting with the cluster.
|
KuduTransaction |
newTransaction()
Start a new multi-row distributed transaction.
|
KuduTable |
openTable(String name)
Open the table with the given name.
|
RecallDeletedTableResponse |
recallDeletedTable(String id)
Recall a deleted table on the cluster with the specified table id
|
RecallDeletedTableResponse |
recallDeletedTable(String id,
String newTableName)
Recall a deleted table on the cluster with the specified table id
and give the recalled table the new table name
|
void |
shutdown()
Performs a graceful shutdown of this instance.
|
boolean |
tableExists(String name)
Test if a table exists.
|
void |
trustedCertificates(List<com.google.protobuf.ByteString> certificates)
Mark the given CA certificates (in DER format) as the trusted ones for the
client.
|
void |
updateLastPropagatedTimestamp(long lastPropagatedTimestamp)
Updates the last timestamp received from a server.
|
public static final long NO_TIMESTAMP
public void updateLastPropagatedTimestamp(long lastPropagatedTimestamp)
lastPropagatedTimestamp
- the last timestamp received from a server.public long getLastPropagatedTimestamp()
public boolean hasLastPropagatedTimestamp()
public String getLocationString()
public String getClusterId()
public KuduTable createTable(String name, Schema schema, CreateTableOptions builder) throws KuduException
name
- the table's nameschema
- the table's schemabuilder
- a builder containing the table's configurationsKuduException
- if anything went wrongpublic boolean isCreateTableDone(String name) throws KuduException
name
- the table's nameKuduException
- for any error returned by sending RPCs to the master
(e.g. the table does not exist)public DeleteTableResponse deleteTable(String name) throws KuduException
name
- the table's nameKuduException
- if anything went wrongpublic DeleteTableResponse deleteTable(String name, int reserveSeconds) throws KuduException
name
- the table's namereserveSeconds
- the soft deleted table to be alive timeKuduException
- if anything went wrongpublic RecallDeletedTableResponse recallDeletedTable(String id) throws KuduException
id
- the table's idKuduException
- if anything went wrongpublic RecallDeletedTableResponse recallDeletedTable(String id, String newTableName) throws KuduException
id
- the table's idnewTableName
- the recalled table's new nameKuduException
- if anything went wrongpublic AlterTableResponse alterTable(String name, AlterTableOptions ato) throws KuduException
name
- the table's name (old name if the table is being renamed)ato
- the alter table optionsKuduException
- if anything went wrongpublic boolean isAlterTableDone(String name) throws KuduException
name
- the table's nameKuduException
- for any error returned by sending RPCs to the master
(e.g. the table does not exist)public ListTabletServersResponse listTabletServers() throws KuduException
KuduException
- if anything went wrongpublic ListTablesResponse getTablesList() throws KuduException
KuduException
- if anything went wrongpublic ListTablesResponse getTablesList(String nameFilter) throws KuduException
nameFilter
- an optional table name filterKuduException
- if anything went wrongpublic ListTablesResponse getSoftDeletedTablesList() throws KuduException
KuduException
- if anything went wrongpublic ListTablesResponse getSoftDeletedTablesList(String nameFilter) throws KuduException
nameFilter
- an optional table name filterKuduException
- if anything went wrongpublic KuduTableStatistics getTableStatistics(String name) throws KuduException
name
- the table's nameKuduException
- if anything went wrongpublic boolean tableExists(String name) throws KuduException
name
- a non-null table nameKuduException
- if anything went wrongpublic KuduTable openTable(String name) throws KuduException
name
- table to openKuduException
- if anything went wrongpublic KuduSession newSession()
public KuduTransaction newTransaction() throws KuduException
Start a new multi-row transaction and return a handle for the transactional object to manage the newly started transaction. Under the hood, this makes an RPC call to the Kudu cluster and registers a newly created transaction in the system. This call is blocking.
KuduException
public boolean isStatisticsEnabled()
public Statistics getStatistics()
IllegalStateException
- thrown if statistics collection has been disabledpublic KuduScanner.KuduScannerBuilder newScannerBuilder(KuduTable table)
KuduScanner.KuduScannerBuilder
for a particular table.table
- the table you intend to scan.
The string is assumed to use the platform's default charset.public KuduScanToken.KuduScanTokenBuilder newScanTokenBuilder(KuduTable table)
KuduScanToken.KuduScanTokenBuilder
for a particular table.
Used for integrations with compute frameworks.table
- the table you intend to scanpublic void close() throws KuduException
shutdown()
.close
in interface AutoCloseable
KuduException
- if an error happens while closing the connectionspublic void shutdown() throws KuduException
KuduException
- if anything went wrong@InterfaceStability.Unstable public byte[] exportAuthenticationCredentials() throws KuduException
KuduException
@InterfaceStability.Unstable public void importAuthenticationCredentials(byte[] authnData)
authnData
- then authentication data provided by a prior call to
exportAuthenticationCredentials()
@InterfaceStability.Unstable public void trustedCertificates(List<com.google.protobuf.ByteString> certificates) throws CertificateException
certificates
- list of certificates to trust (in DER format)CertificateException
- if any of the specified certificates were invalid@InterfaceStability.Unstable public void jwt(String jwt)
jwt
- The JSON web token to set.public long getDefaultOperationTimeoutMs()
public long getDefaultAdminOperationTimeoutMs()
public String getMasterAddressesAsString()