This is my output:
Listening on port 1234
Session Opened
Time for write:31 ms
Time for write:32 ms
My setup is:
Windows XP
Dual Core 1.66GHz
2GB RAM
I can certainly understand where you are coming from here. I am wondering
if over the course of 50,000 messages getting written to the client that
only 2 times is the write going over the determined time. I have always
thought that the precision of time for the JVM was not perfect. You could
probably get some people over at the java.util.concurrency mailing list to
agree and there are definitely some people that might offer solutions.
My first thought was that this might not be an issue with MINA's ability to
properly wait the properly specified amount of time as it is maybe just
additional time in calling methods. 11 and 12 milliseconds is not alot of
time. After looking at the code, I do not see any problems and in fact the
actual waiting method relies on Object.wait(long)
I am certain that none of this information will help your problem, but maybe
it will convince you that there is not necessarily a problem with the MINA
API.
that's my $.02
--Mark
On Jan 11, 2008 7:20 AM, Luis Filipe dos Santos Neves <[EMAIL PROTECTED]>
wrote:
> Mark wrote:
> > Does not sound like it is working as planned. Do you have a test
> program
> > that demonstrates this behavior?
>
> Yes. You can test the code below using netcat:
> nc -i 5 localhost 1234
>
>
> *****************************************************
>
> public class WriteRequestSnafuServer
> {
> private static final int PORT = 1234;
>
> public static void main(String[] args) throws Exception
> {
> SocketAcceptor acceptor = new
> NioSocketAcceptor(Runtime.getRuntime().availableProcessors()
> + 1);
>
> acceptor.setReuseAddress(true);
> DefaultIoFilterChainBuilder chain = acceptor.getFilterChain();
> WriteThrottleFilter writeThrottleFilter = new WriteThrottleFilter(
> WriteThrottlePolicy.BLOCK);
>
> chain.addLast("executor", new ExecutorFilter(Executors.newFixedThreadPool
> (16)));
>
> chain.addLast("writeThrottleFilter", writeThrottleFilter);
>
> acceptor.setHandler(new IoHandlerAdapter()
> {
>
> @Override
> public void sessionOpened(IoSession iosession) throws Exception
> {
> System.out.println("Session Opened");
> super.sessionOpened(iosession);
>
> for (int i = 0; i < 50000; i++)
> {
> IoBuffer wbuf = IoBuffer.wrap(("Message #" + i + ": The brown fox jumps
> over the lazy dog.\n").getBytes());
>
> long beginWrite = System.currentTimeMillis();
> WriteFuture wf = iosession.write(wbuf);
> wf.awaitUninterruptibly(10);
> long endWrite = System.currentTimeMillis();
> long duration = endWrite - beginWrite;
> if (duration > 20)
> {
> System.out.println("Time for write:" + duration + " ms");
> }
> }
> }
>
> @Override
> public void exceptionCaught(IoSession iosession, Throwable t) throws
> Exception
> {
> System.out.println(t.getMessage());
> }
>
> });
>
> // Bind
> acceptor.bind(new InetSocketAddress(PORT));
>
> System.out.println("Listening on port " + PORT);
> }
> }
>
> *****************************************************************
>
>
> --
> Luis Neves
>
--
--------------------------------
Talent hits a target no one else can hit; Genius hits a target no one else
can see.