T - Type of futurepublic abstract class AbstractSshFuture<T extends SshFuture> extends AbstractLoggingBean implements SshFuture<T>
| Modifier and Type | Field and Description |
|---|---|
protected static Object |
CANCELED
A default value to indicate the future has been canceled
|
log| Modifier | Constructor and Description |
|---|---|
protected |
AbstractSshFuture(Object id) |
| Modifier and Type | Method and Description |
|---|---|
protected SshFutureListener<T> |
asListener(Object o) |
protected T |
asT() |
boolean |
await(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout.
|
protected abstract Object |
await0(long timeoutMillis,
boolean interruptable)
Wait for the Future to be ready.
|
boolean |
awaitUninterruptibly(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.
|
protected <E extends Throwable> |
formatExceptionMessage(Function<? super String,? extends E> exceptionCreator,
String format,
Object... args)
Generates an exception whose message is prefixed by the future simple class name +
identifier as
a hint to the context of the failure. |
Object |
getId() |
protected void |
notifyListener(SshFutureListener<T> l) |
String |
toString() |
protected <R> R |
verifyResult(Class<? extends R> expectedType,
long timeout)
Waits (interruptible) for the specified timeout (msec.) and then checks the result:
|
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddListener, removeListenerawait, await, await, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, isDoneprotected static final Object CANCELED
protected AbstractSshFuture(Object id)
id - Some identifier useful as toString() valuepublic Object getId()
getId in interface WaitableFuturetoString() valuepublic boolean await(long timeoutMillis)
throws IOException
WaitableFutureawait in interface WaitableFuturetimeoutMillis - Wait time in millisecondstrue if the operation is completed.IOException - if failed - specifically InterruptedIOException if waiting was interruptedpublic boolean awaitUninterruptibly(long timeoutMillis)
WaitableFutureawaitUninterruptibly in interface WaitableFuturetimeoutMillis - Wait time in millisecondstrue if the operation is finished.protected <R> R verifyResult(Class<? extends R> expectedType, long timeout) throws IOException
Waits (interruptible) for the specified timeout (msec.) and then checks the result:
If result is null then timeout is assumed to have expired - throw an appropriate IOException
If the result is of the expected type, then cast and return it
If the result is a Throwable then throw an IOException whose cause is the original exception
Otherwise (should never happen), throw a StreamCorruptedException with the name of the result type
R - The generic result typeexpectedType - The expected result typetimeout - The timeout (millis) to wait for a resultnull) resultIOException - If failed to retrieve the expected result on timeprotected abstract Object await0(long timeoutMillis, boolean interruptable) throws InterruptedIOException
timeoutMillis - The delay we will wait for the Future to be readyinterruptable - Tells if the wait can be interrupted or not. If true and the thread is
interrupted then an InterruptedIOException is thrown.null result object if the Future is ready, null if the
timeout expired and no result was receivedInterruptedIOException - If the thread has been interrupted when it's not allowed.protected SshFutureListener<T> asListener(Object o)
protected void notifyListener(SshFutureListener<T> l)
protected T asT()
protected <E extends Throwable> E formatExceptionMessage(Function<? super String,? extends E> exceptionCreator, String format, Object... args)
identifier as
a hint to the context of the failure.E - Type of Throwable being generatedexceptionCreator - The exception creator from the formatted messageformat - The extra payload format as per String.format(String, Object...)args - The formatting argumentsCopyright © 2018–2021 The Apache Software Foundation. All rights reserved.