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() |
Modifier and Type | Method and Description |
---|---|
protected SshFutureListener<T> |
asListener(Object o) |
protected T |
asT() |
boolean |
await()
Wait
Long.MAX_VALUE msec. |
boolean |
await(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout.
|
boolean |
await(long timeout,
TimeUnit unit)
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()
Wait
Long.MAX_VALUE msec. |
boolean |
awaitUninterruptibly(long timeoutMillis)
Wait for the asynchronous operation to complete with the specified timeout
uninterruptibly.
|
boolean |
awaitUninterruptibly(long timeout,
TimeUnit unit)
Wait for the asynchronous operation to complete with the specified timeout
uninterruptibly.
|
protected void |
notifyListener(SshFutureListener<T> l) |
protected <R> R |
verifyResult(Class<? extends R> expectedType,
long timeout)
Waits (interruptible) for the specified timeout (msec.) and then checks
the result:
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addListener, removeListener
isDone
protected static final Object CANCELED
public boolean await() throws IOException
WaitableFuture
Long.MAX_VALUE
msec. for the asynchronous operation to complete.
The attached listeners will be notified when the operation is
completed.await
in interface WaitableFuture
true
if the operation is completed.IOException
- if failed - specifically InterruptedIOException
if waiting was interruptedWaitableFuture.await(long)
public boolean await(long timeout, TimeUnit unit) throws IOException
WaitableFuture
await
in interface WaitableFuture
timeout
- The number of time units to waitunit
- The TimeUnit
for waitingtrue
if the operation is completed.IOException
- if failed - specifically InterruptedIOException
if waiting was interruptedWaitableFuture.await(long)
public boolean await(long timeoutMillis) throws IOException
WaitableFuture
await
in interface WaitableFuture
timeoutMillis
- Wait time in millisecondstrue
if the operation is completed.IOException
- if failed - specifically InterruptedIOException
if waiting was interruptedpublic boolean awaitUninterruptibly()
WaitableFuture
Long.MAX_VALUE
msec. for the asynchronous operation to complete
uninterruptibly. The attached listeners will be notified when the operation is
completed.awaitUninterruptibly
in interface WaitableFuture
true
if the operation is completed.WaitableFuture.awaitUninterruptibly(long)
public boolean awaitUninterruptibly(long timeout, TimeUnit unit)
WaitableFuture
awaitUninterruptibly
in interface WaitableFuture
timeout
- The number of time units to waitunit
- The TimeUnit
for waitingtrue
if the operation is completed.WaitableFuture.awaitUninterruptibly(long)
public boolean awaitUninterruptibly(long timeoutMillis)
WaitableFuture
awaitUninterruptibly
in interface WaitableFuture
timeoutMillis
- 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 an IOException
then re-throw 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()
Copyright © 2008–2016 The Apache Software Foundation. All rights reserved.