directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trustin Lee" <trus...@gmail.com>
Subject Re: sessionCreated event doesn't fire
Date Thu, 21 Dec 2006 00:40:49 GMT
Please try to increase the number of the threads in the I/O thread pool.  If
you specified IO_THREADS in the constructor, the executor specified along
with that number should be able to allocate one more threads than it (i.e.
IO_THREADS + 1).

HTH,
Trustin

On 12/21/06, Luis Neves <luis.neves@co.sapo.pt> wrote:
>
> Hi all,
>
> Using the latest code from trunk I'm experiencing a somewhat strange
> behaviour.
> Running the code provided below and opening several telnet connections to
> the
> socket doesn't always print "sessionCreated()", this behaviour is more
> evident
> on windows but happens on linux also... can anyone confirm?
> Did something change in the way we must setup an SocketAcceptor?
>
> --
> Luis Neves
>
>
>
>
> Code below (beware wrapping):
>
>
> ********************************************************************************
>
> import java.net.InetSocketAddress;
> import java.util.concurrent.LinkedBlockingQueue;
> import java.util.concurrent.ThreadPoolExecutor;
> import java.util.concurrent.TimeUnit;
>
> import org.apache.mina.common.IoHandlerAdapter;
> import org.apache.mina.common.IoSession;
> import org.apache.mina.filter.executor.ExecutorFilter;
> import org.apache.mina.transport.socket.nio.SocketAcceptor;
>
> public class TestAcceptor
> {
> static final int PORT = 10007;
>
> static final int NCPU = Runtime.getRuntime().availableProcessors();
>
> static final int IO_THREADS = NCPU + 1;
>
> static final int EVENT_THREADS = 10;
>
> static final IoHandlerAdapter testHandler = new IoHandlerAdapter()
> {
>         @Override
>         public void sessionCreated(IoSession iosession)
>                         throws Exception
>         {
>                 System.out.println("sessionCreated()");
>         }
>
>         @Override
>         public void sessionClosed(IoSession iosession)
>         {
>                 System.out.println("sessionClosed()");
>         }
>
>         @Override
>         public void exceptionCaught(IoSession iosession,
>                         Throwable cause)
>         {
>                 System.out.println("exceptionCaught()");
>         }
> };
>
> public static void main(String[] args) throws Exception
> {
>         ThreadPoolExecutor ioExecutor = new ThreadPoolExecutor(
>                         IO_THREADS, IO_THREADS, 60, TimeUnit.SECONDS,
>                         new LinkedBlockingQueue<Runnable>());
>
>         SocketAcceptor acceptor = new SocketAcceptor(IO_THREADS,
>                         ioExecutor);
>
>         ThreadPoolExecutor eventExecutor = new ThreadPoolExecutor(
>                         EVENT_THREADS, EVENT_THREADS * NCPU, 60,
>                         TimeUnit.SECONDS, new
> LinkedBlockingQueue<Runnable>());
>
>         acceptor.getFilterChain().addLast("threadPool",
>                         new ExecutorFilter(eventExecutor));
>
>         acceptor.setReuseAddress(true);
>         acceptor.setLocalAddress(new InetSocketAddress(PORT));
>
>         acceptor.setHandler(testHandler);
>
>         acceptor.bind();
>         System.out.println("listening...");
>
> }
> }
>
>


-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41  4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4  455E 1C62 A7DC 0255 ECA6

Mime
View raw message