From 82d8d8192e691abba345437db8a9d06ac2821774 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Br=C3=A9gier?= Date: Sun, 20 May 2012 11:27:20 +0300 Subject: [PATCH] Change Executor to Timer from Netty, in reference to Issue #345 --- .../netty/handler/traffic/package-info.java | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/traffic/package-info.java b/src/main/java/org/jboss/netty/handler/traffic/package-info.java index 25321804cb..50ed87d3d5 100644 --- a/src/main/java/org/jboss/netty/handler/traffic/package-info.java +++ b/src/main/java/org/jboss/netty/handler/traffic/package-info.java @@ -17,26 +17,28 @@ /** * 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:

@@ -60,27 +62,27 @@ * [Global or per Channel] [Write or Read] Limitation in byte/s.
* A value of 0 * stands for no limitation, so the traffic shaping is deactivate (on what you specified).
- * You can either change those values with the method configure in {@link org.jboss.netty.handler.traffic.AbstractTrafficShapingHandler}.
+ * You can either change those values with the method configure in {@link AbstractTrafficShapingHandler}.
*
* *
  • 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 this statistics, just override the doAccounting method.
    - * This interval can be changed either from the method configure in {@link org.jboss.netty.handler.traffic.AbstractTrafficShapingHandler} - * or directly using the method configure of {@link org.jboss.netty.handler.traffic.TrafficCounter}.

    + * This interval can be changed either from the method configure in {@link AbstractTrafficShapingHandler} + * or directly using the method configure of {@link TrafficCounter}.

    * *



    * *

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

    - * XXXXXTrafficShapingHandler myHandler = new XXXXXTrafficShapingHandler(executor);

    - * where executor could be created using Executors.newCachedThreadPool(); and XXXXX could be either + * 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 {@link org.jboss.netty.handler.traffic.ChannelTrafficShapingHandler} must be created for each new channel, - * but only one {@link org.jboss.netty.handler.traffic.GlobalTrafficShapingHandler} must be created for all channels.

    + *

    Note that a new {@link ChannelTrafficShapingHandler} must be created for each new channel, + * but only one {@link 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).