Search in sources :

Example 11 with HAPolicy

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);
    }
}
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 12 with HAPolicy

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

Example 13 with HAPolicy

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

Example 14 with HAPolicy

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

Example 15 with HAPolicy

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();
    }
}
Also used : SharedStoreSlavePolicy(org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy) 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) SharedStoreBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation) Test(org.junit.Test)

Aggregations

HAPolicy (org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy)20 Test (org.junit.Test)16 Configuration (org.apache.activemq.artemis.core.config.Configuration)15 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)15 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)15 Activation (org.apache.activemq.artemis.core.server.impl.Activation)15 ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)15 ColocatedActivation (org.apache.activemq.artemis.core.server.impl.ColocatedActivation)15 LiveOnlyActivation (org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation)15 SharedNothingBackupActivation (org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation)15 SharedNothingLiveActivation (org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation)15 SharedStoreBackupActivation (org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation)15 SharedStoreLiveActivation (org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation)15 ScaleDownPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy)10 ReplicaPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ReplicaPolicy)7 SharedStoreSlavePolicy (org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy)7 ColocatedPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy)4 LiveOnlyPolicy (org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy)4 ReplicatedPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy)3 SharedStoreMasterPolicy (org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreMasterPolicy)3