Search in sources :

Example 16 with InVMNodeManager

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

the class MultipleLivesMultipleBackupsFailoverTest method testMultipleFailovers2LiveServers.

@Test
public void testMultipleFailovers2LiveServers() throws Exception {
    NodeManager nodeManager1 = new InVMNodeManager(!sharedStore);
    NodeManager nodeManager2 = new InVMNodeManager(!sharedStore);
    createLiveConfig(nodeManager1, 0, 3, 4, 5);
    createBackupConfig(nodeManager1, 0, 1, true, new int[] { 0, 2 }, 3, 4, 5);
    createBackupConfig(nodeManager1, 0, 2, true, new int[] { 0, 1 }, 3, 4, 5);
    createLiveConfig(nodeManager2, 3, 0);
    createBackupConfig(nodeManager2, 3, 4, true, new int[] { 3, 5 }, 0, 1, 2);
    createBackupConfig(nodeManager2, 3, 5, true, new int[] { 3, 4 }, 0, 1, 2);
    servers.get(0).start();
    waitForServerToStart(servers.get(0).getServer());
    servers.get(3).start();
    waitForServerToStart(servers.get(3).getServer());
    servers.get(1).start();
    waitForServerToStart(servers.get(1).getServer());
    servers.get(2).start();
    servers.get(4).start();
    waitForServerToStart(servers.get(4).getServer());
    servers.get(5).start();
    waitForServerToStart(servers.get(4).getServer());
    locator = getServerLocator(0).setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true).setReconnectAttempts(15);
    ClientSessionFactoryInternal sf = createSessionFactoryAndWaitForTopology(locator, 4, servers.get(0).getServer());
    ClientSession session = sendAndConsume(sf, true);
    System.out.println(((ServerLocatorInternal) locator).getTopology().describe());
    Thread.sleep(500);
    servers.get(0).crash(session);
    int liveAfter0 = waitForNewLive(10000, true, servers, 1, 2);
    locator2 = getServerLocator(3).setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true).setReconnectAttempts(15);
    ClientSessionFactoryInternal sf2 = createSessionFactoryAndWaitForTopology(locator2, 4);
    ClientSession session2 = sendAndConsume(sf2, true);
    System.setProperty("foo", "bar");
    servers.get(3).crash(session2);
    int liveAfter3 = waitForNewLive(10000, true, servers, 4, 5);
    locator.close();
    locator2.close();
    if (liveAfter0 == 2) {
        Thread.sleep(500);
        servers.get(1).stop();
        Thread.sleep(500);
        servers.get(2).stop();
    } else {
        Thread.sleep(500);
        servers.get(2).stop();
        Thread.sleep(500);
        servers.get(1).stop();
    }
    if (liveAfter3 == 4) {
        Thread.sleep(500);
        servers.get(5).stop();
        Thread.sleep(500);
        servers.get(4).stop();
    } else {
        Thread.sleep(500);
        servers.get(4).stop();
        Thread.sleep(500);
        servers.get(5).stop();
    }
}
Also used : InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) NodeManager(org.apache.activemq.artemis.core.server.NodeManager) ClientSessionFactoryInternal(org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ServerLocatorInternal(org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal) Test(org.junit.Test)

Example 17 with InVMNodeManager

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

the class NettyFailoverTest method createNodeManager.

@Override
protected NodeManager createNodeManager() throws Exception {
    switch(nodeManagerType) {
        case InVM:
            return new InVMNodeManager(false);
        case Jdbc:
            final ThreadFactory daemonThreadFactory = t -> {
                final Thread th = new Thread(t);
                th.setDaemon(true);
                return th;
            };
            final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(daemonThreadFactory);
            scheduledExecutorServices.add(scheduledExecutorService);
            final ExecutorService executor = Executors.newFixedThreadPool(2, daemonThreadFactory);
            executors.add(executor);
            final DatabaseStorageConfiguration dbConf = createDefaultDatabaseStorageConfiguration();
            final ExecutorFactory executorFactory = new OrderedExecutorFactory(executor);
            return JdbcNodeManager.with(dbConf, scheduledExecutorService, executorFactory, (code, message, file) -> {
                code.printStackTrace();
                Assert.fail(message);
            });
        default:
            throw new AssertionError("enum type not supported!");
    }
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) Arrays(java.util.Arrays) SameProcessActiveMQServer(org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer) OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ClientSessionFactoryInternal(org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal) DatabaseStorageConfiguration(org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration) TransportConstants(org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants) RunWith(org.junit.runner.RunWith) HashMap(java.util.HashMap) ClientConsumer(org.apache.activemq.artemis.api.core.client.ClientConsumer) ArrayList(java.util.ArrayList) ActiveMQClient(org.apache.activemq.artemis.api.core.client.ActiveMQClient) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Is(org.hamcrest.core.Is) TestableServer(org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer) Map(java.util.Map) After(org.junit.After) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) Assume(org.junit.Assume) NodeManager(org.apache.activemq.artemis.core.server.NodeManager) ThreadFactory(java.util.concurrent.ThreadFactory) ExecutorService(java.util.concurrent.ExecutorService) Parameterized(org.junit.runners.Parameterized) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) Test(org.junit.Test) ExecutorFactory(org.apache.activemq.artemis.utils.ExecutorFactory) Executors(java.util.concurrent.Executors) List(java.util.List) ClientProducer(org.apache.activemq.artemis.api.core.client.ClientProducer) JdbcNodeManager(org.apache.activemq.artemis.core.server.impl.jdbc.JdbcNodeManager) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ThreadLeakCheckRule(org.apache.activemq.artemis.utils.ThreadLeakCheckRule) Assert(org.junit.Assert) DatabaseStorageConfiguration(org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration) ThreadFactory(java.util.concurrent.ThreadFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) OrderedExecutorFactory(org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory) ExecutorFactory(org.apache.activemq.artemis.utils.ExecutorFactory) ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) ExecutorService(java.util.concurrent.ExecutorService)

Example 18 with InVMNodeManager

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

the class FailoverListenerTest method createConfigs.

@Override
protected void createConfigs() throws Exception {
    nodeManager = new InVMNodeManager(false);
    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(), backupConnector.getName())).addConnectorConfiguration(liveConnector.getName(), liveConnector).addConnectorConfiguration(backupConnector.getName(), backupConnector);
    liveServer = createTestableServer(liveConfig);
}
Also used : InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) 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)

Example 19 with InVMNodeManager

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

the class SharedStoreBackupTest method createConfigs.

@Override
protected void createConfigs() throws Exception {
    nodeManager = new InVMNodeManager(false);
    TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
    TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
    System.out.println("backup config created - mnovak");
    backupConfig = super.createDefaultConfig(false).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(false)).setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration().setScaleDownConfiguration(new ScaleDownConfiguration().setEnabled(false)).setRestartBackup(false)).addConnectorConfiguration(liveConnector.getName(), liveConnector).addConnectorConfiguration(backupConnector.getName(), backupConnector).addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName()));
    backupServer = createTestableServer(backupConfig);
    liveConfig = super.createDefaultConfig(false).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true)).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration().setFailoverOnServerShutdown(true)).addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName())).addConnectorConfiguration(liveConnector.getName(), liveConnector);
    liveServer = createTestableServer(liveConfig);
}
Also used : InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) 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)

Example 20 with InVMNodeManager

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

the class BroadcastGroupImplTest method testBroadcastDatagramLength.

/**
 * Test the broadcasted packages length.<br>
 * Broadcast and MultiCast techniques are commonly limited in size by
 * underlying hardware. Broadcast and MultiCast protocols are typically not
 * guaranteed (UDP) and as such large packages may be silently discarded by
 * underlying hardware.<br>
 * This test validates that Artemis Server does not broadcast packages above
 * a size of 1500 bytes. The limit is not derived from any normative
 * documents, but is rather derived from common MTU for network equipment.
 */
@Test
public void testBroadcastDatagramLength() throws Throwable {
    BroadcastEndpointFactoryImpl befi;
    befi = new BroadcastEndpointFactoryImpl();
    InVMNodeManager node;
    node = new InVMNodeManager(false);
    String name;
    name = "BroadcastGroupImplTest";
    BroadcastGroupImpl test;
    test = new BroadcastGroupImpl(node, name, 1000, null, befi);
    TransportConfiguration tcon;
    tcon = new TransportConfiguration(getClass().getName());
    test.addConnector(tcon);
    // Broadcast
    test.broadcastConnectors();
    // Make sure we sent one package
    assertEquals("Incorrect number of sent datagrams", 1, befi.sent);
}
Also used : InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Test(org.junit.Test)

Aggregations

InVMNodeManager (org.apache.activemq.artemis.core.server.impl.InVMNodeManager)24 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)14 Test (org.junit.Test)13 SharedStoreSlavePolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration)10 ClientConsumer (org.apache.activemq.artemis.api.core.client.ClientConsumer)9 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)9 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)9 ClientSessionFactoryInternal (org.apache.activemq.artemis.core.client.impl.ClientSessionFactoryInternal)9 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)9 NodeManager (org.apache.activemq.artemis.core.server.NodeManager)9 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)8 ArrayList (java.util.ArrayList)6 ActiveMQException (org.apache.activemq.artemis.api.core.ActiveMQException)6 CountDownLatch (java.util.concurrent.CountDownLatch)5 XAException (javax.transaction.xa.XAException)5 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)5 ActiveMQDuplicateIdException (org.apache.activemq.artemis.api.core.ActiveMQDuplicateIdException)4 ActiveMQObjectClosedException (org.apache.activemq.artemis.api.core.ActiveMQObjectClosedException)4 ActiveMQTransactionOutcomeUnknownException (org.apache.activemq.artemis.api.core.ActiveMQTransactionOutcomeUnknownException)4 ActiveMQTransactionRolledBackException (org.apache.activemq.artemis.api.core.ActiveMQTransactionRolledBackException)4