Top Fields Constructors Methods
org.apache.sshd.common.future

public abstract Class AbstractSshFuture<T extends SshFuture<T>>

extends AbstractLoggingBean
implements SshFuture<T extends SshFuture<T>>
Class Inheritance
All Implemented Interfaces
org.apache.sshd.common.future.SshFuture, org.apache.sshd.common.future.WaitableFuture
Known Direct Subclasses
org.apache.sshd.common.future.DefaultSshFuture
Type Parameters
<T>
Type of future
Imports
java.io.IOException, .InterruptedIOException, .StreamCorruptedException, java.net.ConnectException, java.util.concurrent.CancellationException, .TimeoutException, java.util.function.Function, org.apache.sshd.common.SshException, org.apache.sshd.common.util.ExceptionUtils, .GenericUtils, org.apache.sshd.common.util.logging.AbstractLoggingBean, org.apache.sshd.common.util.threads.ThreadUtils

Author
Apache MINA SSHD Project

Field Summary

Modifier and TypeField and Description
private final Object
Inherited from org.apache.sshd.common.util.logging.AbstractLoggingBean:
log

Constructor Summary

AccessConstructor and Description
protected
AbstractSshFuture(Object
Some identifier useful as toString() value
id
)

Method Summary

Modifier and TypeMethod and Description
protected SshFutureListener<T>
protected T
asT()

public boolean
await(long
Wait time in milliseconds
timeoutMillis
,
CancelOption...
Optional CancelOptions defining the behavior on time-out or interrupt; ignored if the future is not Cancellable.
options
)

Implements org.apache.sshd.common.future.WaitableFuture.await.

Wait for the asynchronous operation to complete with the specified timeout.

protected abstract Object

Returns:

The non-null result object if the Future is ready, null if the timeout expired and no result was received
await0
(long
The delay we will wait for the Future to be ready
timeoutMillis
,
boolean
Tells if the wait can be interrupted or not. If true and the thread is interrupted then an InterruptedIOException is thrown.
interruptable
,
CancelOption...
Optional CancelOption defining the behavior on time-out or interrupt.
options
)

Wait for the Future to be ready.

public boolean
awaitUninterruptibly(long
Wait time in milliseconds
timeoutMillis
,
CancelOption...
Optional CancelOptions defining the behavior on time-out; ignored if the future is not Cancellable.
options
)

Implements org.apache.sshd.common.future.WaitableFuture.awaitUninterruptibly.

Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.

protected <
Type of Throwable being generated
E extends Throwable
>
E

Returns:

The generated exception
formatExceptionMessage
(Function<? super String, ? extends E>
The exception creator from the formatted message
exceptionCreator
,
String
The extra payload format as per String#format(String, Object...)
format
,
Object...
The formatting arguments
args
)

Generates an exception whose message is prefixed by the future simple class name + identifier as a hint to the context of the failure.

public Object
protected void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

protected <
The generic result type
R
>
R

Returns:

The (never null) result
verifyResult
(Class<? extends R>
The expected result type
expectedType
,
long
The timeout (millis) to wait for a result
timeout
,
CancelOption...
Optional CancelOptions defining the behavior on time-out or interrupt.
options
)

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
Inherited from org.apache.sshd.common.util.logging.AbstractLoggingBean:
debugdebugdebugdebugdebugerrorerrorerrorerrorerrorgetSimplifiedLoggerinfoinfowarnwarnwarnwarnwarnwarnwarnwarn

Field Detail

idback to summary
private final Object id

Constructor Detail

AbstractSshFutureback to summary
protected AbstractSshFuture(Object id)
Parameters
id:Object

Some identifier useful as toString() value

Method Detail

asListenerback to summary
protected SshFutureListener<T> asListener(Object o)
Annotations
@SuppressWarnings:unchecked
asTback to summary
protected T asT()
Annotations
@SuppressWarnings:unchecked
awaitback to summary
public boolean await(long timeoutMillis, CancelOption... options) throws IOException

Implements org.apache.sshd.common.future.WaitableFuture.await.

Doc from org.apache.sshd.common.future.WaitableFuture.await.

Wait for the asynchronous operation to complete with the specified timeout.

Parameters
timeoutMillis:long

Wait time in milliseconds

options:CancelOption[]

Optional CancelOptions defining the behavior on time-out or interrupt; ignored if the future is not Cancellable.

Returns:boolean

true if the operation is completed.

Annotations
@Override
Exceptions
IOException:
if failed - specifically java.io.InterruptedIOException if waiting was interrupted
await0back to summary
protected abstract Object await0(long timeoutMillis, boolean interruptable, CancelOption... options) throws InterruptedIOException

Wait for the Future to be ready. If the requested delay is 0 or negative, this method returns immediately.

Parameters
timeoutMillis:long

The delay we will wait for the Future to be ready

interruptable:boolean

Tells if the wait can be interrupted or not. If true and the thread is interrupted then an InterruptedIOException is thrown.

options:CancelOption[]

Optional CancelOption defining the behavior on time-out or interrupt.

Returns:Object

The non-null result object if the Future is ready, null if the timeout expired and no result was received

Exceptions
InterruptedIOException:
If the thread has been interrupted when it's not allowed.
awaitUninterruptiblyback to summary
public boolean awaitUninterruptibly(long timeoutMillis, CancelOption... options)

Implements org.apache.sshd.common.future.WaitableFuture.awaitUninterruptibly.

Doc from org.apache.sshd.common.future.WaitableFuture.awaitUninterruptibly.

Wait for the asynchronous operation to complete with the specified timeout uninterruptibly.

Parameters
timeoutMillis:long

Wait time in milliseconds

options:CancelOption[]

Optional CancelOptions defining the behavior on time-out; ignored if the future is not Cancellable.

Returns:boolean

true if the operation is finished.

Annotations
@Override
formatExceptionMessageback to summary
protected <E extends Throwable> E 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.

Parameters
<E>
Type of Throwable being generated
exceptionCreator:Function<? super String, ? extends E>

The exception creator from the formatted message

format:String

The extra payload format as per String#format(String, Object...)

args:Object[]

The formatting arguments

Returns:E

The generated exception

getIdback to summary
public Object getId()

Implements org.apache.sshd.common.future.WaitableFuture.getId.

Returns:Object

Doc from org.apache.sshd.common.future.WaitableFuture.getId.

Some identifier useful as toString() value

Annotations
@Override
notifyListenerback to summary
protected void notifyListener(SshFutureListener<T> l)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
verifyResultback to summary
protected <R> R verifyResult(Class<? extends R> expectedType, long timeout, CancelOption... options) 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
Parameters
<R>
The generic result type
expectedType:Class<? extends R>

The expected result type

timeout:long

The timeout (millis) to wait for a result

options:CancelOption[]

Optional CancelOptions defining the behavior on time-out or interrupt.

Returns:R

The (never null) result

Exceptions
IOException:
If failed to retrieve the expected result on time