You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2019/07/18 20:28:22 UTC

[activemq-artemis] branch master updated (4d8e935 -> 30ee0da)

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git.


    from 4d8e935  This closes #2743
     new aeecb6f  ARTEMIS-2408 Too many opened FDs after server stops
     new 989b3a5  ARTEMIS-2408 A few tweaks on acceptor async stop
     new 30ee0da  This closes #2759

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../artemis/core/server/ActiveMQComponent.java     | 16 +++-----------
 .../core/remoting/impl/netty/NettyAcceptor.java    | 25 +++++++++++-----------
 .../remoting/server/impl/RemotingServiceImpl.java  |  7 +++++-
 .../artemis/tests/util/ActiveMQTestBase.java       |  4 ++++
 4 files changed, 26 insertions(+), 26 deletions(-)


[activemq-artemis] 02/03: ARTEMIS-2408 A few tweaks on acceptor async stop

Posted by cl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 989b3a516e177e039bfa013160bf0cce46037440
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Jul 18 16:23:19 2019 -0400

    ARTEMIS-2408 A few tweaks on acceptor async stop
---
 .../apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java | 2 +-
 .../activemq/artemis/core/remoting/server/impl/RemotingServiceImpl.java | 2 +-
 .../apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java    | 2 --
 3 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
index ee8c44e..418e9a9 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
@@ -650,7 +650,7 @@ public class NettyAcceptor extends AbstractAcceptor {
    public void stop() throws Exception {
       CountDownLatch latch = new CountDownLatch(1);
 
-      asyncStop(() -> latch.countDown());
+      asyncStop(latch::countDown);
 
       latch.await();
    }
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 24dc727..2faa8b2 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
@@ -412,7 +412,7 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
       CountDownLatch acceptorCountDownLatch = new CountDownLatch(acceptors.size());
       for (Acceptor acceptor : acceptors.values()) {
          try {
-            acceptor.asyncStop(() -> acceptorCountDownLatch.countDown());
+            acceptor.asyncStop(acceptorCountDownLatch::countDown);
          } catch (Throwable t) {
             ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
          }
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 24be17c..68ca620 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -1269,8 +1269,6 @@ public class ActiveMQServerImpl implements ActiveMQServer {
          this.analyzer = null;
       }
 
-      activateCallbacks.clear();
-
       if (identity != null) {
          ActiveMQServerLogger.LOGGER.serverStopped("identity=" + identity + ",version=" + getVersion().getFullVersion(), tempNodeID, getUptime());
       } else {


[activemq-artemis] 01/03: ARTEMIS-2408 Too many opened FDs after server stops

Posted by cl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit aeecb6f70b90c58e7f972b9f123dbe85d9ddf0c1
Author: brusdev <br...@gmail.com>
AuthorDate: Thu Jul 18 19:43:08 2019 +0200

    ARTEMIS-2408 Too many opened FDs after server stops
    
    Limit acceptors stop time.
    
    reapplying after commit 20ca827d79282ca41b4f60f28e6b09333c3d82d5
---
 .../artemis/core/server/ActiveMQComponent.java     | 16 +++-----------
 .../core/remoting/impl/netty/NettyAcceptor.java    | 25 +++++++++++-----------
 .../remoting/server/impl/RemotingServiceImpl.java  |  7 +++++-
 .../core/server/impl/ActiveMQServerImpl.java       |  2 ++
 .../artemis/tests/util/ActiveMQTestBase.java       |  4 ++++
 5 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQComponent.java b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQComponent.java
index dd60404..2b5c6c7 100644
--- a/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQComponent.java
+++ b/artemis-commons/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQComponent.java
@@ -16,26 +16,16 @@
  */
 package org.apache.activemq.artemis.core.server;
 
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.Future;
-
 public interface ActiveMQComponent {
 
    void start() throws Exception;
 
    void stop() throws Exception;
 
-   default Future<?> asyncStop() {
-      CompletableFuture<?> future = new CompletableFuture<>();
-
-      try {
-         stop();
-         future.complete(null);
-      } catch (Throwable t) {
-         future.completeExceptionally(t);
-      }
+   default void asyncStop(Runnable callback) throws Exception {
+      stop();
 
-      return future;
+      callback.run();
    }
 
    boolean isStarted();
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
index 98fb676..ee8c44e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/remoting/impl/netty/NettyAcceptor.java
@@ -36,8 +36,8 @@ import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.Executor;
-import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
@@ -222,8 +222,6 @@ public class NettyAcceptor extends AbstractAcceptor {
 
    final Executor failureExecutor;
 
-   private Future<?> asyncStopFuture = null;
-
    public NettyAcceptor(final String name,
                         final ClusterConnection clusterConnection,
                         final Map<String, Object> configuration,
@@ -649,15 +647,18 @@ public class NettyAcceptor extends AbstractAcceptor {
    }
 
    @Override
-   public java.util.concurrent.Future<?> asyncStop() {
-      stop();
+   public void stop() throws Exception {
+      CountDownLatch latch = new CountDownLatch(1);
+
+      asyncStop(() -> latch.countDown());
 
-      return asyncStopFuture;
+      latch.await();
    }
 
    @Override
-   public synchronized void stop() {
+   public synchronized void asyncStop(Runnable callback) {
       if (channelClazz == null) {
+         callback.run();
          return;
       }
 
@@ -693,11 +694,6 @@ public class NettyAcceptor extends AbstractAcceptor {
          }
       }
 
-      // Shutdown the EventLoopGroup if no new task was added for 100ms or if
-      // 3000ms elapsed.
-      asyncStopFuture = eventLoopGroup.shutdownGracefully(100, 3000, TimeUnit.MILLISECONDS);
-      eventLoopGroup = null;
-
       channelClazz = null;
 
       for (Connection connection : connections.values()) {
@@ -720,6 +716,11 @@ public class NettyAcceptor extends AbstractAcceptor {
       }
 
       paused = false;
+
+      // Shutdown the EventLoopGroup if no new task was added for 100ms or if
+      // 3000ms elapsed.
+      eventLoopGroup.shutdownGracefully(100, 3000, TimeUnit.MILLISECONDS).addListener(f -> callback.run());
+      eventLoopGroup = null;
    }
 
    @Override
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 416e9a9..24dc727 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
@@ -79,6 +79,8 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
 
    private static final Logger logger = Logger.getLogger(RemotingServiceImpl.class);
 
+   private static final int ACCEPTOR_STOP_TIMEOUT = 3000;
+
    // Attributes ----------------------------------------------------
 
    private volatile boolean started = false;
@@ -407,13 +409,16 @@ public class RemotingServiceImpl implements RemotingService, ServerConnectionLif
          conn.disconnect(criticalError);
       }
 
+      CountDownLatch acceptorCountDownLatch = new CountDownLatch(acceptors.size());
       for (Acceptor acceptor : acceptors.values()) {
          try {
-            acceptor.stop();
+            acceptor.asyncStop(() -> acceptorCountDownLatch.countDown());
          } catch (Throwable t) {
             ActiveMQServerLogger.LOGGER.errorStoppingAcceptor(acceptor.getName());
          }
       }
+      //In some cases an acceptor stopping could be locked ie NettyAcceptor stopping could be locked by a network failure.
+      acceptorCountDownLatch.await(ACCEPTOR_STOP_TIMEOUT, TimeUnit.MILLISECONDS);
 
       acceptors.clear();
 
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
index 68ca620..24be17c 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java
@@ -1269,6 +1269,8 @@ public class ActiveMQServerImpl implements ActiveMQServer {
          this.analyzer = null;
       }
 
+      activateCallbacks.clear();
+
       if (identity != null) {
          ActiveMQServerLogger.LOGGER.serverStopped("identity=" + identity + ",version=" + getVersion().getFullVersion(), tempNodeID, getUptime());
       } else {
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
index b48af77..19a3919 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/tests/util/ActiveMQTestBase.java
@@ -171,6 +171,9 @@ public abstract class ActiveMQTestBase extends Assert {
    @ClassRule
    public static ThreadLeakCheckRule leakCheckRule = new ThreadLeakCheckRule();
 
+   @Rule
+   public NoProcessFilesBehind noProcessFilesBehind = new NoProcessFilesBehind(-1, 1000);
+
    /** We should not under any circunstance create data outside of ./target
     *  if you have a test failing because because of this rule for any reason,
     *  even if you use afterClass events, move the test to ./target and always cleanup after
@@ -276,6 +279,7 @@ public abstract class ActiveMQTestBase extends Assert {
 
    @After
    public void tearDown() throws Exception {
+      noProcessFilesBehind.tearDown();
       closeAllSessionFactories();
       closeAllServerLocatorsFactories();
 


[activemq-artemis] 03/03: This closes #2759

Posted by cl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git

commit 30ee0daa902b11b2ade64a44003d79ff2aecc7e5
Merge: 4d8e935 989b3a5
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Jul 18 16:28:04 2019 -0400

    This closes #2759

 .../artemis/core/server/ActiveMQComponent.java     | 16 +++-----------
 .../core/remoting/impl/netty/NettyAcceptor.java    | 25 +++++++++++-----------
 .../remoting/server/impl/RemotingServiceImpl.java  |  7 +++++-
 .../artemis/tests/util/ActiveMQTestBase.java       |  4 ++++
 4 files changed, 26 insertions(+), 26 deletions(-)