Top Description Inners Fields Constructors Methods
io.netty5.handler.traffic

public Class ChannelTrafficShapingHandler

extends AbstractTrafficShapingHandler
Class Inheritance
Imports
io.netty5.channel.ChannelHandlerContext, io.netty5.util.Resource, io.netty5.util.concurrent.Promise, java.util.ArrayDeque, java.util.concurrent.TimeUnit

This implementation of the AbstractTrafficShapingHandler is for channel traffic shaping, that is to say a per channel limitation of the bandwidth.

Note the index used in OutboundBuffer.setUserDefinedWritability(index, boolean) is 1.

The general use should be as follow:

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final ArrayDeque<ChannelTrafficShapingHandler.ToSend>
private long
Inherited from io.netty5.handler.traffic.AbstractTrafficShapingHandler:
CHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEXcheckIntervalDEFAULT_CHECK_INTERVALDEFAULT_MAX_SIZEDEFAULT_MAX_TIMEGLOBAL_DEFAULT_USER_DEFINED_WRITABILITY_INDEXGLOBALCHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEXmaxTimemaxWriteDelaymaxWriteSizeMINIMAL_WAITREAD_SUSPENDEDREOPEN_TASKtrafficCounteruserDefinedWritabilityIndex

Constructor Summary

AccessConstructor and Description
public
ChannelTrafficShapingHandler(long
0 or a limit in bytes/s
writeLimit
,
long
0 or a limit in bytes/s
readLimit
,
long
The delay between two computations of performances for channels or 0 if no stats are to be computed.
checkInterval
,
long
The maximum delay to wait in case of traffic excess.
maxTime
)

Create a new instance.

public
ChannelTrafficShapingHandler(long
0 or a limit in bytes/s
writeLimit
,
long
0 or a limit in bytes/s
readLimit
,
long
The delay between two computations of performances for channels or 0 if no stats are to be computed.
checkInterval
)

Create a new instance using default max time as delay allowed value of 15000 ms.

public
ChannelTrafficShapingHandler(long
0 or a limit in bytes/s
writeLimit
,
long
0 or a limit in bytes/s
readLimit
)

Create a new instance using default Check Interval value of 1000 ms and max time as delay allowed value of 15000 ms.

public
ChannelTrafficShapingHandler(long
The delay between two computations of performances for channels or 0 if no stats are to be computed.
checkInterval
)

Create a new instance using default max time as delay allowed value of 15000 ms and no limit.

Method Summary

Modifier and TypeMethod and Description
public void
handlerAdded(ChannelHandlerContext ctx)

Overrides default io.netty5.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.
public void
handlerRemoved(ChannelHandlerContext ctx)

Overrides io.netty5.handler.traffic.AbstractTrafficShapingHandler.handlerRemoved.

Overrides default io.netty5.channel.ChannelHandler.handlerRemoved.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.
public long

Returns:

current size in bytes of the write buffer.
queueSize
()

private void
sendAllValid(final ChannelHandlerContext ctx, final long now)

pack-priv void
submitWrite(final ChannelHandlerContext ctx, final Object msg, final long size, final long delay, final long now, final Promise<Void> promise)

Implements abstract io.netty5.handler.traffic.AbstractTrafficShapingHandler.submitWrite.

Inherited from io.netty5.handler.traffic.AbstractTrafficShapingHandler:
calculateSizechannelReadchannelRegisteredcheckWaitReadTimecheckWriteSuspendconfigureconfigureconfiguredoAccountinggetCheckIntervalgetMaxTimeWaitgetMaxWriteDelaygetMaxWriteSizegetReadLimitgetWriteLimitinformReadOperationisHandlerActivereadreleaseReadSuspendedreleaseWriteSuspendedsetCheckIntervalsetMaxTimeWaitsetMaxWriteDelaysetMaxWriteSizesetReadLimitsetTrafficCountersetUserDefinedWritabilitysetWriteLimitsubmitWritetoStringtrafficCounteruserDefinedWritabilityIndexwrite

Field Detail

messagesQueueback to summary
private final ArrayDeque<ChannelTrafficShapingHandler.ToSend> messagesQueue
queueSizeback to summary
private long queueSize

Constructor Detail

ChannelTrafficShapingHandlerback to summary
public ChannelTrafficShapingHandler(long writeLimit, long readLimit, long checkInterval, long maxTime)

Create a new instance.

Parameters
writeLimit:long

0 or a limit in bytes/s

readLimit:long

0 or a limit in bytes/s

checkInterval:long

The delay between two computations of performances for channels or 0 if no stats are to be computed.

maxTime:long

The maximum delay to wait in case of traffic excess.

ChannelTrafficShapingHandlerback to summary
public ChannelTrafficShapingHandler(long writeLimit, long readLimit, long checkInterval)

Create a new instance using default max time as delay allowed value of 15000 ms.

Parameters
writeLimit:long

0 or a limit in bytes/s

readLimit:long

0 or a limit in bytes/s

checkInterval:long

The delay between two computations of performances for channels or 0 if no stats are to be computed.

ChannelTrafficShapingHandlerback to summary
public ChannelTrafficShapingHandler(long writeLimit, long readLimit)

Create a new instance using default Check Interval value of 1000 ms and max time as delay allowed value of 15000 ms.

Parameters
writeLimit:long

0 or a limit in bytes/s

readLimit:long

0 or a limit in bytes/s

ChannelTrafficShapingHandlerback to summary
public ChannelTrafficShapingHandler(long checkInterval)

Create a new instance using default max time as delay allowed value of 15000 ms and no limit.

Parameters
checkInterval:long

The delay between two computations of performances for channels or 0 if no stats are to be computed.

Method Detail

handlerAddedback to summary
public void handlerAdded(ChannelHandlerContext ctx) throws Exception

Overrides default io.netty5.channel.ChannelHandler.handlerAdded.

Doc from io.netty5.channel.ChannelHandler.handlerAdded.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

Annotations
@Override
handlerRemovedback to summary
public void handlerRemoved(ChannelHandlerContext ctx) throws Exception

Overrides io.netty5.handler.traffic.AbstractTrafficShapingHandler.handlerRemoved.

Overrides default io.netty5.channel.ChannelHandler.handlerRemoved.

Doc from io.netty5.channel.ChannelHandler.handlerRemoved.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.

Annotations
@Override
queueSizeback to summary
public long queueSize()
Returns:long

current size in bytes of the write buffer.

sendAllValidback to summary
private void sendAllValid(final ChannelHandlerContext ctx, final long now)
submitWriteback to summary
pack-priv void submitWrite(final ChannelHandlerContext ctx, final Object msg, final long size, final long delay, final long now, final Promise<Void> promise)

Implements abstract io.netty5.handler.traffic.AbstractTrafficShapingHandler.submitWrite.

Annotations
@Override
io.netty5.handler.traffic back to summary

private final Class ChannelTrafficShapingHandler.ToSend

extends Object
Class Inheritance
  • java.lang.Object
  • io.netty5.handler.traffic.ChannelTrafficShapingHandler.ToSend

Field Summary

Modifier and TypeField and Description
pack-priv final Promise<Void>
pack-priv final long
pack-priv final Object

Constructor Summary

AccessConstructor and Description
private
ToSend(final long delay, final Object toSend, final Promise<Void> promise)

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

promiseback to summary
pack-priv final Promise<Void> promise
relativeTimeActionback to summary
pack-priv final long relativeTimeAction
toSendback to summary
pack-priv final Object toSend

Constructor Detail

ToSendback to summary
private ToSend(final long delay, final Object toSend, final Promise<Void> promise)