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>
ADefaultSshFuturethat 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 interfaceGlobalRequestFuture.ReplyHandlerAReplyHandleris invoked asynchronously when the reply for a request withwant-reply = trueis received.
-
Field Summary
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description GlobalRequestFuture(String request)Creates a newGlobalRequestFuturefor a global request.GlobalRequestFuture(String request, GlobalRequestFuture.ReplyHandler handler)Creates a newGlobalRequestFuturefor a global request.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BuffergetBuffer()Obtains the replyBufferif the request was successful.ThrowablegetException()Retrieves an exception if the request failed.GlobalRequestFuture.ReplyHandlergetHandler()Retrieves theGlobalRequestFuture.ReplyHandlerof this future, if any.StringgetId()longgetSequenceNumber()Retrieves this future's packet sequence number.voidoperationComplete(IoWriteFuture future)voidsetSequenceNumber(long number)Sets the packet sequence number of the global request represented by this future.StringtoString()-
Methods inherited from class org.apache.sshd.common.future.DefaultSshFuture
addListener, await0, createCancellation, getNumRegisteredListeners, getValue, isDone, notifyListeners, onValueSet, 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 newGlobalRequestFuturefor 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 newGlobalRequestFuturefor 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:
getIdin interfaceWaitableFuture- Overrides:
getIdin 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
-
getHandler
public GlobalRequestFuture.ReplyHandler getHandler()
Retrieves theGlobalRequestFuture.ReplyHandlerof this future, if any.- Returns:
- the handler, or
nullif none was set
-
getBuffer
public Buffer getBuffer()
Obtains the replyBufferif the request was successful. If called afterDefaultSshFuture.isDone()istrue, a non-nullresult means the request was successful.- Returns:
- the
Buffer, ornullif 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, anullresult means the request did not fail.- Returns:
- a failure reason, or
nullif there isn't one or if the request did not fail
-
operationComplete
public void operationComplete(IoWriteFuture future)
- Specified by:
operationCompletein interfaceSshFutureListener<IoWriteFuture>
-
toString
public String toString()
- Overrides:
toStringin classDefaultSshFuture<GlobalRequestFuture>
-
-