Hi folks, I've just added a very interesting feature, which overlaps with org.apache.mina.filter.traffic. The difference if that it attaches to the new ThreadPoolExecutors - OrderedThreadPoolExecutor and UnorderedThreadPoolExecutor. You can specify an IoEventQueueHandler in the constructor. IoEventQueueHandler provides some hook methods for vetoing the event from getting into the queue and monitoring flow of events. IoEventQueueThrottle is the first implementation of IoEventQueueHandler. It is much simpler than org.apache.mina.filter.traffic classes because it interacts ThreadPoolExecutors directly. Please take a look into the source code:
http://svn.apache.org/viewvc/mina/trunk/core/src/main/java/org/apache/mina/filter/executor/IoEventQueueThrottle.java?view=markup As you can see from the source code, it doesn't use IoSession traffic mask operation; it just blocks on Executor.execute() and unblocks on notification. Trade-off of this simplicity is that there's no various scope type in threshold value, in contrast to ReadThrottleFilter. It will be more efficient and won't burden call stack depth at all instead, while fulfilling most people's demand. You can try the following code to test this feature: public class IoEventQueueThrottleTest { // Try to beat with the following command: // while true; do echo 1234567890; done | nc localhost 1234 public static void main(String[] args) throws Exception { SocketAcceptor acceptor = new NioSocketAcceptor(); acceptor.getFilterChain().addLast("executor", new ExecutorFilter( new UnorderedThreadPoolExecutor( 0, 16, 30, TimeUnit.SECONDS, new IoEventQueueThrottle()))); acceptor.setHandler(new IoHandlerAdapter() { @Override public void messageReceived(IoSession session, Object message) throws Exception { Thread.sleep(1000); } }); acceptor.setLocalAddress(new InetSocketAddress(1234)); acceptor.bind(); } } Any feed back is appreciated! Cheers, Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6
