directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Luis Neves <luis.ne...@co.sapo.pt>
Subject sessionCreated event doesn't fire
Date Wed, 20 Dec 2006 19:16:28 GMT
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...");

}
}


Mime
View raw message