use of org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration in project activemq-artemis by apache.
the class BridgeTestBase method createActiveMQServer.
protected ActiveMQServer createActiveMQServer(final int id, final Map<String, Object> params, final boolean netty, final NodeManager nodeManager) throws Exception {
TransportConfiguration tc = new TransportConfiguration();
if (netty) {
params.put(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants.DEFAULT_PORT + id);
tc = new TransportConfiguration(NETTY_ACCEPTOR_FACTORY, params);
} else {
params.put(org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants.SERVER_ID_PROP_NAME, id);
tc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY, params);
}
Configuration serviceConf = createBasicConfig().setJournalType(getDefaultJournalType()).setBindingsDirectory(getBindingsDir(id, false)).setJournalMinFiles(2).setJournalDirectory(getJournalDir(id, false)).setPagingDirectory(getPageDir(id, false)).setLargeMessagesDirectory(getLargeMessagesDir(id, false)).setJournalFileSize(100 * 1024).addAcceptorConfiguration(tc).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration());
ActiveMQServer server;
if (nodeManager == null) {
server = ActiveMQServers.newActiveMQServer(serviceConf, true);
} else {
server = new InVMNodeManagerServer(serviceConf, nodeManager);
}
return addServer(server);
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration in project activemq-artemis by apache.
the class FailBackManualTest method createConfigs.
@Override
protected void createConfigs() throws Exception {
nodeManager = new InVMNodeManager(false);
TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
backupConfig = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(false)).setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration().setAllowFailBack(false)).addConnectorConfiguration(liveConnector.getName(), liveConnector).addConnectorConfiguration(backupConnector.getName(), backupConnector).addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName()));
backupServer = createTestableServer(backupConfig);
liveConfig = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true)).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()).addConnectorConfiguration(liveConnector.getName(), liveConnector).addConnectorConfiguration(backupConnector.getName(), backupConnector).addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), backupConnector.getName()));
liveServer = createTestableServer(liveConfig);
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration in project activemq-artemis by apache.
the class FailBackAutoTest method createConfigs.
@Override
protected void createConfigs() throws Exception {
nodeManager = new InVMNodeManager(false);
TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
backupConfig = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(false)).setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration().setRestartBackup(true)).addConnectorConfiguration(liveConnector.getName(), liveConnector).addConnectorConfiguration(backupConnector.getName(), backupConnector).addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName()));
backupServer = createTestableServer(backupConfig);
liveConfig = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true)).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), backupConnector.getName())).addConnectorConfiguration(liveConnector.getName(), liveConnector).addConnectorConfiguration(backupConnector.getName(), backupConnector);
liveServer = createTestableServer(liveConfig);
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration in project activemq-artemis by apache.
the class MultipleLivesMultipleBackupsFailoverTest method createLiveConfig.
protected void createLiveConfig(NodeManager nodeManager, int liveNode, int... otherLiveNodes) throws Exception {
TransportConfiguration liveConnector = createTransportConfiguration(isNetty(), false, generateParams(liveNode, isNetty()));
Configuration config0 = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(isNetty(), true, generateParams(liveNode, isNetty()))).setHAPolicyConfiguration(sharedStore ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration()).setBindingsDirectory(getBindingsDir() + "_" + liveNode).setJournalDirectory(getJournalDir() + "_" + liveNode).setPagingDirectory(getPageDir() + "_" + liveNode).setLargeMessagesDirectory(getLargeMessagesDir() + "_" + liveNode).addConnectorConfiguration(liveConnector.getName(), liveConnector);
String[] pairs = new String[otherLiveNodes.length];
for (int i = 0; i < otherLiveNodes.length; i++) {
TransportConfiguration otherLiveConnector = createTransportConfiguration(isNetty(), false, generateParams(otherLiveNodes[i], isNetty()));
config0.addConnectorConfiguration(otherLiveConnector.getName(), otherLiveConnector);
pairs[i] = otherLiveConnector.getName();
}
config0.addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), pairs));
servers.put(liveNode, new SameProcessActiveMQServer(createInVMFailoverServer(true, config0, nodeManager, liveNode)));
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration in project activemq-artemis by apache.
the class StartStopDeadlockTest method testDeadlock.
/*
* simple test to make sure connect still works with some network latency built into netty
* */
@Test
@BMRules(rules = { @BMRule(name = "Server.start wait-init", targetClass = "org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl", targetMethod = "initialisePart2", targetLocation = "ENTRY", condition = "incrementCounter(\"server-Init\") == 2", action = "System.out.println(\"server backup init\"), waitFor(\"start-init\")"), @BMRule(name = "JMSServer.stop wait-init", targetClass = "org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl", targetMethod = "stop", targetLocation = "ENTRY", action = "signalWake(\"start-init\", true)"), @BMRule(name = "StartStopDeadlockTest tearDown", targetClass = "org.apache.activemq.artemis.tests.extras.byteman.StartStopDeadlockTest", targetMethod = "tearDown", targetLocation = "ENTRY", action = "deleteCounter(\"server-Init\")") })
public void testDeadlock() throws Exception {
// A live server that will always be crashed
Configuration confLive = createDefaultNettyConfig().setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration());
final ActiveMQServer serverLive = addServer(ActiveMQServers.newActiveMQServer(confLive));
serverLive.start();
// A backup that will be waiting to be activated
Configuration config = createDefaultNettyConfig().setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration());
final ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, true));
final JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
final InVMNamingContext context = new InVMNamingContext();
jmsServer.setRegistry(new JndiBindingRegistry(context));
jmsServer.start();
final AtomicInteger errors = new AtomicInteger(0);
final CountDownLatch align = new CountDownLatch(2);
final CountDownLatch startLatch = new CountDownLatch(1);
Thread tCrasher = new Thread("tStart") {
@Override
public void run() {
try {
align.countDown();
startLatch.await();
System.out.println("Crashing....");
serverLive.fail(true);
} catch (Exception e) {
errors.incrementAndGet();
e.printStackTrace();
}
}
};
Thread tStop = new Thread("tStop") {
@Override
public void run() {
try {
align.countDown();
startLatch.await();
jmsServer.stop();
} catch (Exception e) {
errors.incrementAndGet();
e.printStackTrace();
}
}
};
tCrasher.start();
tStop.start();
align.await();
startLatch.countDown();
tCrasher.join();
tStop.join();
assertEquals(0, errors.get());
}
Aggregations