Package org.apache.sshd.common.future
Class GlobalRequestFuture
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.future.AbstractSshFuture<T>
-
- org.apache.sshd.common.future.DefaultSshFuture<GlobalRequestFuture>
-
- org.apache.sshd.common.future.GlobalRequestFuture
-
- All Implemented Interfaces:
EventListener
,SshFuture<GlobalRequestFuture>
,SshFutureListener<IoWriteFuture>
,WaitableFuture
,SshdEventListener
public class GlobalRequestFuture extends DefaultSshFuture<GlobalRequestFuture> implements SshFutureListener<IoWriteFuture>
ADefaultSshFuture
that can be used to wait for the reply of an SSH_MSG_GLOBAL_REQUEST sent withwant-reply = true
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
GlobalRequestFuture.ReplyHandler
AReplyHandler
is invoked asynchronously when the reply for a request withwant-reply = true
is received.
-
Field Summary
-
Fields inherited from class org.apache.sshd.common.future.AbstractSshFuture
CANCELED
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description GlobalRequestFuture(String request)
Creates a newGlobalRequestFuture
for a global request.GlobalRequestFuture(String request, GlobalRequestFuture.ReplyHandler handler)
Creates a newGlobalRequestFuture
for a global request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
fail(String message)
Fulfills this future, marking it as failed.Buffer
getBuffer()
Obtains the replyBuffer
if the request was successful.Throwable
getException()
Retrieves an exception if the request failed.GlobalRequestFuture.ReplyHandler
getHandler()
Retrieves theGlobalRequestFuture.ReplyHandler
of this future, if any.String
getId()
long
getSequenceNumber()
Retrieves this future's packet sequence number.void
operationComplete(IoWriteFuture future)
void
setSequenceNumber(long number)
Sets the packet sequence number of the global request represented by this future.String
toString()
-
Methods inherited from class org.apache.sshd.common.future.DefaultSshFuture
addListener, await0, cancel, getNumRegisteredListeners, getValue, isCanceled, isDone, notifyListeners, removeListener, setValue
-
Methods inherited from class org.apache.sshd.common.future.AbstractSshFuture
asListener, asT, await, awaitUninterruptibly, formatExceptionMessage, 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.WaitableFuture
await, await, await, awaitUninterruptibly, awaitUninterruptibly, awaitUninterruptibly
-
-
-
-
Constructor Detail
-
GlobalRequestFuture
public GlobalRequestFuture(String request)
Creates a newGlobalRequestFuture
for a global request. Synchronization occurs on the future itself. The future will be fulfilled once the reply has been received or an error occurred.- Parameters:
request
- the request identifier
-
GlobalRequestFuture
public GlobalRequestFuture(String request, GlobalRequestFuture.ReplyHandler handler)
Creates a newGlobalRequestFuture
for a global request. Synchronization occurs on the future itself. The future will be fulfilled once the request has been sent, or an error occurred during sending. The framework will invoke the handler once the reply has been received. For global requests withwant-reply = false
, the handler will be invoked with an empty buffer if the request was successfully sent.- Parameters:
request
- the request identifierhandler
- theGlobalRequestFuture.ReplyHandler
, ornull
-
-
Method Detail
-
getId
public String getId()
- Specified by:
getId
in interfaceWaitableFuture
- Overrides:
getId
in classAbstractSshFuture<GlobalRequestFuture>
-
getSequenceNumber
public long getSequenceNumber()
Retrieves this future's packet sequence number.- Returns:
- the sequence number
-
setSequenceNumber
public void setSequenceNumber(long number)
Sets the packet sequence number of the global request represented by this future.- Parameters:
number
- the packet sequence number- Throws:
IllegalArgumentException
- if the number given is not an unsigned 32bit value
-
fail
public void fail(String message)
Fulfills this future, marking it as failed.- Parameters:
message
- An explanation of the failure reason
-
getHandler
public GlobalRequestFuture.ReplyHandler getHandler()
Retrieves theGlobalRequestFuture.ReplyHandler
of this future, if any.- Returns:
- the handler, or
null
if none was set
-
getBuffer
public Buffer getBuffer()
Obtains the replyBuffer
if the request was successful. If called afterDefaultSshFuture.isDone()
istrue
, a non-null
result means the request was successful.- Returns:
- the
Buffer
, ornull
if the request was not successful or the reply was not received yet
-
getException
public Throwable getException()
Retrieves an exception if the request failed. If called afterDefaultSshFuture.isDone()
istrue
, anull
result means the request did not fail.- Returns:
- a failure reason, or
null
if there isn't one or if the request did not fail
-
operationComplete
public void operationComplete(IoWriteFuture future)
- Specified by:
operationComplete
in interfaceSshFutureListener<IoWriteFuture>
-
toString
public String toString()
- Overrides:
toString
in classDefaultSshFuture<GlobalRequestFuture>
-
-