Search in sources :

Example 6 with ReplicaPolicy

use of org.apache.activemq.artemis.core.server.cluster.ha.ReplicaPolicy 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 7 with ReplicaPolicy

use of org.apache.activemq.artemis.core.server.cluster.ha.ReplicaPolicy in project activemq-artemis by apache.

the class HAPolicyConfigurationTest method ReplicaTest2.

@Test
public void ReplicaTest2() throws Exception {
    Configuration configuration = createConfiguration("replica-hapolicy-config2.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof SharedNothingBackupActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof ReplicaPolicy);
        ReplicaPolicy replicaPolicy = (ReplicaPolicy) haPolicy;
        assertEquals(replicaPolicy.getGroupName(), "tiddles");
        assertEquals(replicaPolicy.getMaxSavedReplicatedJournalsSize(), 22);
        assertEquals(replicaPolicy.getClusterName(), "33rrrrr");
        assertFalse(replicaPolicy.isRestartBackup());
        ScaleDownPolicy scaleDownPolicy = replicaPolicy.getScaleDownPolicy();
        assertNotNull(scaleDownPolicy);
        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 : 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) ReplicaPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ReplicaPolicy) 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) SharedNothingBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation) Test(org.junit.Test)

Aggregations

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