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:
|
boolean |
isOpen() |
protected boolean |
markClosed()
Marks the queue as closed
|
protected OpenFuture |
markCompletionException(Throwable err) |
protected OpenFuture |
markCompletionSuccessful() |
void |
operationComplete(OpenFuture future)
Invoked when the operation associated with the
SshFuture
has been completed even if you add the listener after the completion. |
String |
toString() |
protected void |
writeMessage(Buffer buffer,
Consumer<? super IOException> errHandler) |
getSimplifiedLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
validateListener
getChannel
protected final DefaultOpenFuture completedFuture
public ClientChannelPendingMessagesQueue(ClientChannel channel)
public ClientChannel getClientChannel()
getClientChannel
in interface ClientChannelHolder
ClientChannel
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 Closeable
close
in interface AutoCloseable
close
in interface Channel
IOException
protected boolean markClosed()
true
if was open and now is closedpublic int handleIncomingMessage(Buffer buffer, Consumer<? super Throwable> errHandler) throws IOException
buffer
- The message Buffer
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, 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
IOException
public void operationComplete(OpenFuture future)
SshFutureListener
SshFuture
has been completed even if you add the listener after the completion.operationComplete
in interface SshFutureListener<OpenFuture>
future
- The source SshFuture
which called this
callback.protected void flushPendingQueue()
protected OpenFuture markCompletionSuccessful()
protected OpenFuture markCompletionException(Throwable err)
protected int clearPendingQueue()
Copyright © 2008–2022 The Apache Software Foundation. All rights reserved.