[hornetq-commits] JBoss hornetq SVN: r8469 - in trunk/src/main/org/hornetq: integration/transports/netty and 1 other directory.

do-not-reply at jboss.org do-not-reply at jboss.org
Mon Nov 30 07:52:23 EST 2009


Author: jmesnil
Date: 2009-11-30 07:52:23 -0500 (Mon, 30 Nov 2009)
New Revision: 8469

Modified:
   trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
   trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java
Log:
fixed race condition in netty acceptor

* added workaround to avoid race condition in NettyAcceptor.pause()
  (until netty 3.2.x is integrated)
* removed sleep from RemotingService.stop()

Modified: trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java
===================================================================
--- trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java	2009-11-30 11:56:39 UTC (rev 8468)
+++ trunk/src/main/org/hornetq/core/remoting/server/impl/RemotingServiceImpl.java	2009-11-30 12:52:23 UTC (rev 8469)
@@ -225,21 +225,6 @@
          acceptor.pause();
       }
 
-      boolean containsNettyAcceptors = false;
-      for (Acceptor acceptor : acceptors)
-      {
-         if (acceptor.getClass().toString().contains("NettyAcceptor"))
-         {
-            containsNettyAcceptors = true;
-            break;
-         }
-      }
-      if (containsNettyAcceptors)
-      {     
-         // we sleep in case there are initializing connections which are in the thread pool
-         Thread.sleep(1000);
-      }
-
       synchronized (server)
       {
          for (ConnectionEntry entry : connections.values())

Modified: trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java
===================================================================
--- trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java	2009-11-30 11:56:39 UTC (rev 8468)
+++ trunk/src/main/org/hornetq/integration/transports/netty/NettyAcceptor.java	2009-11-30 12:52:23 UTC (rev 8469)
@@ -129,6 +129,8 @@
 
    private NotificationService notificationService;
 
+   private VirtualExecutorService bossExecutor;
+
    public NettyAcceptor(final Map<String, Object> configuration,
                         final BufferHandler handler,
                         final ConnectionLifeCycleListener listener,
@@ -225,7 +227,8 @@
          return;
       }
 
-      VirtualExecutorService virtualExecutor = new VirtualExecutorService(threadPool);
+      bossExecutor =  new VirtualExecutorService(threadPool);
+      VirtualExecutorService workerExecutor = new VirtualExecutorService(threadPool);
 
       if (useInvm)
       {
@@ -233,11 +236,11 @@
       }
       else if (useNio)
       {
-         channelFactory = new NioServerSocketChannelFactory(virtualExecutor, virtualExecutor);
+         channelFactory = new NioServerSocketChannelFactory(bossExecutor, workerExecutor);
       }
       else
       {
-         channelFactory = new OioServerSocketChannelFactory(virtualExecutor, virtualExecutor);
+         channelFactory = new OioServerSocketChannelFactory(bossExecutor, workerExecutor);
       }
       bootstrap = new ServerBootstrap(channelFactory);
 
@@ -445,6 +448,18 @@
             }
          }
       }
+      // TODO remove workaround when integrating Netty 3.2.x
+      // https://jira.jboss.org/jira/browse/NETTY-256
+      bossExecutor.shutdown();
+      try
+      {
+         
+         bossExecutor.awaitTermination(30, TimeUnit.SECONDS);
+      }
+      catch (InterruptedException e)
+      {
+         e.printStackTrace();
+      }
 
       paused = true;
    }



More information about the hornetq-commits mailing list