Repository: activemq-artemis
Updated Branches:
  refs/heads/master e40a5ead4 -> d7d494e8f


ARTEMIS-426 - java.lang.IllegalStateException: AMQ119116: Netty Acceptor 
unavailable

also related to https://issues.apache.org/jira/browse/ARTEMIS-416

https://issues.apache.org/jira/browse/ARTEMIS-426


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/a3962d6d
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/a3962d6d
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/a3962d6d

Branch: refs/heads/master
Commit: a3962d6d26dac900f9d6eeae1fa4d2514a3b8908
Parents: e40a5ea
Author: Andy Taylor <[email protected]>
Authored: Tue Mar 1 14:16:34 2016 +0000
Committer: Andy Taylor <[email protected]>
Committed: Tue Mar 1 14:17:41 2016 +0000

----------------------------------------------------------------------
 .../core/client/impl/ClientSessionFactoryImpl.java  | 16 +++++++++++-----
 .../core/remoting/impl/netty/NettyConnector.java    |  1 +
 .../core/remoting/server/RemotingService.java       |  5 +++++
 .../remoting/server/impl/RemotingServiceImpl.java   | 11 +++++++++++
 4 files changed, 28 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a3962d6d/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
----------------------------------------------------------------------
diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
index 0803782..0e04387 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionFactoryImpl.java
@@ -516,6 +516,11 @@ public class ClientSessionFactoryImpl implements 
ClientSessionFactoryInternal, C
          // this is just a debug, since an interrupt is an expected event (in 
case of a shutdown)
          ActiveMQClientLogger.LOGGER.debug(e1.getMessage(), e1);
       }
+      catch (Throwable t) {
+         //for anything else just close so clients are un blocked
+         close();
+         throw t;
+      }
    }
 
    /**
@@ -902,18 +907,19 @@ public class ClientSessionFactoryImpl implements 
ClientSessionFactoryInternal, C
 
             //we check if we can actually connect.
             // we do it here as to receive the reply connection has to be not 
null
+            //make sure to reset this.connection == null
             if (connection != null && liveNodeID != null) {
                try {
                   if (!clientProtocolManager.checkForFailover(liveNodeID)) {
                      connection.destroy();
-                     connection = null;
+                     this.connection = null;
+                     return null;
                   }
                }
                catch (ActiveMQException e) {
-                  if (connection != null) {
-                     connection.destroy();
-                     connection = null;
-                  }
+                  connection.destroy();
+                  this.connection = null;
+                  return null;
                }
             }
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a3962d6d/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
----------------------------------------------------------------------
diff --git 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
index 355202f..6853b79 100644
--- 
a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
+++ 
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyConnector.java
@@ -665,6 +665,7 @@ public class NettyConnector extends AbstractConnector {
                ch.writeAndFlush(request);
 
                if (!httpUpgradeHandler.awaitHandshake()) {
+                  ch.close().awaitUninterruptibly();
                   return null;
                }
             }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a3962d6d/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/RemotingService.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/RemotingService.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/RemotingService.java
index 6079be4..631a71a 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/RemotingService.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/RemotingService.java
@@ -77,6 +77,11 @@ public interface RemotingService {
    void pauseAcceptors();
 
    /**
+    * Pauses the acceptors so that no more connections can be made to the 
server
+    */
+   boolean isPaused();
+
+   /**
     * Freezes and then disconnects all connections except the given one and 
tells the client where else
     * it might connect (only applicable if server is in a cluster and uses 
scaleDown-on-failover=true).
     *

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/a3962d6d/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
----------------------------------------------------------------------
diff --git 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
index ba3d0b0..d2cde4b 100644
--- 
a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
+++ 
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java
@@ -113,6 +113,8 @@ public class RemotingServiceImpl implements 
RemotingService, ServerConnectionLif
 
    private ServiceRegistry serviceRegistry;
 
+   private boolean paused = false;
+
    // Static --------------------------------------------------------
 
    // Constructors --------------------------------------------------
@@ -192,6 +194,8 @@ public class RemotingServiceImpl implements 
RemotingService, ServerConnectionLif
          return;
       }
 
+      paused = false;
+
       // The remoting service maintains it's own thread pool for handling 
remoting traffic
       // If OIO each connection will have it's own thread
       // If NIO these are capped at nio-remoting-threads which defaults to num 
cores * 3
@@ -316,6 +320,8 @@ public class RemotingServiceImpl implements 
RemotingService, ServerConnectionLif
       if (!started)
          return;
 
+      paused = true;
+
       for (Acceptor acceptor : acceptors.values()) {
          try {
             acceptor.pause();
@@ -327,6 +333,11 @@ public class RemotingServiceImpl implements 
RemotingService, ServerConnectionLif
    }
 
    @Override
+   public synchronized boolean isPaused() {
+      return paused;
+   }
+
+   @Override
    public synchronized void freeze(final String scaleDownNodeID, final 
CoreRemotingConnection connectionToKeepOpen) {
       if (!started)
          return;

Reply via email to