Search in sources :

Example 1 with SharedStoreMasterPolicy

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

the class HAPolicyConfigurationTest method colocatedTest2nullbackup.

@Test
public void colocatedTest2nullbackup() throws Exception {
    Configuration configuration = createConfiguration("colocated-hapolicy-config2-null-backup.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;
        SharedStoreMasterPolicy livePolicy = (SharedStoreMasterPolicy) colocatedPolicy.getLivePolicy();
        assertNotNull(livePolicy);
        assertFalse(livePolicy.isFailoverOnServerShutdown());
        SharedStoreSlavePolicy backupPolicy = (SharedStoreSlavePolicy) colocatedPolicy.getBackupPolicy();
        assertNotNull(backupPolicy);
    } finally {
        server.stop();
    }
}
Also used : ColocatedActivation(org.apache.activemq.artemis.core.server.impl.ColocatedActivation) 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) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) ColocatedPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy) SharedStoreMasterPolicy(org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreMasterPolicy) Test(org.junit.Test)

Example 2 with SharedStoreMasterPolicy

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

the class HAPolicyConfigurationTest method colocatedTest2.

@Test
public void colocatedTest2() throws Exception {
    Configuration configuration = createConfiguration("colocated-hapolicy-config2.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;
        SharedStoreMasterPolicy livePolicy = (SharedStoreMasterPolicy) colocatedPolicy.getLivePolicy();
        assertNotNull(livePolicy);
        assertFalse(livePolicy.isFailoverOnServerShutdown());
        SharedStoreSlavePolicy backupPolicy = (SharedStoreSlavePolicy) colocatedPolicy.getBackupPolicy();
        assertNotNull(backupPolicy);
        assertFalse(backupPolicy.isFailoverOnServerShutdown());
        assertFalse(backupPolicy.isRestartBackup());
    } finally {
        server.stop();
    }
}
Also used : ColocatedActivation(org.apache.activemq.artemis.core.server.impl.ColocatedActivation) 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) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) ColocatedPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy) SharedStoreMasterPolicy(org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreMasterPolicy) Test(org.junit.Test)

Example 3 with SharedStoreMasterPolicy

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

the class FailoverTest method testLiveAndBackupBackupComesBackNewFactory.

@Test(timeout = 120000)
public void testLiveAndBackupBackupComesBackNewFactory() throws Exception {
    locator.setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setFailoverOnInitialConnection(true).setReconnectAttempts(300).setRetryInterval(100);
    sf = createSessionFactoryAndWaitForTopology(locator, 2);
    ClientSession session = sendAndConsume(sf, true);
    CountDownSessionFailureListener listener = new CountDownSessionFailureListener(session);
    session.addFailureListener(listener);
    backupServer.stop();
    liveServer.crash();
    // To reload security or other settings that are read during startup
    beforeRestart(backupServer);
    if (!backupServer.getServer().getHAPolicy().isSharedStore()) {
        // XXX
        // this test would not make sense in the remote replication use case, without the following
        backupServer.getServer().setHAPolicy(new SharedStoreMasterPolicy());
    }
    backupServer.start();
    Assert.assertTrue("session failure listener", listener.getLatch().await(5, TimeUnit.SECONDS));
    ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
    ClientMessage message = session.createMessage(true);
    setBody(0, message);
    producer.send(message);
    session.close();
    sf.close();
    createClientSessionFactory();
    session = createSession(sf);
    ClientConsumer cc = session.createConsumer(FailoverTestBase.ADDRESS);
    session.start();
    ClientMessage cm = cc.receive(5000);
    Assert.assertNotNull(cm);
    Assert.assertEquals("message0", cm.getBodyBuffer().readString());
}
Also used : ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ClientMessage(org.apache.activemq.artemis.api.core.client.ClientMessage) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) CountDownSessionFailureListener(org.apache.activemq.artemis.tests.util.CountDownSessionFailureListener) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) SharedStoreMasterPolicy(org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreMasterPolicy) Test(org.junit.Test)

Example 4 with SharedStoreMasterPolicy

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

Aggregations

SharedStoreMasterPolicy (org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreMasterPolicy)4 Test (org.junit.Test)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 HAPolicy (org.apache.activemq.artemis.core.server.cluster.ha.HAPolicy)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 ColocatedPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ColocatedPolicy)2 SharedStoreSlavePolicy (org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy)2 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)1 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)1 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)1 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)1