Package org.apache.sshd.client.channel
Class ClientChannelPendingMessagesQueue
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.client.channel.ClientChannelPendingMessagesQueue
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,EventListener,ClientChannelHolder,ChannelHolder,SshFutureListener<OpenFuture>,SshdEventListener
public class ClientChannelPendingMessagesQueue
extends AbstractLoggingBean
implements SshFutureListener<OpenFuture>, Channel, ClientChannelHolder
This is a specialized
SshFutureListener that is used to enqueue data that is sent while the channel is being
set-up, so that when it is established it will send them in the same order as they have been received.
It also serves as a "backstop" in case session is closed (normally) while the packets as still being
written.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ClientChannelprotected final DefaultOpenFutureprivate final AtomicBooleanFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected intvoidclose()protected voidinthandleIncomingMessage(Buffer buffer, Consumer<? super Throwable> errHandler) Checks if the future is already open and manages the message handling accordingly:booleanisOpen()protected booleanMarks the queue as closedprotected OpenFutureprotected OpenFuturevoidoperationComplete(OpenFuture future) Invoked when the operation associated with theSshFuturehas been completed even if you add the listener after the completion.toString()protected voidwriteMessage(Buffer buffer, Consumer<? super IOException> errHandler) 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, warnMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.client.channel.ClientChannelHolder
getChannel
-
Field Details
-
pendingQueue
-
completedFuture
-
clientChannel
-
open
-
-
Constructor Details
-
ClientChannelPendingMessagesQueue
-
-
Method Details
-
getClientChannel
- Specified by:
getClientChannelin interfaceClientChannelHolder- Returns:
- The underlying
ClientChannelused
-
getCompletedFuture
- Returns:
- An internal
OpenFuturethat can be used to wait for all internal pending messages to be flushed before actually signaling that operation is complete
-
isOpen
public boolean isOpen() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-
markClosed
protected boolean markClosed()Marks the queue as closed- Returns:
trueif was open and now is closed
-
handleIncomingMessage
public int handleIncomingMessage(Buffer buffer, Consumer<? super Throwable> errHandler) throws IOException Checks if the future is already open and manages the message handling accordingly:- If channel is not open yet, it enqueues the request
- If channel is open but there are still pending messages not yet written out, it will wait for them to be written (or exception signaled) before proceeding to write out the incoming message.
- Otherwise (i.e., channel is open and no pending messages yet) it will write the message to the underlying channel immediately.
- Parameters:
buffer- The messageBuffererrHandler- The error handler to invoke it had to enqueue the message and was unsuccessful in writing it. Must be non-nullif future not open yet. Otherwise, ifnulland exception occurs it will be simple re-thrown- Returns:
- The total number of still pending messages - zero if none and message was written (either immediately or after waiting for the pending ones to be written).
- Throws:
IOException- If wrote the message directly, encountered an error and no handler was provided.
-
writeMessage
protected void writeMessage(Buffer buffer, Consumer<? super IOException> errHandler) throws IOException - Throws:
IOException
-
operationComplete
Description copied from interface:SshFutureListenerInvoked when the operation associated with theSshFuturehas been completed even if you add the listener after the completion.- Specified by:
operationCompletein interfaceSshFutureListener<OpenFuture>- Parameters:
future- The sourceSshFuturewhich called this callback.
-
flushPendingQueue
protected void flushPendingQueue() -
markCompletionSuccessful
-
markCompletionException
-
clearPendingQueue
protected int clearPendingQueue() -
toString
-