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 2017/01/27 20:45:42 UTC

[1/2] activemq-artemis git commit: ARTEMIS-932 2 brokers can be started using the same store

Repository: activemq-artemis
Updated Branches:
  refs/heads/master fb4bc063f -> 2e5f45820


ARTEMIS-932 2 brokers can be started using the same store


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

Branch: refs/heads/master
Commit: 5f3159f4c87ea6f850c81e48bfd32c41f07a00a8
Parents: fb4bc06
Author: Howard Gao <ho...@gmail.com>
Authored: Tue Jan 24 04:46:21 2017 +0800
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Jan 27 15:45:32 2017 -0500

----------------------------------------------------------------------
 .../activemq/cli/test/FileBrokerTest.java       | 40 ++++++++++++
 .../test/resources/FileBrokerTest-broker1.xml   | 65 ++++++++++++++++++++
 .../test/resources/FileBrokerTest-broker2.xml   | 65 ++++++++++++++++++++
 .../core/server/impl/LiveOnlyActivation.java    | 17 +++++
 4 files changed, 187 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5f3159f4/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java b/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java
index b04b540..e1a2879 100644
--- a/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java
+++ b/artemis-cli/src/test/java/org/apache/activemq/cli/test/FileBrokerTest.java
@@ -65,6 +65,46 @@ public class FileBrokerTest {
    }
 
    @Test
+   public void startTwoBrokersWithSameDataDir() throws Exception {
+      ServerDTO serverDTO1 = new ServerDTO();
+      ServerDTO serverDTO2 = new ServerDTO();
+      serverDTO1.configuration = "FileBrokerTest-broker1.xml";
+      serverDTO2.configuration = "FileBrokerTest-broker2.xml";
+      FileBroker broker1 = new FileBroker(serverDTO1, new ActiveMQJAASSecurityManager());
+      FileBroker broker2 = new FileBroker(serverDTO2, new ActiveMQJAASSecurityManager());
+      try {
+         broker1.start();
+         Assert.assertTrue(broker1.isStarted());
+
+         Thread thread = new Thread(() -> {
+            try {
+               broker2.start();
+            } catch (Exception e) {
+               e.printStackTrace();
+            }
+         });
+         thread.start();
+
+         Assert.assertFalse(broker2.isStarted());
+         //only if broker1 is stopped can broker2 be fully started
+         broker1.stop();
+         broker1 = null;
+
+         thread.join(5000);
+         Assert.assertTrue(broker2.isStarted());
+         broker2.stop();
+
+      } finally {
+         if (broker1 != null) {
+            broker1.stop();
+         }
+         if (broker2 != null) {
+            broker2.stop();
+         }
+      }
+   }
+
+   @Test
    public void testConfigFileReload() throws Exception {
       ServerDTO serverDTO = new ServerDTO();
       serverDTO.configuration = "broker-reload.xml";

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5f3159f4/artemis-cli/src/test/resources/FileBrokerTest-broker1.xml
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/resources/FileBrokerTest-broker1.xml b/artemis-cli/src/test/resources/FileBrokerTest-broker1.xml
new file mode 100644
index 0000000..58dc1e3
--- /dev/null
+++ b/artemis-cli/src/test/resources/FileBrokerTest-broker1.xml
@@ -0,0 +1,65 @@
+<?xml version='1.0'?>
+<!--
+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.
+-->
+
+<configuration xmlns="urn:activemq">
+   <core xmlns="urn:activemq:core">
+
+      <name>broker1</name>
+
+      <persistence-enabled>true</persistence-enabled>
+
+      <paging-directory>./target/paging</paging-directory>
+
+      <bindings-directory>./target/bindings</bindings-directory>
+
+      <journal-directory>./target/journal</journal-directory>
+
+      <journal-min-files>2</journal-min-files>
+
+      <large-messages-directory>./target/large-messages</large-messages-directory>
+
+      <acceptors>
+         <!-- Acceptor for every supported protocol -->
+         <acceptor name="artemis">tcp://0.0.0.0:61616?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE</acceptor>
+
+      </acceptors>
+
+      <security-settings>
+         <security-setting match="#">
+            <permission type="createNonDurableQueue" roles="guest"/>
+            <permission type="deleteNonDurableQueue" roles="guest"/>
+            <permission type="consume" roles="guest"/>
+            <permission type="send" roles="guest"/>
+         </security-setting>
+      </security-settings>
+
+      <address-settings>
+         <!--default for catch all-->
+         <address-setting match="#">
+            <dead-letter-address>DLQ</dead-letter-address>
+            <expiry-address>ExpiryQueue</expiry-address>
+            <redelivery-delay>0</redelivery-delay>
+            <max-size-bytes>10Mb</max-size-bytes>
+            <message-counter-history-day-limit>10</message-counter-history-day-limit>
+            <address-full-policy>BLOCK</address-full-policy>
+         </address-setting>
+      </address-settings>
+   </core>
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5f3159f4/artemis-cli/src/test/resources/FileBrokerTest-broker2.xml
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/resources/FileBrokerTest-broker2.xml b/artemis-cli/src/test/resources/FileBrokerTest-broker2.xml
new file mode 100644
index 0000000..779afa8
--- /dev/null
+++ b/artemis-cli/src/test/resources/FileBrokerTest-broker2.xml
@@ -0,0 +1,65 @@
+<?xml version='1.0'?>
+<!--
+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.
+-->
+
+<configuration xmlns="urn:activemq">
+   <core xmlns="urn:activemq:core">
+
+      <name>broker2</name>
+
+      <persistence-enabled>true</persistence-enabled>
+
+      <paging-directory>./target/paging</paging-directory>
+
+      <bindings-directory>./target/bindings</bindings-directory>
+
+      <journal-directory>./target/journal</journal-directory>
+
+      <journal-min-files>2</journal-min-files>
+
+      <large-messages-directory>./target/large-messages</large-messages-directory>
+
+      <acceptors>
+         <!-- Acceptor for every supported protocol -->
+         <acceptor name="artemis">tcp://0.0.0.0:61716?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE</acceptor>
+
+      </acceptors>
+
+      <security-settings>
+         <security-setting match="#">
+            <permission type="createNonDurableQueue" roles="guest"/>
+            <permission type="deleteNonDurableQueue" roles="guest"/>
+            <permission type="consume" roles="guest"/>
+            <permission type="send" roles="guest"/>
+         </security-setting>
+      </security-settings>
+
+      <address-settings>
+         <!--default for catch all-->
+         <address-setting match="#">
+            <dead-letter-address>DLQ</dead-letter-address>
+            <expiry-address>ExpiryQueue</expiry-address>
+            <redelivery-delay>0</redelivery-delay>
+            <max-size-bytes>10Mb</max-size-bytes>
+            <message-counter-history-day-limit>10</message-counter-history-day-limit>
+            <address-full-policy>BLOCK</address-full-policy>
+         </address-setting>
+      </address-settings>
+   </core>
+</configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5f3159f4/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java
index 7ffb817..b4bd024 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/LiveOnlyActivation.java
@@ -33,6 +33,7 @@ import org.apache.activemq.artemis.core.postoffice.impl.PostOfficeImpl;
 import org.apache.activemq.artemis.core.remoting.server.RemotingService;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
 import org.apache.activemq.artemis.core.server.LiveNodeLocator;
+import org.apache.activemq.artemis.core.server.NodeManager;
 import org.apache.activemq.artemis.core.server.cluster.ActiveMQServerSideProtocolManagerFactory;
 import org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy;
 import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy;
@@ -61,6 +62,12 @@ public class LiveOnlyActivation extends Activation {
       try {
          activeMQServer.initialisePart1(false);
 
+         activeMQServer.registerActivateCallback(activeMQServer.getNodeManager().startLiveNode());
+
+         if (activeMQServer.getState() == ActiveMQServerImpl.SERVER_STATE.STOPPED || activeMQServer.getState() == ActiveMQServerImpl.SERVER_STATE.STOPPING) {
+            return;
+         }
+
          activeMQServer.initialisePart2(false);
 
          activeMQServer.completeActivation();
@@ -82,6 +89,16 @@ public class LiveOnlyActivation extends Activation {
          scaleDownServerLocator.close();
          scaleDownServerLocator = null;
       }
+
+      NodeManager nodeManagerInUse = activeMQServer.getNodeManager();
+
+      if (nodeManagerInUse != null) {
+         if (permanently) {
+            nodeManagerInUse.crashLiveServer();
+         } else {
+            nodeManagerInUse.pauseLiveServer();
+         }
+      }
    }
 
    @Override


[2/2] activemq-artemis git commit: This closes #978

Posted by cl...@apache.org.
This closes #978


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

Branch: refs/heads/master
Commit: 2e5f458209ae69b6c91c198c55f381b9fd9d0803
Parents: fb4bc06 5f3159f
Author: Clebert Suconic <cl...@apache.org>
Authored: Fri Jan 27 15:45:33 2017 -0500
Committer: Clebert Suconic <cl...@apache.org>
Committed: Fri Jan 27 15:45:33 2017 -0500

----------------------------------------------------------------------
 .../activemq/cli/test/FileBrokerTest.java       | 40 ++++++++++++
 .../test/resources/FileBrokerTest-broker1.xml   | 65 ++++++++++++++++++++
 .../test/resources/FileBrokerTest-broker2.xml   | 65 ++++++++++++++++++++
 .../core/server/impl/LiveOnlyActivation.java    | 17 +++++
 4 files changed, 187 insertions(+)
----------------------------------------------------------------------