ARTEMIS-932 2 brokers can be started using the same store
This commit is contained in:
parent
fb4bc063f1
commit
5f3159f4c8
|
@ -64,6 +64,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
|
@Test
|
||||||
public void testConfigFileReload() throws Exception {
|
public void testConfigFileReload() throws Exception {
|
||||||
ServerDTO serverDTO = new ServerDTO();
|
ServerDTO serverDTO = new ServerDTO();
|
||||||
|
|
|
@ -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>
|
|
@ -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>
|
|
@ -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.remoting.server.RemotingService;
|
||||||
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
|
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
|
||||||
import org.apache.activemq.artemis.core.server.LiveNodeLocator;
|
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.ActiveMQServerSideProtocolManagerFactory;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy;
|
import org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy;
|
import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy;
|
||||||
|
@ -61,6 +62,12 @@ public class LiveOnlyActivation extends Activation {
|
||||||
try {
|
try {
|
||||||
activeMQServer.initialisePart1(false);
|
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.initialisePart2(false);
|
||||||
|
|
||||||
activeMQServer.completeActivation();
|
activeMQServer.completeActivation();
|
||||||
|
@ -82,6 +89,16 @@ public class LiveOnlyActivation extends Activation {
|
||||||
scaleDownServerLocator.close();
|
scaleDownServerLocator.close();
|
||||||
scaleDownServerLocator = null;
|
scaleDownServerLocator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NodeManager nodeManagerInUse = activeMQServer.getNodeManager();
|
||||||
|
|
||||||
|
if (nodeManagerInUse != null) {
|
||||||
|
if (permanently) {
|
||||||
|
nodeManagerInUse.crashLiveServer();
|
||||||
|
} else {
|
||||||
|
nodeManagerInUse.pauseLiveServer();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue