Search in sources :

Example 1 with LiveOnlyPolicy

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();
    }
}
Also used : LiveOnlyActivation(org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation) Configuration(org.apache.activemq.artemis.core.config.Configuration) StoreConfiguration(org.apache.activemq.artemis.core.config.StoreConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) HAPolicy(org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy) SharedNothingBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation) ColocatedActivation(org.apache.activemq.artemis.core.server.impl.ColocatedActivation) Activation(org.apache.activemq.artemis.core.server.impl.Activation) SharedNothingLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation) SharedStoreLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation) SharedStoreBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation) LiveOnlyActivation(org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation) ScaleDownPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) LiveOnlyPolicy(org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy) Test(org.junit.Test)

Example 2 with LiveOnlyPolicy

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);
    }
}
Also used : HAPolicy(org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy) ScaleDownPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy) LiveOnlyPolicy(org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy)

Example 3 with LiveOnlyPolicy

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();
    }
}
Also used : LiveOnlyActivation(org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation) Configuration(org.apache.activemq.artemis.core.config.Configuration) StoreConfiguration(org.apache.activemq.artemis.core.config.StoreConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) HAPolicy(org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy) SharedNothingBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation) ColocatedActivation(org.apache.activemq.artemis.core.server.impl.ColocatedActivation) Activation(org.apache.activemq.artemis.core.server.impl.Activation) SharedNothingLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation) SharedStoreLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation) SharedStoreBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation) LiveOnlyActivation(org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation) ScaleDownPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) LiveOnlyPolicy(org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy)

Example 4 with LiveOnlyPolicy

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();
    }
}
Also used : LiveOnlyActivation(org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation) Configuration(org.apache.activemq.artemis.core.config.Configuration) StoreConfiguration(org.apache.activemq.artemis.core.config.StoreConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) HAPolicy(org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy) SharedNothingBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation) ColocatedActivation(org.apache.activemq.artemis.core.server.impl.ColocatedActivation) Activation(org.apache.activemq.artemis.core.server.impl.Activation) SharedNothingLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation) SharedStoreLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation) SharedStoreBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation) LiveOnlyActivation(org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation) ScaleDownPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) LiveOnlyPolicy(org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy) Test(org.junit.Test)

Aggregations

HAPolicy (org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy)4 LiveOnlyPolicy (org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy)4 ScaleDownPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy)4 Configuration (org.apache.activemq.artemis.core.config.Configuration)3 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)3 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)3 Activation (org.apache.activemq.artemis.core.server.impl.Activation)3 ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)3 ColocatedActivation (org.apache.activemq.artemis.core.server.impl.ColocatedActivation)3 LiveOnlyActivation (org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation)3 SharedNothingBackupActivation (org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation)3 SharedNothingLiveActivation (org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation)3 SharedStoreBackupActivation (org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation)3 SharedStoreLiveActivation (org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation)3 Test (org.junit.Test)2