use of org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration 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());
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration in project activemq-artemis by apache.
the class SpawnedServerSupport method createSharedFolderConfig.
static Configuration createSharedFolderConfig(String folder, int thisport, int otherport, boolean isBackup) {
HAPolicyConfiguration haPolicyConfiguration = null;
if (isBackup) {
haPolicyConfiguration = new SharedStoreSlavePolicyConfiguration();
((SharedStoreSlavePolicyConfiguration) haPolicyConfiguration).setAllowFailBack(false);
} else {
haPolicyConfiguration = new SharedStoreMasterPolicyConfiguration();
}
Configuration config = createConfig(folder).clearAcceptorConfigurations().setJournalFileSize(15 * 1024 * 1024).addAcceptorConfiguration(createTransportConfigiguration(true, thisport)).addConnectorConfiguration("thisServer", createTransportConfigiguration(false, thisport)).addConnectorConfiguration("otherServer", createTransportConfigiguration(false, otherport)).setMessageExpiryScanPeriod(500).addClusterConfiguration(isBackup ? setupClusterConn("thisServer", "otherServer") : setupClusterConn("thisServer")).setHAPolicyConfiguration(haPolicyConfiguration);
return config;
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration in project activemq-artemis by apache.
the class ReplicationTest method setupServer.
private void setupServer(boolean useNetty, boolean backup, ExtraConfigurer extraConfig, String... incomingInterceptors) throws Exception {
TransportConfiguration liveConnector = null;
TransportConfiguration liveAcceptor = null;
TransportConfiguration backupConnector = null;
TransportConfiguration backupAcceptor = null;
if (useNetty) {
liveConnector = TransportConfigurationUtils.getNettyConnector(true, 0);
liveAcceptor = TransportConfigurationUtils.getNettyAcceptor(true, 0);
backupConnector = TransportConfigurationUtils.getNettyConnector(false, 0);
backupAcceptor = TransportConfigurationUtils.getNettyAcceptor(false, 0);
} else {
liveConnector = TransportConfigurationUtils.getInVMConnector(true);
backupConnector = TransportConfigurationUtils.getInVMConnector(false);
backupAcceptor = TransportConfigurationUtils.getInVMAcceptor(false);
}
Configuration liveConfig = createDefaultInVMConfig();
Configuration backupConfig = createDefaultInVMConfig().setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration()).setBindingsDirectory(getBindingsDir(0, true)).setJournalDirectory(getJournalDir(0, true)).setPagingDirectory(getPageDir(0, true)).setLargeMessagesDirectory(getLargeMessagesDir(0, true)).setIncomingInterceptorClassNames(incomingInterceptors.length > 0 ? Arrays.asList(incomingInterceptors) : new ArrayList<String>());
ReplicatedBackupUtils.configureReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, liveAcceptor);
if (extraConfig != null) {
extraConfig.config(liveConfig, backupConfig);
}
if (backup) {
liveServer = createServer(liveConfig);
liveServer.start();
waitForComponent(liveServer);
}
backupServer = createServer(backupConfig);
if (useNetty) {
locator = createNettyNonHALocator();
} else {
locator = createInVMNonHALocator();
}
backupServer.start();
if (backup) {
ActiveMQTestBase.waitForRemoteBackup(null, 5, true, backupServer);
}
int count = 0;
waitForReplication(count);
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration in project activemq-artemis by apache.
the class FileConfigurationParser method createSharedStoreSlaveHaPolicy.
private SharedStoreSlavePolicyConfiguration createSharedStoreSlaveHaPolicy(Element policyNode) {
SharedStoreSlavePolicyConfiguration configuration = new SharedStoreSlavePolicyConfiguration();
configuration.setAllowFailBack(getBoolean(policyNode, "allow-failback", configuration.isAllowFailBack()));
configuration.setFailoverOnServerShutdown(getBoolean(policyNode, "failover-on-shutdown", configuration.isFailoverOnServerShutdown()));
configuration.setRestartBackup(getBoolean(policyNode, "restart-backup", configuration.isRestartBackup()));
configuration.setScaleDownConfiguration(parseScaleDownConfig(policyNode));
return configuration;
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration in project activemq-artemis by apache.
the class FailoverTestBase method createConfigs.
protected void createConfigs() throws Exception {
nodeManager = createNodeManager();
TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
backupConfig = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(false)).setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration()).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())).addConnectorConfiguration(liveConnector.getName(), liveConnector);
liveServer = createTestableServer(liveConfig);
}
Aggregations