Class ThrottlingChannelStreamWriter
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.contrib.common.channel.throttle.ThrottlingChannelStreamWriter
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,java.nio.channels.Channel,java.util.EventListener,org.apache.sshd.common.channel.throttle.ChannelStreamWriter,org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.io.IoWriteFuture>,org.apache.sshd.common.util.SshdEventListener
public class ThrottlingChannelStreamWriter extends org.apache.sshd.common.util.logging.AbstractLoggingBean implements org.apache.sshd.common.channel.throttle.ChannelStreamWriter, org.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.io.IoWriteFuture>AChannelStreamWriterdelegate implementation that "throttles" the output by having a limit on the outstanding packets that have not been sent yet. ThewritePacketimplementation make sure that the limit has not been exceeded - if so, then it waits until pending packets have been successfully sent before sending the next packet. Note:closingthe throttler does not close the delegate writer
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.atomic.AtomicIntegeravailableCountprivate org.apache.sshd.common.channel.throttle.ChannelStreamWriterdelegatestatic org.apache.sshd.common.Property<java.lang.Integer>MAX_PEND_COUNTMax.private intmaxPendingPacketsprivate longmaxWaitprivate java.util.concurrent.atomic.AtomicBooleanopenstatic org.apache.sshd.common.Property<java.time.Duration>WAIT_TIMETimeout (seconds) for throttling packet writer to wait for pending packets send
-
Constructor Summary
Constructors Constructor Description ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.Channel channel)ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, long maxWait)ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, java.time.Duration maxWait)ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, java.util.concurrent.TimeUnit waitUnit, long waitCount)ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, org.apache.sshd.common.PropertyResolver resolver)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()intgetAvailablePacketsCount()org.apache.sshd.common.channel.throttle.ChannelStreamWritergetDelegate()intgetMaxPendingPackets()longgetMaxWait()booleanisOpen()voidoperationComplete(org.apache.sshd.common.io.IoWriteFuture future)java.lang.StringtoString()org.apache.sshd.common.io.IoWriteFuturewriteData(org.apache.sshd.common.util.buffer.Buffer buffer)
-
-
-
Field Detail
-
WAIT_TIME
public static final org.apache.sshd.common.Property<java.time.Duration> WAIT_TIME
Timeout (seconds) for throttling packet writer to wait for pending packets send
-
MAX_PEND_COUNT
public static final org.apache.sshd.common.Property<java.lang.Integer> MAX_PEND_COUNT
Max. pending packets count
-
delegate
private final org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate
-
maxPendingPackets
private final int maxPendingPackets
-
maxWait
private final long maxWait
-
open
private final java.util.concurrent.atomic.AtomicBoolean open
-
availableCount
private final java.util.concurrent.atomic.AtomicInteger availableCount
-
-
Constructor Detail
-
ThrottlingChannelStreamWriter
public ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.Channel channel)
-
ThrottlingChannelStreamWriter
public ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, org.apache.sshd.common.PropertyResolver resolver)
-
ThrottlingChannelStreamWriter
public ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, java.util.concurrent.TimeUnit waitUnit, long waitCount)
-
ThrottlingChannelStreamWriter
public ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, java.time.Duration maxWait)
-
ThrottlingChannelStreamWriter
public ThrottlingChannelStreamWriter(org.apache.sshd.common.channel.throttle.ChannelStreamWriter delegate, int maxPendingPackets, long maxWait)
-
-
Method Detail
-
getDelegate
public org.apache.sshd.common.channel.throttle.ChannelStreamWriter getDelegate()
-
getMaxPendingPackets
public int getMaxPendingPackets()
-
getAvailablePacketsCount
public int getAvailablePacketsCount()
-
getMaxWait
public long getMaxWait()
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
writeData
public org.apache.sshd.common.io.IoWriteFuture writeData(org.apache.sshd.common.util.buffer.Buffer buffer) throws java.io.IOException- Specified by:
writeDatain interfaceorg.apache.sshd.common.channel.throttle.ChannelStreamWriter- Throws:
java.io.IOException
-
operationComplete
public void operationComplete(org.apache.sshd.common.io.IoWriteFuture future)
- Specified by:
operationCompletein interfaceorg.apache.sshd.common.future.SshFutureListener<org.apache.sshd.common.io.IoWriteFuture>
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-