[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Re: Another DeadLock, something around InVM
clebert.suconic@jboss.com
do-not-reply at jboss.com
Wed Mar 4 15:06:49 EST 2009
I was trying to replicate this on a test.
I came up with a test, but it hangs with a different thread dump.
it would probably be a good test.
It starts a bunch of threads, all of them missing pings, and all of them closing the session.
I'm playing with a random wait between the createSession and close:
Thread.sleep(PING_INTERVAL * (RandomUtil.randomPositiveInt() % 3));
So, I could eventually have session.close and failure detection being called at the same time.
WDYT ? :
| /*
| * Test the client triggering failure due to no pong received in time
| */
| public void testMultiThreadOpenAndCloses() throws Exception
| {
| final TransportConfiguration transportConfig = new TransportConfiguration("org.jboss.messaging.integration.transports.netty.NettyConnectorFactory");
|
| Interceptor noPongInterceptor = new Interceptor()
| {
| public boolean intercept(final Packet packet, final RemotingConnection conn) throws MessagingException
| {
| log.info("In interceptor, packet is " + packet.getType());
| if (packet.getType() == PacketImpl.PING)
| {
| log.info("Ignoring Ping packet.. it will be dropped");
| return false;
| }
| else
| {
| return true;
| }
| }
| };
|
| messagingService.getServer().getRemotingService().addInterceptor(noPongInterceptor);
| final int numberOfSessions = 30;
| final int numberOfThreads = 8;
| final CountDownLatch flagStart = new CountDownLatch(1);
| final CountDownLatch flagAligned = new CountDownLatch(numberOfThreads);
|
| final ClientSessionFactory csf = new ClientSessionFactoryImpl(transportConfig,
| null,
| DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME,
| PING_INTERVAL,
| (long)(PING_INTERVAL * 1.5),
| DEFAULT_CALL_TIMEOUT,
| DEFAULT_CONSUMER_WINDOW_SIZE,
| DEFAULT_CONSUMER_MAX_RATE,
| DEFAULT_SEND_WINDOW_SIZE,
| DEFAULT_PRODUCER_MAX_RATE,
| DEFAULT_MIN_LARGE_MESSAGE_SIZE,
| DEFAULT_BLOCK_ON_ACKNOWLEDGE,
| DEFAULT_BLOCK_ON_NON_PERSISTENT_SEND,
| DEFAULT_BLOCK_ON_PERSISTENT_SEND,
| DEFAULT_AUTO_GROUP,
| DEFAULT_MAX_CONNECTIONS,
| DEFAULT_PRE_ACKNOWLEDGE,
| DEFAULT_ACK_BATCH_SIZE,
| DEFAULT_RETRY_INTERVAL,
| DEFAULT_RETRY_INTERVAL_MULTIPLIER,
| DEFAULT_MAX_RETRIES_BEFORE_FAILOVER,
| DEFAULT_MAX_RETRIES_AFTER_FAILOVER);
|
| class LocalThread extends Thread
| {
| Throwable failure;
|
| @Override
| public void run()
| {
| try
| {
| // Start all at once to make concurrency worst
| flagAligned.countDown();
| flagStart.await();
| for (int i = 0; i < numberOfSessions; i++)
| {
|
| ClientSession session = csf.createSession(false, false, false);
|
| Thread.sleep(PING_INTERVAL * (RandomUtil.randomPositiveInt() % 3));
|
| session.close();
| }
| }
| catch (Throwable e)
| {
| failure = e;
| }
| }
| };
|
| LocalThread threads[] = new LocalThread[numberOfThreads];
|
| for (int i = 0; i < numberOfThreads; i++)
| {
| threads = new LocalThread();
| threads.start();
| }
|
| flagAligned.await();
| flagStart.countDown();
|
| Throwable e = null;
| for (LocalThread t : threads)
| {
| t.join();
| if (t.failure != null)
| {
| e = t.failure;
| }
| }
|
| if (e != null)
| {
| throw new Exception("Test Failed", e);
| }
|
| }
|
|
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4215008#4215008
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4215008
More information about the jboss-dev-forums
mailing list