Search in sources :

Example 16 with HAPolicy

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

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

the class HAPolicyConfigurationTest method SharedStoreMasterTest.

@Test
public void SharedStoreMasterTest() throws Exception {
    Configuration configuration = createConfiguration("shared-store-master-hapolicy-config.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof SharedStoreLiveActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof SharedStoreMasterPolicy);
        SharedStoreMasterPolicy masterPolicy = (SharedStoreMasterPolicy) haPolicy;
        assertFalse(masterPolicy.isFailoverOnServerShutdown());
    } 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) SharedStoreLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation) 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) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) SharedStoreMasterPolicy(org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreMasterPolicy) Test(org.junit.Test)

Example 18 with HAPolicy

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

Example 19 with HAPolicy

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

Example 20 with HAPolicy

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

the class HAPolicyConfigurationTest method ReplicatedTest.

@Test
public void ReplicatedTest() throws Exception {
    Configuration configuration = createConfiguration("replicated-hapolicy-config.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof SharedNothingLiveActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof ReplicatedPolicy);
        ReplicatedPolicy replicatedPolicy = (ReplicatedPolicy) haPolicy;
        assertEquals(replicatedPolicy.getGroupName(), "purple");
        assertTrue(replicatedPolicy.isCheckForLiveServer());
        assertEquals(replicatedPolicy.getClusterName(), "abcdefg");
        assertEquals(replicatedPolicy.getInitialReplicationSyncTimeout(), 9876);
    } 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) SharedNothingLiveActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation) HAPolicy(org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy) ReplicatedPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy) 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) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) 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