跳过导航链接
Netty 4.1.72.Final(2021/12/14)

程序包 io.netty.handler.traffic

Implementation of a Traffic Shaping Handler and Dynamic Statistics.

请参阅: 说明

程序包io.netty.handler.traffic的说明

Implementation of a Traffic Shaping Handler and Dynamic Statistics.

The main goal of this package is to allow you to shape the traffic (bandwidth limitation), but also to get statistics on how many bytes are read or written. Both functions can be active or inactive (traffic or statistics).

Two classes implement this behavior:

Both inbound and outbound traffic can be shaped independently. This is done by either passing in the desired limiting values to the constructors of both the Channel and Global traffic shaping handlers, or by calling the configure method on the AbstractTrafficShapingHandler. A value of 0 for either parameter indicates that there should be no limitation. This allows you to monitor the incoming and outgoing traffic without shaping.

To activate or deactivate the statistics, you can adjust the delay to a low (suggested not less than 200ms for efficiency reasons) or a high value (let say 24H in millisecond is huge enough to not get the problem) or even using 0 which means no computation will be done.

If you want to do anything with these statistics, just override the doAccounting method.
This interval can be changed either from the method configure in AbstractTrafficShapingHandler or directly using the method configure of TrafficCounter.

Note that a new ChannelTrafficShapingHandler must be created for each new channel, but only one GlobalTrafficShapingHandler must be created for all channels.

Note also that you can create different GlobalTrafficShapingHandler if you want to separate classes of channels (for instance either from business point of view or from bind address point of view).

跳过导航链接
Netty 4.1.72.Final(2021/12/14)

Copyright © 2021 即时通讯网(52im.net) - 即时通讯开发者社区. All rights reserved.