java.util.concurrent.Future<StatementResult>public interface ExecutionFuture extends java.util.concurrent.Future<StatementResult>
Future that provides a handle to an
administrative statement that has been issued and is being processed by the
kvstore. ExecutionFuture provides a way to check on the interim status of
the administrative operation, wait for the operation to complete, or cancel
the operation.
For example:
// Create a table and get a handle on the operation.
ExecutionFuture future = null;
try {
future = kvstore.execute
("CREATE TABLE users (" +
"id INTEGER, " +
"firstName STRING, " +
"lastName STRING, " +
"age INTEGER, " +
"PRIMARY KEY (id))");
} catch (IllegalArgumentException e) {
System.out.println("The statement is invalid: " + e);
} catch (FaultException e) {
System.out.println("There is a transient problem, retry the " +
"operation: " + e);
}
// Get current status on the asynchronously executing DDL statement
StatementResult result = future.updateStatus();
Note that this class supersedes oracle.kv.table.ExecutionFuture.| Modifier and Type | Method | Description |
|---|---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
Attempts to cancel execution of this statement.
|
StatementResult |
get() |
Block until the command represented by this future completes.
|
StatementResult |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
Block until the administrative operation has finished or the timeout
period is exceeded.
|
StatementResult |
getLastStatus() |
Returns information about the execution of the statement.
|
java.lang.String |
getStatement() |
Return the statement which has been executed.
|
boolean |
isCancelled() |
Returns true if the operation was cancelled.
|
boolean |
isDone() |
Returns true if the operation has been terminated.
|
byte[] |
toByteArray() |
Return a serialized version of the ExecutionFuture, which can be
saved for later use, via
KVStore.getFuture(byte[]). |
StatementResult |
updateStatus() |
Returns information about the execution of the statement.
|
boolean cancel(boolean mayInterruptIfRunning)
throws FaultException
cancel in interface java.util.concurrent.Future<StatementResult>mayInterruptIfRunning - Since command execution begins immediately,
if mayInterreuptIfRunning is false, cancel returns false.FaultException - if the Admin service connection fails.StatementResult get() throws java.util.concurrent.CancellationException, java.util.concurrent.ExecutionException, java.lang.InterruptedException
Note that ExecutionException is thrown if the statement execution threw an exception. Once get() throws ExecutionException, all further calls to get() will continue to throw ExecutionException.
get in interface java.util.concurrent.Future<StatementResult>java.util.concurrent.ExecutionException - if the command failed.java.util.concurrent.CancellationException - if the command was cancelled.java.lang.InterruptedException - if the current thread was interruptedFaultException - if tbwStatementResult get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.TimeoutException, java.util.concurrent.ExecutionException
Note that ExecutionException is thrown if the statement execution threw an exception. Once get() throws ExecutionException, all further calls to get() will continue to throw ExecutionException.
get in interface java.util.concurrent.Future<StatementResult>java.util.concurrent.TimeoutException - if the timeout is exceeded.java.lang.InterruptedException - if the operation is interruptedjava.util.concurrent.ExecutionExceptionboolean isCancelled()
isCancelled in interface java.util.concurrent.Future<StatementResult>boolean isDone()
When the statement has terminated, results and status can be obtained
via StatementResult
isDone in interface java.util.concurrent.Future<StatementResult>StatementResult updateStatus() throws FaultException
FaultException - if there was any problem with accessing the
server. In general, such issues are transient, and the request can
be retried.StatementResult getLastStatus()
updateStatus()java.lang.String getStatement()
byte[] toByteArray()
KVStore.getFuture(byte[]). For example:
byte[] futureBytes = future.toByteArray(); // futureBytes can be saved and used later to recreate an // ExecutionFuture instance ExecutionFuture laterFuture = store.getFuture(futureBytes); StatementResult laterResult = laterFuture.get();
Values returned by calls to this method can be used with current and newer releases, but are not guaranteed to be compatible with earlier releases.
Copyright (c) 2011, 2018 Oracle and/or its affiliates. All rights reserved.