public class BufferedIoOutputStream extends AbstractInnerCloseable implements IoOutputStream
IoOutputStream
capable of queuing write requestsAbstractCloseable.State
Modifier and Type | Field and Description |
---|---|
protected int |
channelId |
protected AtomicReference<IoWriteFutureImpl> |
currentWrite |
protected Object |
id |
protected int |
maxPendingBytesCount |
protected Duration |
maxWaitForPendingWrites |
protected IoOutputStream |
out |
protected AtomicInteger |
pendingBytesCount |
protected AtomicReference<SshChannelBufferedOutputException> |
pendingException |
protected Queue<IoWriteFutureImpl> |
writes |
protected AtomicLong |
writtenBytesCount |
closeFuture, lock, state
log
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT
Constructor and Description |
---|
BufferedIoOutputStream(Object id,
int channelId,
IoOutputStream out,
int maxPendingBytesCount,
Duration maxWaitForPendingWrites) |
BufferedIoOutputStream(Object id,
int channelId,
IoOutputStream out,
PropertyResolver resolver) |
Modifier and Type | Method and Description |
---|---|
protected void |
finishWrite(IoWriteFutureImpl future,
int bufferSize) |
Object |
getId() |
protected Closeable |
getInnerCloseable() |
protected void |
startWriting() |
String |
toString() |
protected void |
waitForAvailableWriteSpace(int requiredSize) |
IoWriteFuture |
writePacket(Buffer buffer)
Encode and send the given buffer.
|
doCloseGracefully, doCloseImmediately
addCloseFutureListener, builder, close, isClosed, isClosing, preClose, removeCloseFutureListener
getSimplifiedLogger
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
protected final Object id
protected final int channelId
protected final int maxPendingBytesCount
protected final Duration maxWaitForPendingWrites
protected final IoOutputStream out
protected final AtomicInteger pendingBytesCount
protected final AtomicLong writtenBytesCount
protected final Queue<IoWriteFutureImpl> writes
protected final AtomicReference<IoWriteFutureImpl> currentWrite
protected final AtomicReference<SshChannelBufferedOutputException> pendingException
public BufferedIoOutputStream(Object id, int channelId, IoOutputStream out, PropertyResolver resolver)
public BufferedIoOutputStream(Object id, int channelId, IoOutputStream out, int maxPendingBytesCount, Duration maxWaitForPendingWrites)
public Object getId()
public IoWriteFuture writePacket(Buffer buffer) throws IOException
PacketWriter
writePacket
in interface PacketWriter
buffer
- the buffer to encode and send. NOTE: the buffer must not be touched
until the returned write future is completed.IoWriteFuture
that can be used to check when the packet has actually been sentIOException
- if an error occurred when encoding sending the packetprotected void waitForAvailableWriteSpace(int requiredSize) throws IOException
IOException
protected void startWriting() throws IOException
IOException
protected void finishWrite(IoWriteFutureImpl future, int bufferSize)
protected Closeable getInnerCloseable()
getInnerCloseable
in class AbstractInnerCloseable
Copyright © 2008–2022 The Apache Software Foundation. All rights reserved.