Search in sources :

Example 11 with ReplicatedPolicyConfiguration

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

the class GroupingFailoverTestBase method testGroupingLocalHandlerFails.

@Test
public void testGroupingLocalHandlerFails() throws Exception {
    setupBackupServer(2, 0, isFileStorage(), isSharedStore(), isNetty());
    setupLiveServer(0, isFileStorage(), isSharedStore(), isNetty(), false);
    setupLiveServer(1, isFileStorage(), isSharedStore(), isNetty(), false);
    setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1);
    setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0);
    setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 2, 1);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 0);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.REMOTE, 1);
    setUpGroupHandler(GroupingHandlerConfiguration.TYPE.LOCAL, 2);
    if (!isSharedStore()) {
        ((ReplicatedPolicyConfiguration) servers[0].getConfiguration().getHAPolicyConfiguration()).setGroupName("group1");
        ((ReplicatedPolicyConfiguration) servers[1].getConfiguration().getHAPolicyConfiguration()).setGroupName("group2");
        ((ReplicaPolicyConfiguration) servers[2].getConfiguration().getHAPolicyConfiguration()).setGroupName("group1");
    }
    startServers(0, 1, 2);
    setupSessionFactory(0, isNetty());
    setupSessionFactory(1, isNetty());
    createQueue(0, "queues.testaddress", "queue0", null, true);
    createQueue(1, "queues.testaddress", "queue0", null, true);
    waitForBindings(0, "queues.testaddress", 1, 0, true);
    waitForBindings(1, "queues.testaddress", 1, 0, true);
    addConsumer(0, 0, "queue0", null);
    addConsumer(1, 1, "queue0", null);
    waitForBindings(0, "queues.testaddress", 1, 1, false);
    waitForBindings(1, "queues.testaddress", 1, 1, false);
    waitForBindings(0, "queues.testaddress", 1, 1, true);
    waitForBindings(1, "queues.testaddress", 1, 1, true);
    waitForTopology(servers[1], 2, 1);
    sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
    verifyReceiveAll(10, 0);
    if (!isSharedStore()) {
        waitForBackupTopologyAnnouncement(sfs[0]);
    }
    Thread.sleep(1000);
    closeSessionFactory(0);
    servers[0].fail(true);
    waitForServerRestart(2);
    setupSessionFactory(2, isNetty());
    addConsumer(2, 2, "queue0", null);
    waitForBindings(2, "queues.testaddress", 1, 1, true);
    sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
    verifyReceiveAll(10, 2);
}
Also used : ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) Test(org.junit.Test)

Example 12 with ReplicatedPolicyConfiguration

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

the class MultiServerTestBase method setupLiveServer.

protected Pair<ActiveMQServer, NodeManager> setupLiveServer(final int node, final boolean realFiles, final boolean sharedStorage) throws Exception {
    NodeManager nodeManager = null;
    TransportConfiguration serverConfigAcceptor = createTransportConfiguration(useNetty(), true, generateParams(node, useNetty()));
    TransportConfiguration thisConnector = createTransportConfiguration(useNetty(), false, generateParams(node, useNetty()));
    if (sharedStorage) {
        nodeManager = new InVMNodeManager(false);
    }
    Configuration configuration = createBasicConfig(node).setJournalMaxIO_AIO(1000).setThreadPoolMaxSize(10).clearAcceptorConfigurations().addAcceptorConfiguration(serverConfigAcceptor).addConnectorConfiguration("thisConnector", thisConnector).setHAPolicyConfiguration(sharedStorage ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration());
    List<String> targetServersOnConnection = new ArrayList<>();
    for (int targetNode = 0; targetNode < getNumberOfServers(); targetNode++) {
        if (targetNode == node) {
            continue;
        }
        String targetConnectorName = "target-" + targetNode;
        TransportConfiguration targetServer = createTransportConfiguration(useNetty(), false, generateParams(targetNode, useNetty()));
        configuration.getConnectorConfigurations().put(targetConnectorName, targetServer);
        targetServersOnConnection.add(targetConnectorName);
        // The connector towards a backup.. just to have a reference so bridges can connect to backups on their configs
        String backupConnectorName = "backup-" + targetNode;
        TransportConfiguration backupConnector = createTransportConfiguration(useNetty(), false, generateParams(targetNode + getNumberOfServers(), useNetty()));
        configuration.getConnectorConfigurations().put(backupConnectorName, backupConnector);
    }
    ClusterConnectionConfiguration clusterConf = new ClusterConnectionConfiguration().setName("localCluster" + node).setAddress("cluster-queues").setConnectorName("thisConnector").setRetryInterval(100).setConfirmationWindowSize(1024).setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND).setStaticConnectors(targetServersOnConnection);
    configuration.getClusterConfigurations().add(clusterConf);
    ActiveMQServer server;
    if (sharedStorage) {
        server = createInVMFailoverServer(realFiles, configuration, nodeManager, node);
    } else {
        server = createServer(realFiles, configuration);
    }
    server.setIdentity(this.getClass().getSimpleName() + "/Live(" + node + ")");
    addServer(server);
    return new Pair<>(server, nodeManager);
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) Configuration(org.apache.activemq.artemis.core.config.Configuration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) 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) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ArrayList(java.util.ArrayList) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) NodeManager(org.apache.activemq.artemis.core.server.NodeManager) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) Pair(org.apache.activemq.artemis.api.core.Pair)

Example 13 with ReplicatedPolicyConfiguration

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

the class AutomaticColocatedQuorumVoteTest method getConfiguration.

private Configuration getConfiguration(String identity, boolean scaleDown, TransportConfiguration liveConnector, TransportConfiguration liveAcceptor, TransportConfiguration... otherLiveNodes) throws Exception {
    Configuration configuration = createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(liveAcceptor).addConnectorConfiguration(liveConnector.getName(), liveConnector).setJournalDirectory(getJournalDir() + identity).setBindingsDirectory(getBindingsDir() + identity).setLargeMessagesDirectory(getLargeMessagesDir() + identity).setPagingDirectory(getPageDir() + identity).addQueueConfiguration(new CoreQueueConfiguration().setAddress("testQueue").setName("testQueue"));
    List<String> transportConfigurationList = new ArrayList<>();
    final ColocatedPolicyConfiguration haPolicy = new ColocatedPolicyConfiguration();
    for (TransportConfiguration otherLiveNode : otherLiveNodes) {
        configuration.addConnectorConfiguration(otherLiveNode.getName(), otherLiveNode);
        transportConfigurationList.add(otherLiveNode.getName());
        haPolicy.getExcludedConnectors().add(otherLiveNode.getName());
    }
    String[] input = new String[transportConfigurationList.size()];
    transportConfigurationList.toArray(input);
    configuration.addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), input));
    haPolicy.setBackupPortOffset(100);
    haPolicy.setBackupRequestRetries(-1);
    haPolicy.setBackupRequestRetryInterval(500);
    haPolicy.setMaxBackups(1);
    haPolicy.setRequestBackup(true);
    configuration.setHAPolicyConfiguration(haPolicy);
    if (!replicated) {
        SharedStoreMasterPolicyConfiguration ssmc = new SharedStoreMasterPolicyConfiguration();
        SharedStoreSlavePolicyConfiguration sssc = new SharedStoreSlavePolicyConfiguration();
        haPolicy.setLiveConfig(ssmc);
        haPolicy.setBackupConfig(sssc);
        if (scaleDown) {
            sssc.setScaleDownConfiguration(new ScaleDownConfiguration());
        }
    } else {
        ReplicatedPolicyConfiguration rpc = new ReplicatedPolicyConfiguration();
        ReplicaPolicyConfiguration rpc2 = new ReplicaPolicyConfiguration();
        haPolicy.setLiveConfig(rpc);
        haPolicy.setBackupConfig(rpc2);
        if (scaleDown) {
            rpc2.setScaleDownConfiguration(new ScaleDownConfiguration());
        }
    }
    return configuration;
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) ColocatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ColocatedPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) ArrayList(java.util.ArrayList) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) ColocatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ColocatedPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)

Example 14 with ReplicatedPolicyConfiguration

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

the class MultipleServerFailoverTestBase method setUp.

@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    liveServers = new ArrayList<>();
    backupServers = new ArrayList<>();
    backupConfigs = new ArrayList<>();
    liveConfigs = new ArrayList<>();
    for (int i = 0; i < getLiveServerCount(); i++) {
        HAPolicyConfiguration haPolicyConfiguration = null;
        if (isSharedStore()) {
            haPolicyConfiguration = new SharedStoreMasterPolicyConfiguration();
        } else {
            haPolicyConfiguration = new ReplicatedPolicyConfiguration();
            if (getNodeGroupName() != null) {
                ((ReplicatedPolicyConfiguration) haPolicyConfiguration).setGroupName(getNodeGroupName() + "-" + i);
            }
        }
        Configuration configuration = createDefaultConfig(isNetty()).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true, i)).setHAPolicyConfiguration(haPolicyConfiguration);
        if (!isSharedStore()) {
            configuration.setBindingsDirectory(getBindingsDir(i, false));
            configuration.setJournalDirectory(getJournalDir(i, false));
            configuration.setPagingDirectory(getPageDir(i, false));
            configuration.setLargeMessagesDirectory(getLargeMessagesDir(i, false));
        } else {
        // todo
        }
        TransportConfiguration livetc = getConnectorTransportConfiguration(true, i);
        configuration.addConnectorConfiguration(livetc.getName(), livetc);
        List<String> connectors = new ArrayList<>();
        for (int j = 0; j < getLiveServerCount(); j++) {
            if (j != i) {
                TransportConfiguration staticTc = getConnectorTransportConfiguration(true, j);
                configuration.getConnectorConfigurations().put(staticTc.getName(), staticTc);
                connectors.add(staticTc.getName());
            }
        }
        String[] input = new String[connectors.size()];
        connectors.toArray(input);
        configuration.addClusterConfiguration(basicClusterConnectionConfig(livetc.getName(), input));
        liveConfigs.add(configuration);
        ActiveMQServer server = createServer(true, configuration);
        TestableServer activeMQServer = new SameProcessActiveMQServer(server);
        activeMQServer.setIdentity("Live-" + i);
        liveServers.add(activeMQServer);
    }
    for (int i = 0; i < getBackupServerCount(); i++) {
        HAPolicyConfiguration haPolicyConfiguration = null;
        if (isSharedStore()) {
            haPolicyConfiguration = new SharedStoreSlavePolicyConfiguration();
        } else {
            haPolicyConfiguration = new ReplicaPolicyConfiguration();
            if (getNodeGroupName() != null) {
                ((ReplicaPolicyConfiguration) haPolicyConfiguration).setGroupName(getNodeGroupName() + "-" + i);
            }
        }
        Configuration configuration = createDefaultConfig(isNetty()).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(false, i)).setHAPolicyConfiguration(haPolicyConfiguration);
        if (!isSharedStore()) {
            configuration.setBindingsDirectory(getBindingsDir(i, true));
            configuration.setJournalDirectory(getJournalDir(i, true));
            configuration.setPagingDirectory(getPageDir(i, true));
            configuration.setLargeMessagesDirectory(getLargeMessagesDir(i, true));
        } else {
        // todo
        }
        TransportConfiguration backuptc = getConnectorTransportConfiguration(false, i);
        configuration.addConnectorConfiguration(backuptc.getName(), backuptc);
        List<String> connectors = new ArrayList<>();
        for (int j = 0; j < getBackupServerCount(); j++) {
            TransportConfiguration staticTc = getConnectorTransportConfiguration(true, j);
            configuration.addConnectorConfiguration(staticTc.getName(), staticTc);
            connectors.add(staticTc.getName());
        }
        for (int j = 0; j < getBackupServerCount(); j++) {
            if (j != i) {
                TransportConfiguration staticTc = getConnectorTransportConfiguration(false, j);
                configuration.getConnectorConfigurations().put(staticTc.getName(), staticTc);
                connectors.add(staticTc.getName());
            }
        }
        String[] input = new String[connectors.size()];
        connectors.toArray(input);
        configuration.addClusterConfiguration(basicClusterConnectionConfig(backuptc.getName(), input));
        backupConfigs.add(configuration);
        ActiveMQServer server = createServer(true, configuration);
        TestableServer testableServer = new SameProcessActiveMQServer(server);
        testableServer.setIdentity("Backup-" + i);
        backupServers.add(testableServer);
    }
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ArrayList(java.util.ArrayList) TestableServer(org.apache.activemq.artemis.tests.integration.cluster.util.TestableServer) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) SameProcessActiveMQServer(org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer) ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) SameProcessActiveMQServer(org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) Before(org.junit.Before)

Example 15 with ReplicatedPolicyConfiguration

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

the class SingleLiveMultipleBackupsFailoverTest method createLiveConfig.

protected void createLiveConfig(int liveNode) throws Exception {
    TransportConfiguration liveConnector = createTransportConfiguration(isNetty(), false, generateParams(liveNode, isNetty()));
    Configuration config0 = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(isNetty(), true, generateParams(liveNode, isNetty()))).setHAPolicyConfiguration(sharedStore ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName())).addConnectorConfiguration(liveConnector.getName(), liveConnector).setBindingsDirectory(getBindingsDir() + "_" + liveNode).setJournalDirectory(getJournalDir() + "_" + liveNode).setPagingDirectory(getPageDir() + "_" + liveNode).setLargeMessagesDirectory(getLargeMessagesDir() + "_" + liveNode);
    SameProcessActiveMQServer server = new SameProcessActiveMQServer(createInVMFailoverServer(true, config0, nodeManager, liveNode));
    addActiveMQComponent(server);
    servers.put(liveNode, server);
}
Also used : 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) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) SameProcessActiveMQServer(org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration)

Aggregations

ReplicatedPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration)17 ReplicaPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)12 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)10 Configuration (org.apache.activemq.artemis.core.config.Configuration)10 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)10 SharedStoreSlavePolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration)10 ArrayList (java.util.ArrayList)5 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)5 ClusterConnectionConfiguration (org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)5 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)5 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)4 SameProcessActiveMQServer (org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer)4 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)3 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)3 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)3 LiveOnlyPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration)3 GroupingHandlerConfiguration (org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration)3 Test (org.junit.Test)3 UDPBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)2 NodeManager (org.apache.activemq.artemis.core.server.NodeManager)2