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:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,Closeable,IoOutputStream
public class BufferedIoOutputStream extends AbstractInnerCloseable implements IoOutputStream
AnIoOutputStreamcapable 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 intchannelIdprotected java.util.concurrent.atomic.AtomicReference<IoWriteFutureImpl>currentWriteprotected java.lang.Objectidprotected intmaxPendingBytesCountprotected java.time.DurationmaxWaitForPendingWritesprotected IoOutputStreamoutprotected java.util.concurrent.atomic.AtomicIntegerpendingBytesCountprotected java.util.concurrent.atomic.AtomicReference<SshChannelBufferedOutputException>pendingExceptionprotected java.util.Queue<IoWriteFutureImpl>writesprotected java.util.concurrent.atomic.AtomicLongwrittenBytesCount-
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
-
-
Constructor Summary
Constructors Constructor Description BufferedIoOutputStream(java.lang.Object id, int channelId, IoOutputStream out, int maxPendingBytesCount, java.time.Duration maxWaitForPendingWrites)BufferedIoOutputStream(java.lang.Object id, int channelId, IoOutputStream out, PropertyResolver resolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidfinishWrite(IoWriteFutureImpl future, int bufferSize)java.lang.ObjectgetId()protected CloseablegetInnerCloseable()protected voidstartWriting()java.lang.StringtoString()protected voidwaitForAvailableWriteSpace(int requiredSize)IoWriteFuturewriteBuffer(Buffer buffer)Write 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
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.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListener
-
-
-
-
Field Detail
-
id
protected final java.lang.Object id
-
channelId
protected final int channelId
-
maxPendingBytesCount
protected final int maxPendingBytesCount
-
maxWaitForPendingWrites
protected final java.time.Duration maxWaitForPendingWrites
-
out
protected final IoOutputStream out
-
pendingBytesCount
protected final java.util.concurrent.atomic.AtomicInteger pendingBytesCount
-
writtenBytesCount
protected final java.util.concurrent.atomic.AtomicLong writtenBytesCount
-
writes
protected final java.util.Queue<IoWriteFutureImpl> writes
-
currentWrite
protected final java.util.concurrent.atomic.AtomicReference<IoWriteFutureImpl> currentWrite
-
pendingException
protected final java.util.concurrent.atomic.AtomicReference<SshChannelBufferedOutputException> pendingException
-
-
Constructor Detail
-
BufferedIoOutputStream
public BufferedIoOutputStream(java.lang.Object id, int channelId, IoOutputStream out, PropertyResolver resolver)
-
BufferedIoOutputStream
public BufferedIoOutputStream(java.lang.Object id, int channelId, IoOutputStream out, int maxPendingBytesCount, java.time.Duration maxWaitForPendingWrites)
-
-
Method Detail
-
getId
public java.lang.Object getId()
-
writeBuffer
public IoWriteFuture writeBuffer(Buffer buffer) throws java.io.IOException
Description copied from interface:IoOutputStreamWrite the given buffer.- Specified by:
writeBufferin interfaceIoOutputStream- Parameters:
buffer- the data to write. NOTE: the buffer must not be touched until the returned write future is completed.- Returns:
- An
IoWriteFuturethat can be used to check when the data has actually been written. - Throws:
java.io.IOException- if an error occurred when writing the data
-
waitForAvailableWriteSpace
protected void waitForAvailableWriteSpace(int requiredSize) throws java.io.IOException- Throws:
java.io.IOException
-
startWriting
protected void startWriting() throws java.io.IOException- Throws:
java.io.IOException
-
finishWrite
protected void finishWrite(IoWriteFutureImpl future, int bufferSize)
-
getInnerCloseable
protected Closeable getInnerCloseable()
- Specified by:
getInnerCloseablein classAbstractInnerCloseable
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-