Package org.apache.sshd.common.channel
Class BufferedIoOutputStream
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.common.util.closeable.IoBaseCloseable
-
- org.apache.sshd.common.util.closeable.AbstractCloseable
-
- org.apache.sshd.common.util.closeable.AbstractInnerCloseable
-
- org.apache.sshd.common.channel.BufferedIoOutputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Channel
,Closeable
,IoOutputStream
,PacketWriter
public class BufferedIoOutputStream extends AbstractInnerCloseable implements IoOutputStream
AnIoOutputStream
capable of queuing write requests
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
AbstractCloseable.State
-
-
Field Summary
Fields Modifier and Type Field Description protected AtomicReference<IoWriteFutureImpl>
currentWrite
protected Object
id
protected IoOutputStream
out
protected Queue<IoWriteFutureImpl>
writes
-
Fields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, state
-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
Fields inherited from interface org.apache.sshd.common.Closeable
CLOSE_WAIT_TIMEOUT, DEFAULT_CLOSE_WAIT_TIMEOUT
-
-
Constructor Summary
Constructors Constructor Description BufferedIoOutputStream(Object id, IoOutputStream out)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Object
getId()
protected Closeable
getInnerCloseable()
protected void
startWriting()
String
toString()
IoWriteFuture
writePacket(Buffer buffer)
Encode and send the given buffer.-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractInnerCloseable
doCloseGracefully, doCloseImmediately
-
Methods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, preClose, removeCloseFutureListener
-
Methods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
getSimplifiedLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
-
-
-
Field Detail
-
out
protected final IoOutputStream out
-
writes
protected final Queue<IoWriteFutureImpl> writes
-
currentWrite
protected final AtomicReference<IoWriteFutureImpl> currentWrite
-
id
protected final Object id
-
-
Constructor Detail
-
BufferedIoOutputStream
public BufferedIoOutputStream(Object id, IoOutputStream out)
-
-
Method Detail
-
getId
public Object getId()
-
writePacket
public IoWriteFuture writePacket(Buffer buffer) throws IOException
Description copied from interface:PacketWriter
Encode and send the given buffer. Note: for session packets the buffer has to have 5 bytes free at the beginning to allow the encoding to take place. Also, the write position of the buffer has to be set to the position of the last byte to write.- Specified by:
writePacket
in interfacePacketWriter
- Parameters:
buffer
- the buffer to encode and send. NOTE: the buffer must not be touched until the returned write future is completed.- Returns:
- An
IoWriteFuture
that can be used to check when the packet has actually been sent - Throws:
IOException
- if an error occurred when encoding sending the packet
-
startWriting
protected void startWriting() throws IOException
- Throws:
IOException
-
getInnerCloseable
protected Closeable getInnerCloseable()
- Specified by:
getInnerCloseable
in classAbstractInnerCloseable
-
-