users@grizzly.java.net

Performance test failing due to race condition problems

From: Simon Trudeau <strudeau_at_bluetreewireless.com>
Date: Fri, 7 Mar 2008 14:11:02 -0500

I am trying to concurrently connect to 2500 servers at a time using my
client application. Unfortunately, I run into all sorts of instability
issues:

 

After connecting my 1268th client (it may vary) to the server, I get the
following exception:

 

Exception in thread "pool-1-thread-10"
java.nio.channels.NotYetConnectedException

            at
com.sun.grizzly.TCPConnectorHandler.write(TCPConnectorHandler.java:387)

...

java.nio.channels.ClosedChannelException

            at sun.nio.ch.SocketChannelImpl.finishConnect(Unknown
Source)

            at
com.sun.grizzly.TCPConnectorHandler.finishConnect(TCPConnectorHandler.ja
va:565)

            at
client.BtNIOClient$Connector$ClientCallBackHandler.onConnect(BtNIOClient
.java:214)

 

Running the same test I obtain also:

 

After connecting my 1253th client (it may vary) to the server, I get the
following exception:

 

java.nio.channels.ClosedChannelException

            at sun.nio.ch.SocketChannelImpl.ensureWriteOpen(Unknown
Source)

            at sun.nio.ch.SocketChannelImpl.write(Unknown Source)

            at
com.sun.grizzly.TCPConnectorHandler.write(TCPConnectorHandler.java:403)

...

7-Mar-2008 1:48:04 PM com.sun.grizzly.TCPConnectorHandler
configureChannel

WARNING: setTcpNoDelay exception

java.net.SocketException: Connection reset by peer:
sun.nio.ch.Net.setIntOption

            at sun.nio.ch.Net.setIntOption0(Native Method)

            at sun.nio.ch.Net.setIntOption(Unknown Source)

            at sun.nio.ch.SocketChannelImpl$1.setInt(Unknown Source)

            at sun.nio.ch.SocketOptsImpl.setBoolean(Unknown Source)

            at sun.nio.ch.SocketOptsImpl$IP$TCP.noDelay(Unknown Source)

            at sun.nio.ch.OptionAdaptor.setTcpNoDelay(Unknown Source)

            at sun.nio.ch.SocketAdaptor.setTcpNoDelay(Unknown Source)

            at
com.sun.grizzly.TCPConnectorHandler.configureChannel(TCPConnectorHandler
.java:596)

            at
com.sun.grizzly.TCPConnectorHandler.finishConnect(TCPConnectorHandler.ja
va:567)

            at
client.BtNIOClient$Connector$ClientCallBackHandler.onConnect(BtNIOClient
.java:214)

            at
com.sun.grizzly.CallbackHandlerContextTask.doCall(CallbackHandlerContext
Task.java:66)

            at
com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.jav
a:57)

            at
com.sun.grizzly.util.WorkerThreadImpl.run(WorkerThreadImpl.java:179)

 

I also get for the same test

 

After connecting my 1253th client (it may vary) to the server, I get the
following exception:

 

Exception in thread "pool-1-thread-5" java.lang.IllegalStateException:
SelectorHandler not yet started

            at
com.sun.grizzly.TCPSelectorHandler.acquireConnectorHandler(TCPSelectorHa
ndler.java:778)

            at
client.BtNIOClient$Connector.initConnector(BtNIOClient.java:181)

 

What's weird is that it always happens around my 1250-1260 th client...

 

I am testing with both client and server using the same Controller.
Tests are ran on a dual core intel machine. You need to run the
performance test (ClientPerformanceTest.java performanceTest1()) a few
times to get the exceptions, they don't occur on each run... which is
weird but which is also consistent with the race condition problems I am
encountering.

 

I have attached my full source code with test to this mail so you can
run my test and maybe some of you might help me figure out what I did
wrong.

 

To run the test, just include on the classpath the latest
grizzly-framework and use java 6.

 

 

Thanks,

 

 

Simon