Search in sources :

Example 6 with ActiveMQServerImpl

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

the class ShutdownOnCriticalIOErrorMoveNextTest method createServer.

ActiveMQServer createServer(String folder) throws Exception {
    final AtomicBoolean blocked = new AtomicBoolean(false);
    Configuration conf = createConfig(folder);
    ActiveMQSecurityManager securityManager = new ActiveMQJAASSecurityManager(InVMLoginModule.class.getName(), new SecurityConfiguration());
    conf.setPersistenceEnabled(true);
    ActiveMQServer server = new ActiveMQServerImpl(conf, securityManager) {

        @Override
        protected StorageManager createStorageManager() {
            JournalStorageManager storageManager = new JournalStorageManager(conf, getCriticalAnalyzer(), executorFactory, scheduledPool, ioExecutorFactory, shutdownOnCriticalIO) {

                @Override
                protected Journal createMessageJournal(Configuration config, IOCriticalErrorListener criticalErrorListener, int fileSize) {
                    return new JournalImpl(ioExecutorFactory, fileSize, config.getJournalMinFiles(), config.getJournalPoolFiles(), config.getJournalCompactMinFiles(), config.getJournalCompactPercentage(), config.getJournalFileOpenTimeout(), journalFF, "activemq-data", "amq", journalFF.getMaxIO(), 0, criticalErrorListener) {

                        @Override
                        protected void moveNextFile(boolean scheduleReclaim) throws Exception {
                            super.moveNextFile(scheduleReclaim);
                            if (blocked.get()) {
                                throw new IllegalStateException("forcibly down");
                            }
                        }
                    };
                }

                @Override
                public void storeMessage(Message message) throws Exception {
                    super.storeMessage(message);
                    blocked.set(true);
                }
            };
            this.getCriticalAnalyzer().add(storageManager);
            return storageManager;
        }
    };
    return server;
}
Also used : IOCriticalErrorListener(org.apache.activemq.artemis.core.io.IOCriticalErrorListener) Configuration(org.apache.activemq.artemis.core.config.Configuration) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) Message(org.apache.activemq.artemis.api.core.Message) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) InVMLoginModule(org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule) ActiveMQServerImpl(org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl) JournalStorageManager(org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) SecurityConfiguration(org.apache.activemq.artemis.core.config.impl.SecurityConfiguration) ActiveMQSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager) JournalImpl(org.apache.activemq.artemis.core.journal.impl.JournalImpl)

Example 7 with ActiveMQServerImpl

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

the class HAPolicyConfigurationTest method colocatedTestNullBackup.

@Test
public void colocatedTestNullBackup() throws Exception {
    Configuration configuration = createConfiguration("colocated-hapolicy-config-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;
        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);
    } 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 8 with ActiveMQServerImpl

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

the class HAPolicyConfigurationTest method ReplicaTest3.

@Test
public void ReplicaTest3() throws Exception {
    Configuration configuration = createConfiguration("replica-hapolicy-config3.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();
        assertNull(scaleDownPolicy);
    } 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 9 with ActiveMQServerImpl

use of org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl 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 10 with ActiveMQServerImpl

use of org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl 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)

Aggregations

ActiveMQServerImpl (org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl)49 Test (org.junit.Test)35 Configuration (org.apache.activemq.artemis.core.config.Configuration)28 StoreConfiguration (org.apache.activemq.artemis.core.config.StoreConfiguration)19 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)16 Activation (org.apache.activemq.artemis.core.server.impl.Activation)16 SharedNothingBackupActivation (org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation)16 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 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 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)14 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)10 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)9 ScaleDownPolicy (org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy)9 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)9 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)8 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)8