public class ClientChannelPendingMessagesQueue extends AbstractLoggingBean implements SshFutureListener<OpenFuture>, Channel, ClientChannelHolder
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.| Modifier and Type | Field and Description |
|---|---|
protected DefaultOpenFuture |
completedFuture |
protected Deque<Map.Entry<Buffer,Consumer<? super Throwable>>> |
pendingQueue |
log| Constructor and Description |
|---|
ClientChannelPendingMessagesQueue(ClientChannel channel) |
| Modifier and Type | Method and Description |
|---|---|
protected int |
clearPendingQueue() |
void |
close() |
protected void |
flushPendingQueue() |
ClientChannel |
getClientChannel() |
OpenFuture |
getCompletedFuture() |
int |
handleIncomingMessage(Buffer buffer,
Consumer<? super Throwable> errHandler)
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.
|
boolean |
isOpen() |
protected boolean |
markClosed()
Marks the queue as closed
|
protected OpenFuture |
markCompletionException(Throwable err) |
protected OpenFuture |
markCompletionSuccessful() |
void |
operationComplete(OpenFuture future) |
String |
toString() |
protected void |
writeMessage(Buffer buffer,
Consumer<? super IOException> errHandler) |
getSimplifiedLoggerclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitvalidateListenergetChannelprotected final DefaultOpenFuture completedFuture
public ClientChannelPendingMessagesQueue(ClientChannel channel)
public ClientChannel getClientChannel()
getClientChannel in interface ClientChannelHolderClientChannel usedpublic OpenFuture getCompletedFuture()
OpenFuture that can be used to wait
for all internal pending messages to be flushed before actually
signaling that operation is completepublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ChannelIOExceptionprotected boolean markClosed()
true if was open and now is closedpublic int handleIncomingMessage(Buffer buffer, Consumer<? super Throwable> errHandler) throws IOException
buffer - The message BuffererrHandler - 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, if null and exception occurs it will be simple re-thrownIOException - If wrote the message directly, encountered an error and
no handler was provided.protected void writeMessage(Buffer buffer, Consumer<? super IOException> errHandler) throws IOException
IOExceptionpublic void operationComplete(OpenFuture future)
operationComplete in interface SshFutureListener<OpenFuture>protected void flushPendingQueue()
protected OpenFuture markCompletionSuccessful()
protected OpenFuture markCompletionException(Throwable err)
protected int clearPendingQueue()
Copyright © 2008–2020 The Apache Software Foundation. All rights reserved.