Search in sources :

Example 11 with SharedStoreSlavePolicyConfiguration

use of org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration in project activemq-artemis by apache.

the class StartStopDeadlockTest method testDeadlock.

/*
   * simple test to make sure connect still works with some network latency  built into netty
   * */
@Test
@BMRules(rules = { @BMRule(name = "Server.start wait-init", targetClass = "org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl", targetMethod = "initialisePart2", targetLocation = "ENTRY", condition = "incrementCounter(\"server-Init\") == 2", action = "System.out.println(\"server backup init\"), waitFor(\"start-init\")"), @BMRule(name = "JMSServer.stop wait-init", targetClass = "org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl", targetMethod = "stop", targetLocation = "ENTRY", action = "signalWake(\"start-init\", true)"), @BMRule(name = "StartStopDeadlockTest tearDown", targetClass = "org.apache.activemq.artemis.tests.extras.byteman.StartStopDeadlockTest", targetMethod = "tearDown", targetLocation = "ENTRY", action = "deleteCounter(\"server-Init\")") })
public void testDeadlock() throws Exception {
    // A live server that will always be crashed
    Configuration confLive = createDefaultNettyConfig().setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration());
    final ActiveMQServer serverLive = addServer(ActiveMQServers.newActiveMQServer(confLive));
    serverLive.start();
    // A backup that will be waiting to be activated
    Configuration config = createDefaultNettyConfig().setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration());
    final ActiveMQServer server = addServer(ActiveMQServers.newActiveMQServer(config, true));
    final JMSServerManagerImpl jmsServer = new JMSServerManagerImpl(server);
    final InVMNamingContext context = new InVMNamingContext();
    jmsServer.setRegistry(new JndiBindingRegistry(context));
    jmsServer.start();
    final AtomicInteger errors = new AtomicInteger(0);
    final CountDownLatch align = new CountDownLatch(2);
    final CountDownLatch startLatch = new CountDownLatch(1);
    Thread tCrasher = new Thread("tStart") {

        @Override
        public void run() {
            try {
                align.countDown();
                startLatch.await();
                System.out.println("Crashing....");
                serverLive.fail(true);
            } catch (Exception e) {
                errors.incrementAndGet();
                e.printStackTrace();
            }
        }
    };
    Thread tStop = new Thread("tStop") {

        @Override
        public void run() {
            try {
                align.countDown();
                startLatch.await();
                jmsServer.stop();
            } catch (Exception e) {
                errors.incrementAndGet();
                e.printStackTrace();
            }
        }
    };
    tCrasher.start();
    tStop.start();
    align.await();
    startLatch.countDown();
    tCrasher.join();
    tStop.join();
    assertEquals(0, errors.get());
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) CountDownLatch(java.util.concurrent.CountDownLatch) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Test(org.junit.Test) BMRules(org.jboss.byteman.contrib.bmunit.BMRules)

Example 12 with SharedStoreSlavePolicyConfiguration

use of org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration in project activemq-artemis by apache.

the class SpawnedServerSupport method createSharedFolderConfig.

static Configuration createSharedFolderConfig(String folder, int thisport, int otherport, boolean isBackup) {
    HAPolicyConfiguration haPolicyConfiguration = null;
    if (isBackup) {
        haPolicyConfiguration = new SharedStoreSlavePolicyConfiguration();
        ((SharedStoreSlavePolicyConfiguration) haPolicyConfiguration).setAllowFailBack(false);
    } else {
        haPolicyConfiguration = new SharedStoreMasterPolicyConfiguration();
    }
    Configuration config = createConfig(folder).clearAcceptorConfigurations().setJournalFileSize(15 * 1024 * 1024).addAcceptorConfiguration(createTransportConfigiguration(true, thisport)).addConnectorConfiguration("thisServer", createTransportConfigiguration(false, thisport)).addConnectorConfiguration("otherServer", createTransportConfigiguration(false, otherport)).setMessageExpiryScanPeriod(500).addClusterConfiguration(isBackup ? setupClusterConn("thisServer", "otherServer") : setupClusterConn("thisServer")).setHAPolicyConfiguration(haPolicyConfiguration);
    return config;
}
Also used : HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)

Example 13 with SharedStoreSlavePolicyConfiguration

use of org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration in project activemq-artemis by apache.

the class ReplicationTest method setupServer.

private void setupServer(boolean useNetty, boolean backup, ExtraConfigurer extraConfig, String... incomingInterceptors) throws Exception {
    TransportConfiguration liveConnector = null;
    TransportConfiguration liveAcceptor = null;
    TransportConfiguration backupConnector = null;
    TransportConfiguration backupAcceptor = null;
    if (useNetty) {
        liveConnector = TransportConfigurationUtils.getNettyConnector(true, 0);
        liveAcceptor = TransportConfigurationUtils.getNettyAcceptor(true, 0);
        backupConnector = TransportConfigurationUtils.getNettyConnector(false, 0);
        backupAcceptor = TransportConfigurationUtils.getNettyAcceptor(false, 0);
    } else {
        liveConnector = TransportConfigurationUtils.getInVMConnector(true);
        backupConnector = TransportConfigurationUtils.getInVMConnector(false);
        backupAcceptor = TransportConfigurationUtils.getInVMAcceptor(false);
    }
    Configuration liveConfig = createDefaultInVMConfig();
    Configuration backupConfig = createDefaultInVMConfig().setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration()).setBindingsDirectory(getBindingsDir(0, true)).setJournalDirectory(getJournalDir(0, true)).setPagingDirectory(getPageDir(0, true)).setLargeMessagesDirectory(getLargeMessagesDir(0, true)).setIncomingInterceptorClassNames(incomingInterceptors.length > 0 ? Arrays.asList(incomingInterceptors) : new ArrayList<String>());
    ReplicatedBackupUtils.configureReplicationPair(backupConfig, backupConnector, backupAcceptor, liveConfig, liveConnector, liveAcceptor);
    if (extraConfig != null) {
        extraConfig.config(liveConfig, backupConfig);
    }
    if (backup) {
        liveServer = createServer(liveConfig);
        liveServer.start();
        waitForComponent(liveServer);
    }
    backupServer = createServer(backupConfig);
    if (useNetty) {
        locator = createNettyNonHALocator();
    } else {
        locator = createInVMNonHALocator();
    }
    backupServer.start();
    if (backup) {
        ActiveMQTestBase.waitForRemoteBackup(null, 5, true, backupServer);
    }
    int count = 0;
    waitForReplication(count);
}
Also used : TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) ArrayList(java.util.ArrayList) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

Example 14 with SharedStoreSlavePolicyConfiguration

use of org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration in project activemq-artemis by apache.

the class FileConfigurationParser method createSharedStoreSlaveHaPolicy.

private SharedStoreSlavePolicyConfiguration createSharedStoreSlaveHaPolicy(Element policyNode) {
    SharedStoreSlavePolicyConfiguration configuration = new SharedStoreSlavePolicyConfiguration();
    configuration.setAllowFailBack(getBoolean(policyNode, "allow-failback", configuration.isAllowFailBack()));
    configuration.setFailoverOnServerShutdown(getBoolean(policyNode, "failover-on-shutdown", configuration.isFailoverOnServerShutdown()));
    configuration.setRestartBackup(getBoolean(policyNode, "restart-backup", configuration.isRestartBackup()));
    configuration.setScaleDownConfiguration(parseScaleDownConfig(policyNode));
    return configuration;
}
Also used : SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration)

Example 15 with SharedStoreSlavePolicyConfiguration

use of org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration in project activemq-artemis by apache.

the class FailoverTestBase method createConfigs.

protected void createConfigs() throws Exception {
    nodeManager = createNodeManager();
    TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
    TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
    backupConfig = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(false)).setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration()).addConnectorConfiguration(liveConnector.getName(), liveConnector).addConnectorConfiguration(backupConnector.getName(), backupConnector).addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName()));
    backupServer = createTestableServer(backupConfig);
    liveConfig = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true)).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName())).addConnectorConfiguration(liveConnector.getName(), liveConnector);
    liveServer = createTestableServer(liveConfig);
}
Also used : SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

Aggregations

SharedStoreSlavePolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration)24 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)20 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)19 Configuration (org.apache.activemq.artemis.core.config.Configuration)11 InVMNodeManager (org.apache.activemq.artemis.core.server.impl.InVMNodeManager)9 ReplicaPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)8 ReplicatedPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration)8 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)7 ArrayList (java.util.ArrayList)5 ClusterConnectionConfiguration (org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)5 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)5 SameProcessActiveMQServer (org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer)4 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)3 ScaleDownConfiguration (org.apache.activemq.artemis.core.config.ScaleDownConfiguration)3 ColocatedPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ColocatedPolicyConfiguration)3 JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)3 NodeManager (org.apache.activemq.artemis.core.server.NodeManager)3 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)3 InVMNodeManagerServer (org.apache.activemq.artemis.tests.util.InVMNodeManagerServer)3 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)2