@InterfaceAudience.Public @InterfaceStability.Unstable public class AsyncKuduClient extends Object implements AutoCloseable
This client should be instantiated only once. You can use it with any number of tables at the same time. The only case where you should have multiple instances is when you want to use multiple different clusters at the same time.
If you play by the rules, this client is completely thread-safe. Read the documentation carefully to know what the requirements are for this guarantee to apply.
This client is fully non-blocking, any blocking operation will return a
Deferred
instance to which you can attach a Callback
chain
that will execute when the asynchronous operation completes.
KuduRpc
instances passed to this classKuduRpc
passed to a method of this class should not be
changed or re-used until the Deferred
returned by that method
calls you back. Changing or re-using any KuduRpc
for
an RPC in flight will lead to unpredictable results and voids
your warranty.
throws
clausesDeferred
object they return to you can carry an
exception that you should handle (using "errbacks", see the javadoc of
Deferred
). In order to be able to do proper asynchronous error
handling, you need to know what types of exceptions you're expected to face
in your errbacks. In order to document that, the methods of this API use
javadoc's @throws
to spell out the exception types you should
handle in your errback. Asynchronous exceptions will be indicated as such
in the javadoc with "(deferred)".Modifier and Type | Class and Description |
---|---|
static class |
AsyncKuduClient.AsyncKuduClientBuilder
Builder class to use in order to connect to Kudu.
|
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_OPERATION_TIMEOUT_MS |
static long |
DEFAULT_SOCKET_READ_TIMEOUT_MS |
static byte[] |
EMPTY_ARRAY |
static org.slf4j.Logger |
LOG |
static long |
NO_TIMESTAMP |
static int |
SLEEP_TIME |
Modifier and Type | Method and Description |
---|---|
com.stumbleupon.async.Deferred<AlterTableResponse> |
alterTable(String name,
AlterTableOptions ato)
Alter a table on the cluster as specified by the builder.
|
void |
close()
Invokes
shutdown() and waits for the configured admin timeout. |
com.stumbleupon.async.Deferred<KuduTable> |
createTable(String name,
Schema schema,
CreateTableOptions builder)
Create a table on the cluster with the specified name, schema, and table configurations.
|
com.stumbleupon.async.Deferred<DeleteTableResponse> |
deleteTable(String name)
Delete a table on the cluster with the specified name.
|
long |
getDefaultAdminOperationTimeoutMs()
Get the timeout used for admin operations.
|
long |
getDefaultOperationTimeoutMs()
Get the timeout used for operations on sessions and scanners.
|
long |
getDefaultSocketReadTimeoutMs()
Get the timeout used when waiting to read data from a socket.
|
long |
getLastPropagatedTimestamp() |
Statistics |
getStatistics()
Get the statistics object of this client.
|
com.stumbleupon.async.Deferred<ListTablesResponse> |
getTablesList()
Get the list of all the tables.
|
com.stumbleupon.async.Deferred<ListTablesResponse> |
getTablesList(String nameFilter)
Get a list of table names.
|
com.stumbleupon.async.Deferred<IsAlterTableDoneResponse> |
isAlterTableDone(String name)
Helper method that checks and waits until the completion of an alter command.
|
boolean |
isStatisticsEnabled()
Check if statistics collection is enabled for this client.
|
com.stumbleupon.async.Deferred<ListTabletServersResponse> |
listTabletServers()
Get the list of running tablet servers.
|
AsyncKuduScanner.AsyncKuduScannerBuilder |
newScannerBuilder(KuduTable table)
Creates a new
AsyncKuduScanner.AsyncKuduScannerBuilder for a particular table. |
AsyncKuduSession |
newSession()
Create a new session for interacting with the cluster.
|
com.stumbleupon.async.Deferred<KuduTable> |
openTable(String name)
Open the table with the given name.
|
com.stumbleupon.async.Deferred<ArrayList<Void>> |
shutdown()
Performs a graceful shutdown of this instance.
|
KuduClient |
syncClient()
Returns a synchronous
KuduClient which wraps this asynchronous client. |
com.stumbleupon.async.Deferred<Boolean> |
tableExists(String name)
Test if a table exists.
|
void |
updateLastPropagatedTimestamp(long lastPropagatedTimestamp)
Updates the last timestamp received from a server.
|
public static final org.slf4j.Logger LOG
public static final int SLEEP_TIME
public static final byte[] EMPTY_ARRAY
public static final long NO_TIMESTAMP
public static final long DEFAULT_OPERATION_TIMEOUT_MS
public static final long DEFAULT_SOCKET_READ_TIMEOUT_MS
public void updateLastPropagatedTimestamp(long lastPropagatedTimestamp)
lastPropagatedTimestamp
- the last timestamp received from a serverpublic long getLastPropagatedTimestamp()
public KuduClient syncClient()
KuduClient
which wraps this asynchronous client.
Calling KuduClient.close()
on the returned client will close this client.
If this asynchronous client should outlive the returned synchronous client,
then do not close the synchronous client.KuduClient
public com.stumbleupon.async.Deferred<KuduTable> createTable(String name, Schema schema, CreateTableOptions builder)
name
- the table's nameschema
- the table's schemabuilder
- a builder containing the table's configurationspublic com.stumbleupon.async.Deferred<DeleteTableResponse> deleteTable(String name)
name
- the table's namepublic com.stumbleupon.async.Deferred<AlterTableResponse> alterTable(String name, AlterTableOptions ato)
isAlterTableDone(String)
to know when the alter finishes.name
- the table's name, if this is a table rename then the old table name must be passedato
- the alter table builderpublic com.stumbleupon.async.Deferred<IsAlterTableDoneResponse> isAlterTableDone(String name) throws Exception
name
- the table's name, if the table was renamed then that name must be checked againstException
public com.stumbleupon.async.Deferred<ListTabletServersResponse> listTabletServers()
public com.stumbleupon.async.Deferred<ListTablesResponse> getTablesList()
public com.stumbleupon.async.Deferred<ListTablesResponse> getTablesList(String nameFilter)
nameFilter
- an optional table name filterpublic com.stumbleupon.async.Deferred<Boolean> tableExists(String name)
name
- a non-null table namepublic com.stumbleupon.async.Deferred<KuduTable> openTable(String name)
name
- table to openpublic long getDefaultOperationTimeoutMs()
public long getDefaultAdminOperationTimeoutMs()
public long getDefaultSocketReadTimeoutMs()
timeout
milliseconds.public boolean isStatisticsEnabled()
public Statistics getStatistics()
IllegalStateException
- thrown if statistics collection has been disabledpublic AsyncKuduScanner.AsyncKuduScannerBuilder newScannerBuilder(KuduTable table)
AsyncKuduScanner.AsyncKuduScannerBuilder
for a particular table.table
- the name of the table you intend to scan.
The string is assumed to use the platform's default charset.public AsyncKuduSession newSession()
public void close() throws Exception
shutdown()
and waits for the configured admin timeout. This method returns
void, so consider invoking shutdown directly if there's a need to handle dangling RPCs.close
in interface AutoCloseable
Exception
- if an error happens while closing the connectionspublic com.stumbleupon.async.Deferred<ArrayList<Void>> shutdown()
Flushes
all buffered edits.Deferred
, whose callback chain will be invoked once all
of the above have been done. If this callback chain doesn't fail, then
the clean shutdown will be successful, and all the data will be safe on
the Kudu side. In case of a failure (the "errback" is invoked) you will have
to open a new AsyncKuduClient if you want to retry those operations.
The Deferred doesn't actually hold any content.Copyright © 2016. All rights reserved.