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 ClientChannel
protected final DefaultOpenFuture
private final AtomicBoolean
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected int
void
close()
protected void
int
handleIncomingMessage
(Buffer buffer, Consumer<? super Throwable> errHandler) Checks if the future is already open and manages the message handling accordingly:boolean
isOpen()
protected boolean
Marks the queue as closedprotected OpenFuture
protected OpenFuture
void
operationComplete
(OpenFuture future) Invoked when the operation associated with theSshFuture
has been completed even if you add the listener after the completion.toString()
protected void
writeMessage
(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, 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.client.channel.ClientChannelHolder
getChannel
-
Field Details
-
pendingQueue
-
completedFuture
-
clientChannel
-
open
-
-
Constructor Details
-
ClientChannelPendingMessagesQueue
-
-
Method Details
-
getClientChannel
- Specified by:
getClientChannel
in interfaceClientChannelHolder
- Returns:
- The underlying
ClientChannel
used
-
getCompletedFuture
- Returns:
- An internal
OpenFuture
that 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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceChannel
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
markClosed
protected boolean markClosed()Marks the queue as closed- Returns:
true
if 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 messageBuffer
errHandler
- The error handler to invoke it had to enqueue the message and was unsuccessful in writing it. Must be non-null
if future not open yet. Otherwise, ifnull
and 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:SshFutureListener
Invoked when the operation associated with theSshFuture
has been completed even if you add the listener after the completion.- Specified by:
operationComplete
in interfaceSshFutureListener<OpenFuture>
- Parameters:
future
- The sourceSshFuture
which called this callback.
-
flushPendingQueue
protected void flushPendingQueue() -
markCompletionSuccessful
-
markCompletionException
-
clearPendingQueue
protected int clearPendingQueue() -
toString
-