Package org.apache.sshd.common.future
Class DefaultCancelFuture
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.future.AbstractSshFuture<T>
-
- org.apache.sshd.common.future.DefaultSshFuture<CancelFuture>
-
- org.apache.sshd.common.future.DefaultCancelFuture
-
- All Implemented Interfaces:
CancelFuture
,SshFuture<CancelFuture>
,VerifiableFuture<java.lang.Boolean>
,WaitableFuture
public class DefaultCancelFuture extends DefaultSshFuture<CancelFuture> implements CancelFuture
A default implementation of aCancelFuture
.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.CancellationException
backTrace
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DefaultCancelFuture(java.lang.Object id)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.CancellationException
getBackTrace()
Obtains an exception describing the stack trace of where the cancellation was initiated.boolean
isCanceled()
Tells whether the cancellation has been effected.void
setBackTrace(java.util.concurrent.CancellationException backTrace)
Sets aCancellationException
describing the stack trace of where the cancellation was initiated.void
setCanceled()
Marks thisCancelFuture
as the cancellation having been effected.void
setCanceled(java.lang.Throwable error)
Marks thisCancelFuture
as the cancellation having been effected.void
setNotCanceled()
Completes this future with a value indicating that the cancellation was not done.java.lang.Boolean
verify(long timeoutMillis, CancelOption... options)
Wait and verify that the operation was successful-
Methods inherited from class org.apache.sshd.common.future.DefaultSshFuture
addListener, await0, createCancellation, getNumRegisteredListeners, getValue, isDone, notifyListeners, onValueSet, removeListener, setValue, toString
-
Methods inherited from class org.apache.sshd.common.future.AbstractSshFuture
asListener, asT, await, awaitUninterruptibly, formatExceptionMessage, getId, notifyListener, verifyResult
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.future.SshFuture
addListener, removeListener
-
Methods inherited from interface org.apache.sshd.common.future.VerifiableFuture
verify, verify, verify, verify, verify, verify, verify
-
Methods inherited from interface org.apache.sshd.common.future.WaitableFuture
await, await, await, await, await, await, await, await, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly, getId, isDone
-
-
-
-
Method Detail
-
verify
public java.lang.Boolean verify(long timeoutMillis, CancelOption... options) throws java.io.IOException
Wait and verify that the operation was successful- Specified by:
verify
in interfaceVerifiableFuture<java.lang.Boolean>
- Parameters:
timeoutMillis
- Wait timeout in millisecondsoptions
- OptionalCancelOption
s defining the behavior on time-out or interrupt; ignored if the future is notCancellable
.- Returns:
- the value of
isCanceled()
- Throws:
java.io.IOException
- If failed to verify successfully on time
-
setCanceled
public void setCanceled()
Description copied from interface:CancelFuture
Marks thisCancelFuture
as the cancellation having been effected.This is a framework-internal method.
- Specified by:
setCanceled
in interfaceCancelFuture
-
setCanceled
public void setCanceled(java.lang.Throwable error)
Description copied from interface:CancelFuture
Marks thisCancelFuture
as the cancellation having been effected.This is a framework-internal method.
- Specified by:
setCanceled
in interfaceCancelFuture
- Parameters:
error
- optionalThrowable
, if non-null
, it'll be attached to the backtrace.
-
setNotCanceled
public void setNotCanceled()
Description copied from interface:CancelFuture
Completes this future with a value indicating that the cancellation was not done.- Specified by:
setNotCanceled
in interfaceCancelFuture
-
isCanceled
public boolean isCanceled()
Description copied from interface:CancelFuture
Tells whether the cancellation has been effected. (WaitableFuture.isDone()
&& !isCanceled()
) means the cancellation was not effected. In that case check the original operation for a success or failure value.- Specified by:
isCanceled
in interfaceCancelFuture
- Returns:
true
if the cancellation was done;false
otherwise
-
setBackTrace
public void setBackTrace(java.util.concurrent.CancellationException backTrace)
Description copied from interface:CancelFuture
Sets aCancellationException
describing the stack trace of where the cancellation was initiated. Has no effect if a backtrace was already set, or the given backtrace isnull
.This is a framework-internal method.
- Specified by:
setBackTrace
in interfaceCancelFuture
- Parameters:
backTrace
-CancellationException
to set
-
getBackTrace
public java.util.concurrent.CancellationException getBackTrace()
Description copied from interface:CancelFuture
Obtains an exception describing the stack trace of where the cancellation was initiated.- Specified by:
getBackTrace
in interfaceCancelFuture
- Returns:
- a
CancellationException
-
-