use of org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy in project activemq-artemis by apache.
the class FailoverTest method testBackupServerNotRemoved.
@Test(timeout = 120000)
public void testBackupServerNotRemoved() throws Exception {
// HORNETQ-720 Disabling test for replicating backups.
if (!(backupServer.getServer().getHAPolicy() instanceof SharedStoreSlavePolicy)) {
return;
}
locator.setFailoverOnInitialConnection(true);
createSessionFactory();
ClientSession session = sendAndConsume(sf, true);
CountDownSessionFailureListener listener = new CountDownSessionFailureListener(session);
session.addFailureListener(listener);
backupServer.stop();
liveServer.crash();
// To reload security or other settings that are read during startup
beforeRestart(backupServer);
backupServer.start();
Assert.assertTrue("session failure listener", listener.getLatch().await(5, TimeUnit.SECONDS));
ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
ClientMessage message = session.createMessage(true);
setBody(0, message);
producer.send(message);
}
use of org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy in project activemq-artemis by apache.
the class FailBackAutoTest method testAutoFailback.
@Test
public void testAutoFailback() throws Exception {
((SharedStoreSlavePolicy) backupServer.getServer().getHAPolicy()).setRestartBackup(false);
createSessionFactory();
final CountDownLatch latch = new CountDownLatch(1);
ClientSession session = sendAndConsume(sf, true);
CountDownSessionFailureListener listener = new CountDownSessionFailureListener(latch, session);
session.addFailureListener(listener);
liveServer.crash();
assertTrue(latch.await(5, TimeUnit.SECONDS));
log.info("backup (nowLive) topology = " + backupServer.getServer().getClusterManager().getDefaultConnection(null).getTopology().describe());
log.info("Server Crash!!!");
ClientProducer producer = session.createProducer(ADDRESS);
ClientMessage message = session.createMessage(true);
setBody(0, message);
producer.send(message);
verifyMessageOnServer(1, 1);
session.removeFailureListener(listener);
final CountDownLatch latch2 = new CountDownLatch(1);
listener = new CountDownSessionFailureListener(latch2, session);
session.addFailureListener(listener);
log.info("******* starting live server back");
liveServer.start();
Thread.sleep(1000);
System.out.println("After failback: " + locator.getTopology().describe());
assertTrue(latch2.await(5, TimeUnit.SECONDS));
message = session.createMessage(true);
setBody(1, message);
producer.send(message);
session.close();
verifyMessageOnServer(0, 1);
wrapUpSessionFactory();
}
use of org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy in project activemq-artemis by apache.
the class FailBackAutoTest method testFailBack.
/**
* Basic fail-back test.
*
* @throws Exception
*/
@Test
public void testFailBack() throws Exception {
((SharedStoreSlavePolicy) backupServer.getServer().getHAPolicy()).setRestartBackup(false);
createSessionFactory();
ClientSession session = sendAndConsume(sf, true);
ClientProducer producer = session.createProducer(ADDRESS);
sendMessages(session, producer, NUM_MESSAGES);
session.commit();
crash(session);
session.start();
ClientConsumer consumer = session.createConsumer(ADDRESS);
receiveMessages(consumer, 0, NUM_MESSAGES, true);
producer = session.createProducer(ADDRESS);
sendMessages(session, producer, 2 * NUM_MESSAGES);
session.commit();
assertFalse("must NOT be a backup", liveServer.getServer().getHAPolicy().isBackup());
adaptLiveConfigForReplicatedFailBack(liveServer);
CountDownSessionFailureListener listener = new CountDownSessionFailureListener(session);
session.addFailureListener(listener);
liveServer.start();
assertTrue(listener.getLatch().await(5, TimeUnit.SECONDS));
assertTrue("live initialized after restart", liveServer.getServer().waitForActivation(15, TimeUnit.SECONDS));
session.start();
receiveMessages(consumer, 0, NUM_MESSAGES, true);
}
use of org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method setFailoverOnServerShutdown.
@Override
public void setFailoverOnServerShutdown(boolean failoverOnServerShutdown) {
checkStarted();
clearIO();
try {
HAPolicy haPolicy = server.getHAPolicy();
if (haPolicy instanceof SharedStoreSlavePolicy) {
((SharedStoreSlavePolicy) haPolicy).setFailoverOnServerShutdown(failoverOnServerShutdown);
}
} finally {
blockOnIO();
}
}
use of org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy in project activemq-artemis by apache.
the class HAPolicyConfigurationTest method SharedStoreSlaveTest.
@Test
public void SharedStoreSlaveTest() throws Exception {
Configuration configuration = createConfiguration("shared-store-slave-hapolicy-config.xml");
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
try {
server.start();
Activation activation = server.getActivation();
assertTrue(activation instanceof SharedStoreBackupActivation);
HAPolicy haPolicy = server.getHAPolicy();
assertTrue(haPolicy instanceof SharedStoreSlavePolicy);
SharedStoreSlavePolicy sharedStoreSlavePolicy = (SharedStoreSlavePolicy) haPolicy;
assertFalse(sharedStoreSlavePolicy.isFailoverOnServerShutdown());
assertFalse(sharedStoreSlavePolicy.isRestartBackup());
ScaleDownPolicy scaleDownPolicy = sharedStoreSlavePolicy.getScaleDownPolicy();
assertNotNull(scaleDownPolicy);
assertEquals(scaleDownPolicy.getGroupName(), "boo!");
assertEquals(scaleDownPolicy.getDiscoveryGroup(), "wahey");
List<String> connectors = scaleDownPolicy.getConnectors();
assertNotNull(connectors);
assertEquals(connectors.size(), 0);
} finally {
server.stop();
}
}
Aggregations