Hey,

Even after adding my defensive code to my decoder, and using ExecutorFilter I still find that only 16 threads are working on my MyConnectionHandler. All thread named AnonymousIoService-1 thru AnonymousIoService-16.

How can I increase the thread pool working on MyConnectionHandler?


thanks.

Jigar Gosar wrote:
Hey,

I am new to mina, and using version 1.x

This is my code.

       ByteBuffer.setUseDirectBuffers(false);
       ByteBuffer.setAllocator(new SimpleByteBufferAllocator());

IoAcceptor acceptor = new SocketAcceptor(4, Executors.newCachedThreadPool());

       IoServiceConfig acceptorConfig = acceptor.getDefaultConfig();
       acceptorConfig.setThreadModel(ThreadModel.MANUAL);
             SocketAcceptorConfig cfg = new SocketAcceptorConfig();
acceptor.getFilterChain().addLast("xml", new ProtocolCodecFilter(new XMLCodecFactory())); acceptor.getFilterChain().addLast("threadPool", new ExecutorFilter(Executors.newCachedThreadPool())); acceptor.bind(new InetSocketAddress(PORT), new MyConnectionHandler(), cfg);

While debugging I found that there are only 16 threads working on MyConnectionHandler. Hence I added Executor filter as suggested in the tutorial. The moment I started using Executor Filter, my xml CumulativeProtocolDecoder started blowing up.

protected boolean doDecode(IoSession session, ByteBuffer in, ProtocolDecoderOutput out)
           throws Exception {

       Object parser = session.getAttribute("parser");
// parser is now null, causing NPE's to be thrown, session.isConnected() == false

       ....
   }

I am setting the parser parameter in my IoHandler's sessionOpened method. But why is closed session being passed to decoder? only when using executor filter.


Can some one explain how the default 16 threads for my IO handler and this Executor Filter work together, I am very confused.

Should I put code like following in my CumulativeProtocolDecoder

if(!session.isConnected()){
System.out.println("Why is doDecode called with closed session??");
           return false;                  }

Thanks.



--
jigar gosar
bottoms up, pun intended :)
http://jigar.org/blog
http://simplegtd.com
http://madcow.tumblr.com
http://del.icio.us/cujigar


Reply via email to