Package org.jboss.netty.handler.traffic

Implementation of a Traffic Shaping Handler and Dynamic Statistics.

See: Description

Package org.jboss.netty.handler.traffic Description

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).

Copyright © 2008-2013 The Netty Project. All Rights Reserved.