use of org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy in project activemq-artemis by apache.
the class ActiveMQServerControlImpl method scaleDown.
@Override
public void scaleDown(String connector) throws Exception {
checkStarted();
clearIO();
HAPolicy haPolicy = server.getHAPolicy();
if (haPolicy instanceof LiveOnlyPolicy) {
LiveOnlyPolicy liveOnlyPolicy = (LiveOnlyPolicy) haPolicy;
if (liveOnlyPolicy.getScaleDownPolicy() == null) {
liveOnlyPolicy.setScaleDownPolicy(new ScaleDownPolicy());
}
liveOnlyPolicy.getScaleDownPolicy().setEnabled(true);
if (connector != null) {
liveOnlyPolicy.getScaleDownPolicy().getConnectors().add(0, connector);
}
server.fail(true);
}
}
use of org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy 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.HAPolicy in project activemq-artemis by apache.
the class FailoverTest method testSimpleFailover.
@Test(timeout = 120000)
public void testSimpleFailover() throws Exception {
HAPolicy haPolicy = backupServer.getServer().getHAPolicy();
simpleFailover(haPolicy instanceof ReplicaPolicy, false);
}
use of org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy in project activemq-artemis by apache.
the class FailoverTest method testFailBack.
/**
* Basic fail-back test.
*
* @throws Exception
*/
@Test(timeout = 120000)
public void testFailBack() throws Exception {
boolean doFailBack = true;
HAPolicy haPolicy = backupServer.getServer().getHAPolicy();
if (haPolicy instanceof ReplicaPolicy) {
((ReplicaPolicy) haPolicy).setMaxSavedReplicatedJournalsSize(1);
}
simpleFailover(haPolicy instanceof ReplicaPolicy, doFailBack);
}
use of org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy 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