Search in sources :

Example 6 with Activation

use of org.apache.activemq.artemis.core.server.impl.Activation in project activemq-artemis by apache.

the class HAPolicyConfigurationTest method colocatedTest.

@Test
public void colocatedTest() throws Exception {
    Configuration configuration = createConfiguration("colocated-hapolicy-config.xml");
    ActiveMQServerImpl server = new ActiveMQServerImpl(configuration);
    try {
        server.start();
        Activation activation = server.getActivation();
        assertTrue(activation instanceof ColocatedActivation);
        HAPolicy haPolicy = server.getHAPolicy();
        assertTrue(haPolicy instanceof ColocatedPolicy);
        ColocatedPolicy colocatedPolicy = (ColocatedPolicy) haPolicy;
        ReplicatedPolicy livePolicy = (ReplicatedPolicy) colocatedPolicy.getLivePolicy();
        assertNotNull(livePolicy);
        assertEquals(livePolicy.getGroupName(), "purple");
        assertTrue(livePolicy.isCheckForLiveServer());
        assertEquals(livePolicy.getClusterName(), "abcdefg");
        ReplicaPolicy backupPolicy = (ReplicaPolicy) colocatedPolicy.getBackupPolicy();
        assertNotNull(backupPolicy);
        assertEquals(backupPolicy.getGroupName(), "tiddles");
        assertEquals(backupPolicy.getMaxSavedReplicatedJournalsSize(), 22);
        assertEquals(backupPolicy.getClusterName(), "33rrrrr");
        assertFalse(backupPolicy.isRestartBackup());
    } finally {
        server.stop();
    }
}
Also used : ColocatedActivation(org.apache.activemq.artemis.core.server.impl.ColocatedActivation) 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) 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) ColocatedPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy) Test(org.junit.Test)

Example 7 with Activation

use of org.apache.activemq.artemis.core.server.impl.Activation in project activemq-artemis by apache.

the class HAPolicyConfigurationTest method ReplicaTest.

@Test
public void ReplicaTest() throws Exception {
    Configuration configuration = createConfiguration("replica-hapolicy-config.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());
        assertTrue(replicaPolicy.isAllowFailback());
        assertEquals(replicaPolicy.getInitialReplicationSyncTimeout(), 9876);
        ScaleDownPolicy scaleDownPolicy = replicaPolicy.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 : 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 8 with Activation

use of org.apache.activemq.artemis.core.server.impl.Activation in project activemq-artemis by apache.

the class HAPolicyConfigurationTest method SharedStoreSlaveTest3.

@Test
public void SharedStoreSlaveTest3() throws Exception {
    Configuration configuration = createConfiguration("shared-store-slave-hapolicy-config3.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;
        assertTrue(sharedStoreSlavePolicy.isFailoverOnServerShutdown());
        assertTrue(sharedStoreSlavePolicy.isRestartBackup());
        ScaleDownPolicy scaleDownPolicy = sharedStoreSlavePolicy.getScaleDownPolicy();
        assertNull(scaleDownPolicy);
    } 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)

Example 9 with Activation

use of org.apache.activemq.artemis.core.server.impl.Activation in project activemq-artemis by apache.

the class HAPolicyConfigurationTest method SharedStoreSlaveTest2.

@Test
public void SharedStoreSlaveTest2() throws Exception {
    Configuration configuration = createConfiguration("shared-store-slave-hapolicy-config2.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;
        assertTrue(sharedStoreSlavePolicy.isFailoverOnServerShutdown());
        assertTrue(sharedStoreSlavePolicy.isRestartBackup());
        ScaleDownPolicy scaleDownPolicy = sharedStoreSlavePolicy.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 : 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)

Example 10 with Activation

use of org.apache.activemq.artemis.core.server.impl.Activation in project activemq-artemis by apache.

the class ActiveMQTestBase method waitForRemoteBackup.

/**
 * @param sessionFactoryP
 * @param seconds
 * @param waitForSync
 * @param backup
 */
public static final void waitForRemoteBackup(ClientSessionFactory sessionFactoryP, int seconds, boolean waitForSync, final ActiveMQServer backup) {
    ClientSessionFactoryInternal sessionFactory = (ClientSessionFactoryInternal) sessionFactoryP;
    final ActiveMQServerImpl actualServer = (ActiveMQServerImpl) backup;
    final long toWait = seconds * 1000;
    final long time = System.currentTimeMillis();
    int loop = 0;
    while (true) {
        Activation activation = actualServer.getActivation();
        boolean isReplicated = !backup.getHAPolicy().isSharedStore();
        boolean isRemoteUpToDate = true;
        if (isReplicated) {
            if (activation instanceof SharedNothingBackupActivation) {
                isRemoteUpToDate = backup.isReplicaSync();
            } else {
                // we may have already failed over and changed the Activation
                if (actualServer.isStarted()) {
                    // let it fail a few time to have time to start stopping in the case of waiting to failback
                    isRemoteUpToDate = loop++ > 10;
                } else {
                    // we could be waiting to failback or restart if the server is stopping
                    isRemoteUpToDate = false;
                }
            }
        }
        if ((sessionFactory == null || sessionFactory.getBackupConnector() != null) && (isRemoteUpToDate || !waitForSync) && (!waitForSync || actualServer.getBackupManager() != null && actualServer.getBackupManager().isBackupAnnounced())) {
            break;
        }
        if (System.currentTimeMillis() > (time + toWait)) {
            fail("backup started? (" + actualServer.isStarted() + "). Finished synchronizing (" + (activation) + "). SessionFactory!=null ? " + (sessionFactory != null) + " || sessionFactory.getBackupConnector()==" + (sessionFactory != null ? sessionFactory.getBackupConnector() : "not-applicable"));
        }
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            fail(e.getMessage());
        }
    }
}
Also used : ClientSessionFactoryInternal(org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal) Activation(org.apache.activemq.artemis.core.server.impl.Activation) SharedNothingBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) SharedNothingBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation)

Aggregations

Activation (org.apache.activemq.artemis.core.server.impl.Activation)17 ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)16 SharedNothingBackupActivation (org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation)16 SharedNothingLiveActivation (org.apache.activemq.artemis.core.server.impl.SharedNothingLiveActivation)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 HAPolicy (org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy)15 ColocatedActivation (org.apache.activemq.artemis.core.server.impl.ColocatedActivation)15 LiveOnlyActivation (org.apache.activemq.artemis.core.server.impl.LiveOnlyActivation)15 SharedStoreBackupActivation (org.apache.activemq.artemis.core.server.impl.SharedStoreBackupActivation)15 SharedStoreLiveActivation (org.apache.activemq.artemis.core.server.impl.SharedStoreLiveActivation)15 Test (org.junit.Test)14 ScaleDownPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy)9 ReplicaPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ReplicaPolicy)5 SharedStoreSlavePolicy (org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy)5 ColocatedPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy)4 LiveOnlyPolicy (org.apache.activemq.artemis.core.server.cluster.ha.LiveOnlyPolicy)3 ReplicatedPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy)3 SharedStoreMasterPolicy (org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreMasterPolicy)3