Netty 3.10.5.Final(build 2016/02/27)

程序包 org.jboss.netty.handler.traffic

Implementation of a Traffic Shaping Handler and Dynamic Statistics.

请参阅: 说明

程序包org.jboss.netty.handler.traffic的说明

Implementation of a Traffic Shaping Handler and Dynamic Statistics.


The main goal of this package is to allow 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:

Standard use could be as follow:



So in your application you will create your own TrafficShapingHandler and set the values to fit your needs.

XXXXXTrafficShapingHandler myHandler = new XXXXXTrafficShapingHandler(timer);

timer could be created using HashedWheelTimer and XXXXX could be either Global or Channel
pipeline.addLast("XXXXX_TRAFFIC_SHAPING", myHandler);
...
pipeline.addLast("MemoryExecutor",new ExecutionHandler(memoryAwareThreadPoolExecutor));

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 3.10.5.Final(build 2016/02/27)

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