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/08/02 17:26:28 UTC

[activemq-artemis] branch master updated (b142fa9 -> 6500ca0)

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 b142fa9  This closes #2777
     new 73e2d47  ARTEMIS-2438 Activation cleaning
     new 9c5a2f4  ARTEMIS-2435 Renaming CLI parameter as --journal prefix
     new 6500ca0  This closes #2778

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:
 .../activemq/artemis/cli/commands/Create.java      |  2 +-
 .../apache/activemq/artemis/cli/commands/Run.java  |  4 +--
 .../jms/server/impl/JMSServerManagerImpl.java      |  4 +--
 .../artemis/core/server/ActivateCallback.java      | 11 +++++++
 .../core/server/impl/ActiveMQServerImpl.java       |  8 +++++
 .../CleaningActivateCallback.java}                 | 29 +++++++++--------
 .../artemis/core/server/impl/InVMNodeManager.java  |  2 +-
 .../core/server/impl/jdbc/JdbcNodeManager.java     |  3 +-
 .../management/impl/ManagementServiceImpl.java     |  4 +--
 .../cluster/bridge/BridgeReconnectTest.java        |  1 -
 .../integration/discovery/DiscoveryBaseTest.java   |  3 +-
 ...stenerTest.java => ActivationCallbackTest.java} | 37 ++++++++++------------
 12 files changed, 63 insertions(+), 45 deletions(-)
 copy artemis-server/src/main/java/org/apache/activemq/artemis/core/server/{cluster/ha/HAManager.java => impl/CleaningActivateCallback.java} (60%)
 copy tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/{ActivationFailureListenerTest.java => ActivationCallbackTest.java} (58%)


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

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 6500ca0f86157759b191bfa13bc262449c7a441d
Merge: b142fa9 9c5a2f4
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Fri Aug 2 13:26:16 2019 -0400

    This closes #2778

 .../activemq/artemis/cli/commands/Create.java      |  2 +-
 .../apache/activemq/artemis/cli/commands/Run.java  |  4 +-
 .../jms/server/impl/JMSServerManagerImpl.java      |  4 +-
 .../artemis/core/server/ActivateCallback.java      | 11 +++++
 .../core/server/impl/ActiveMQServerImpl.java       |  8 ++++
 .../CleaningActivateCallback.java}                 | 33 ++++++--------
 .../artemis/core/server/impl/InVMNodeManager.java  |  2 +-
 .../core/server/impl/jdbc/JdbcNodeManager.java     |  3 +-
 .../management/impl/ManagementServiceImpl.java     |  4 +-
 .../cluster/bridge/BridgeReconnectTest.java        |  1 -
 .../integration/discovery/DiscoveryBaseTest.java   |  3 +-
 .../integration/server/ActivationCallbackTest.java | 51 ++++++++++++++++++++++
 12 files changed, 95 insertions(+), 31 deletions(-)


[activemq-artemis] 02/03: ARTEMIS-2435 Renaming CLI parameter as --journal prefix

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 9c5a2f42de45d398c6048f2ae3b25a87bc6f86df
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Aug 1 16:13:50 2019 -0400

    ARTEMIS-2435 Renaming CLI parameter as --journal prefix
---
 .../src/main/java/org/apache/activemq/artemis/cli/commands/Create.java  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
index 99d4b13..6318d0b 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
@@ -266,7 +266,7 @@ public class Create extends InputAbstract {
    @Option(name = "--no-fsync", description = "Disable usage of fdatasync (channel.force(false) from java nio) on the journal")
    private boolean noJournalSync;
 
-   @Option(name = "--device-block-size", description = "The block size by the device, default at 4096.")
+   @Option(name = "--journal-device-block-size", description = "The block size by the device, default at 4096.")
    private int journalDeviceBlockSize = 4096;
 
    @Option(name = "--global-max-size", description = "Maximum amount of memory which message data may consume (Default: Undefined, half of the system's memory)")


[activemq-artemis] 01/03: ARTEMIS-2438 Activation cleaning

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 73e2d4709d5ed18c10de3cc1bad3005c2d08d29a
Author: Clebert Suconic <cl...@apache.org>
AuthorDate: Thu Aug 1 15:54:06 2019 -0400

    ARTEMIS-2438 Activation cleaning
---
 .../apache/activemq/artemis/cli/commands/Run.java  |  4 +-
 .../jms/server/impl/JMSServerManagerImpl.java      |  4 +-
 .../artemis/core/server/ActivateCallback.java      | 11 +++++
 .../core/server/impl/ActiveMQServerImpl.java       |  8 ++++
 .../CleaningActivateCallback.java}                 | 33 ++++++--------
 .../artemis/core/server/impl/InVMNodeManager.java  |  2 +-
 .../core/server/impl/jdbc/JdbcNodeManager.java     |  3 +-
 .../management/impl/ManagementServiceImpl.java     |  4 +-
 .../cluster/bridge/BridgeReconnectTest.java        |  1 -
 .../integration/discovery/DiscoveryBaseTest.java   |  3 +-
 .../integration/server/ActivationCallbackTest.java | 51 ++++++++++++++++++++++
 11 files changed, 94 insertions(+), 30 deletions(-)

diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java
index 759815c..d7a26cb 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Run.java
@@ -29,7 +29,7 @@ import org.apache.activemq.artemis.cli.factory.BrokerFactory;
 import org.apache.activemq.artemis.cli.factory.jmx.ManagementFactory;
 import org.apache.activemq.artemis.cli.factory.security.SecurityManagerFactory;
 import org.apache.activemq.artemis.components.ExternalComponent;
-import org.apache.activemq.artemis.core.server.ActivateCallback;
+import org.apache.activemq.artemis.core.server.impl.CleaningActivateCallback;
 import org.apache.activemq.artemis.core.server.management.ManagementContext;
 import org.apache.activemq.artemis.dto.BrokerDTO;
 import org.apache.activemq.artemis.dto.ComponentDTO;
@@ -83,7 +83,7 @@ public class Run extends LockAbstract {
 
          managementContext.start();
          server.start();
-         server.getServer().registerActivateCallback(new ActivateCallback() {
+         server.getServer().registerActivateCallback(new CleaningActivateCallback() {
             @Override
             public void deActivate() {
                try {
diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
index a05ed27..a5e6339 100644
--- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
+++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java
@@ -46,10 +46,10 @@ import org.apache.activemq.artemis.core.postoffice.BindingType;
 import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
 import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
 import org.apache.activemq.artemis.core.security.Role;
-import org.apache.activemq.artemis.core.server.ActivateCallback;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
+import org.apache.activemq.artemis.core.server.impl.CleaningActivateCallback;
 import org.apache.activemq.artemis.core.server.management.Notification;
 import org.apache.activemq.artemis.core.server.reload.ReloadCallback;
 import org.apache.activemq.artemis.core.server.reload.ReloadManager;
@@ -97,7 +97,7 @@ import org.w3c.dom.NodeList;
  * redeployed.
  */
 @Deprecated
-public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback {
+public class JMSServerManagerImpl extends CleaningActivateCallback implements JMSServerManager {
 
    private static final String REJECT_FILTER = Filter.GENERIC_IGNORED_FILTER;
 
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActivateCallback.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActivateCallback.java
index f3d3820..9a646d4 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActivateCallback.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActivateCallback.java
@@ -42,4 +42,15 @@ public interface ActivateCallback {
     */
    default void activationComplete() {
    }
+
+   /*
+    * This is called when the broker is stopped (no shutdown in place)
+    */
+   default void stop(ActiveMQServer server) {
+   }
+
+   default void shutdown(ActiveMQServer server) {
+   }
+
+
 }
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..70a4fbf 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,14 @@ public class ActiveMQServerImpl implements ActiveMQServer {
          this.analyzer = null;
       }
 
+      for (ActivateCallback callback: activateCallbacks) {
+         if (isShutdown) {
+            callback.shutdown(this);
+         } else {
+            callback.stop(this);
+         }
+      }
+
       if (identity != null) {
          ActiveMQServerLogger.LOGGER.serverStopped("identity=" + identity + ",version=" + getVersion().getFullVersion(), tempNodeID, getUptime());
       } else {
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActivateCallback.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/CleaningActivateCallback.java
similarity index 53%
copy from artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActivateCallback.java
copy to artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/CleaningActivateCallback.java
index f3d3820..f02e30e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActivateCallback.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/CleaningActivateCallback.java
@@ -14,32 +14,25 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.activemq.artemis.core.server;
 
-public interface ActivateCallback {
+package org.apache.activemq.artemis.core.server.impl;
 
-   /*
-    * this is called before any services are started when the server first initialised
-    */
-   default void preActivate() {
-   }
+import org.apache.activemq.artemis.core.server.ActivateCallback;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+
+/** This is an abstract ActivateCallback that will cleanup itself when the broker is shutodwn */
+public abstract class CleaningActivateCallback implements ActivateCallback {
 
-   /*
-    * this is called after most of the services have been started but before any cluster resources or JMS resources have been
-    */
-   default void activated() {
+   public CleaningActivateCallback() {
    }
 
-   /*
-    * this is called when the server is stopping, after any network resources and clients are closed but before the rest
-    * of the resources
-    */
-   default void deActivate() {
+   @Override
+   public void stop(ActiveMQServer server) {
+      server.unregisterActivateCallback(this);
    }
 
-   /*
-    * this is called when all resources have been started including any JMS resources
-    */
-   default void activationComplete() {
+   @Override
+   public void shutdown(ActiveMQServer server) {
+      server.unregisterActivateCallback(this);
    }
 }
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java
index a3bce41..a0e7601 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/InVMNodeManager.java
@@ -107,7 +107,7 @@ public final class InVMNodeManager extends NodeManager {
    public ActivateCallback startLiveNode() throws Exception {
       state = FAILING_BACK;
       liveLock.acquire();
-      return new ActivateCallback() {
+      return new CleaningActivateCallback() {
          @Override
          public void activationComplete() {
             try {
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/JdbcNodeManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/JdbcNodeManager.java
index 322ea38..b98fd85 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/JdbcNodeManager.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/jdbc/JdbcNodeManager.java
@@ -28,6 +28,7 @@ import org.apache.activemq.artemis.core.io.IOCriticalErrorListener;
 import org.apache.activemq.artemis.core.server.ActivateCallback;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.NodeManager;
+import org.apache.activemq.artemis.core.server.impl.CleaningActivateCallback;
 import org.apache.activemq.artemis.jdbc.store.drivers.JDBCUtils;
 import org.apache.activemq.artemis.jdbc.store.sql.PropertySQLProvider;
 import org.apache.activemq.artemis.jdbc.store.sql.SQLProvider;
@@ -429,7 +430,7 @@ public final class JdbcNodeManager extends NodeManager {
 
          ActiveMQServerLogger.LOGGER.obtainedLiveLock();
 
-         return new ActivateCallback() {
+         return new CleaningActivateCallback() {
             @Override
             public void activationComplete() {
                LOGGER.debug("ENTER activationComplete");
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
index 2ba8e4e..aa1479a 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
@@ -71,7 +71,6 @@ import org.apache.activemq.artemis.core.postoffice.PostOffice;
 import org.apache.activemq.artemis.core.remoting.server.RemotingService;
 import org.apache.activemq.artemis.core.security.Role;
 import org.apache.activemq.artemis.core.security.SecurityStore;
-import org.apache.activemq.artemis.core.server.ActivateCallback;
 import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
@@ -82,6 +81,7 @@ import org.apache.activemq.artemis.core.server.cluster.Bridge;
 import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
 import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
+import org.apache.activemq.artemis.core.server.impl.CleaningActivateCallback;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
 import org.apache.activemq.artemis.core.server.management.Notification;
 import org.apache.activemq.artemis.core.server.management.NotificationListener;
@@ -553,7 +553,7 @@ public class ManagementServiceImpl implements ManagementService {
        * Ensure the management notification address is created otherwise if auto-create-address = false then cluster
        * bridges won't be able to connect.
        */
-      messagingServer.registerActivateCallback(new ActivateCallback() {
+      messagingServer.registerActivateCallback(new CleaningActivateCallback() {
          @Override
          public void activated() {
             try {
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java
index 88c0e81..23ce8a7 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/bridge/BridgeReconnectTest.java
@@ -480,7 +480,6 @@ public class BridgeReconnectTest extends BridgeTestBase {
          ClientMessage r1 = cons1.receive(30000);
          assertNotNull("received expected msg", r1);
          assertEquals("property value matches", i, r1.getObjectProperty(propKey));
-         BridgeReconnectTest.log.info("got message " + r1.getObjectProperty(propKey));
       }
 
       BridgeReconnectTest.log.info("got messages");
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java
index 17128c7..650694f 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/discovery/DiscoveryBaseTest.java
@@ -34,6 +34,7 @@ import org.apache.activemq.artemis.core.server.ActivateCallback;
 import org.apache.activemq.artemis.core.server.NodeManager;
 import org.apache.activemq.artemis.core.server.cluster.BroadcastGroup;
 import org.apache.activemq.artemis.core.server.cluster.impl.BroadcastGroupImpl;
+import org.apache.activemq.artemis.core.server.impl.CleaningActivateCallback;
 import org.apache.activemq.artemis.core.server.management.NotificationService;
 import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
 import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
@@ -194,7 +195,7 @@ public class DiscoveryBaseTest extends ActiveMQTestBase {
 
       @Override
       public ActivateCallback startLiveNode() throws Exception {
-         return new ActivateCallback() {
+         return new CleaningActivateCallback() {
          };
       }
 
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ActivationCallbackTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ActivationCallbackTest.java
new file mode 100644
index 0000000..62a233d
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/server/ActivationCallbackTest.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.tests.integration.server;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.activemq.artemis.core.server.ActivateCallback;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * A simple test-case used for documentation purposes.
+ */
+public class ActivationCallbackTest extends ActiveMQTestBase {
+
+   protected ActiveMQServer server;
+
+   @Test
+   public void callbackOnShutdown() throws Exception {
+      server = createServer(false, createDefaultNettyConfig());
+      final CountDownLatch latch = new CountDownLatch(1);
+      server.registerActivateCallback(new ActivateCallback() {
+         @Override
+         public void shutdown(ActiveMQServer server) {
+            latch.countDown();
+         }
+      });
+      server.start();
+      Assert.assertEquals(1, latch.getCount());
+      server.stop();
+      Assert.assertTrue(latch.await(30, TimeUnit.SECONDS));
+   }
+}