use of org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy in project activemq-artemis by apache.
the class HAPolicyConfigurationTest method liveOnlyTest.
@Test
public void liveOnlyTest() throws Exception {
Configuration configuration = createConfiguration("live-only-hapolicy-config.xml");
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
try {
server.start();
Activation activation = server.getActivation();
assertTrue(activation instanceof LiveOnlyActivation);
HAPolicy haPolicy = server.getHAPolicy();
assertTrue(haPolicy instanceof LiveOnlyPolicy);
LiveOnlyPolicy liveOnlyPolicy = (LiveOnlyPolicy) haPolicy;
ScaleDownPolicy scaleDownPolicy = liveOnlyPolicy.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();
}
}
use of org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy 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.LiveOnlyPolicy in project activemq-artemis by apache.
the class HAPolicyConfigurationTest method liveOnlyTest.
private void liveOnlyTest(String file) throws Exception {
Configuration configuration = createConfiguration(file);
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
try {
server.start();
Activation activation = server.getActivation();
assertTrue(activation instanceof LiveOnlyActivation);
HAPolicy haPolicy = server.getHAPolicy();
assertTrue(haPolicy instanceof LiveOnlyPolicy);
LiveOnlyPolicy liveOnlyPolicy = (LiveOnlyPolicy) haPolicy;
ScaleDownPolicy scaleDownPolicy = liveOnlyPolicy.getScaleDownPolicy();
assertNull(scaleDownPolicy);
} finally {
server.stop();
}
}
use of org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy in project activemq-artemis by apache.
the class HAPolicyConfigurationTest method liveOnlyTest2.
@Test
public void liveOnlyTest2() throws Exception {
Configuration configuration = createConfiguration("live-only-hapolicy-config2.xml");
ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
try {
server.start();
Activation activation = server.getActivation();
assertTrue(activation instanceof LiveOnlyActivation);
HAPolicy haPolicy = server.getHAPolicy();
assertTrue(haPolicy instanceof LiveOnlyPolicy);
LiveOnlyPolicy liveOnlyPolicy = (LiveOnlyPolicy) haPolicy;
ScaleDownPolicy scaleDownPolicy = liveOnlyPolicy.getScaleDownPolicy();
assertNotNull(scaleDownPolicy);
assertFalse(scaleDownPolicy.isEnabled());
assertEquals(scaleDownPolicy.getGroupName(), "boo!");
assertEquals(scaleDownPolicy.getDiscoveryGroup(), null);
List<String> connectors = scaleDownPolicy.getConnectors();
assertNotNull(connectors);
assertEquals(connectors.size(), 2);
assertTrue(connectors.contains("sd-connector1"));
assertTrue(connectors.contains("sd-connector2"));
} finally {
server.stop();
}
}
Aggregations