Search in sources :

Example 1 with ReplicaPolicyConfiguration

use of org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration in project wildfly by wildfly.

the class ReplicationSlaveDefinition method buildConfiguration.

static HAPolicyConfiguration buildConfiguration(OperationContext context, ModelNode model) throws OperationFailedException {
    ReplicaPolicyConfiguration haPolicyConfiguration = new ReplicaPolicyConfiguration().setAllowFailBack(ALLOW_FAILBACK.resolveModelAttribute(context, model).asBoolean()).setInitialReplicationSyncTimeout(INITIAL_REPLICATION_SYNC_TIMEOUT.resolveModelAttribute(context, model).asLong()).setMaxSavedReplicatedJournalsSize(MAX_SAVED_REPLICATED_JOURNAL_SIZE.resolveModelAttribute(context, model).asInt()).setScaleDownConfiguration(addScaleDownConfiguration(context, model)).setRestartBackup(RESTART_BACKUP.resolveModelAttribute(context, model).asBoolean());
    ModelNode clusterName = CLUSTER_NAME.resolveModelAttribute(context, model);
    if (clusterName.isDefined()) {
        haPolicyConfiguration.setClusterName(clusterName.asString());
    }
    ModelNode groupName = GROUP_NAME.resolveModelAttribute(context, model);
    if (groupName.isDefined()) {
        haPolicyConfiguration.setGroupName(groupName.asString());
    }
    return haPolicyConfiguration;
}
Also used : ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) ModelNode(org.jboss.dmr.ModelNode)

Example 2 with ReplicaPolicyConfiguration

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

the class JMSFailoverTest method startServers.

/**
 * @throws Exception
 */
protected void startServers() throws Exception {
    final boolean sharedStore = true;
    NodeManager nodeManager = new InVMNodeManager(!sharedStore);
    backuptc = new TransportConfiguration(INVM_CONNECTOR_FACTORY, backupParams);
    livetc = new TransportConfiguration(INVM_CONNECTOR_FACTORY);
    liveAcceptortc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY);
    backupAcceptortc = new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams);
    backupParams.put(TransportConstants.SERVER_ID_PROP_NAME, 1);
    backupConf = createBasicConfig().addAcceptorConfiguration(backupAcceptortc).addConnectorConfiguration(livetc.getName(), livetc).addConnectorConfiguration(backuptc.getName(), backuptc).setSecurityEnabled(false).setJournalType(getDefaultJournalType()).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams)).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).setPersistenceEnabled(true).setHAPolicyConfiguration(sharedStore ? new SharedStoreSlavePolicyConfiguration() : new ReplicaPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(backuptc.getName(), livetc.getName()));
    backupServer = addServer(new InVMNodeManagerServer(backupConf, nodeManager));
    backupJMSServer = new JMSServerManagerImpl(backupServer);
    backupJMSServer.setRegistry(new JndiBindingRegistry(ctx2));
    backupJMSServer.getActiveMQServer().setIdentity("JMSBackup");
    log.info("Starting backup");
    backupJMSServer.start();
    liveConf = createBasicConfig().setJournalDirectory(getJournalDir()).setBindingsDirectory(getBindingsDir()).setSecurityEnabled(false).addAcceptorConfiguration(liveAcceptortc).setJournalType(getDefaultJournalType()).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).addConnectorConfiguration(livetc.getName(), livetc).setPersistenceEnabled(true).setHAPolicyConfiguration(sharedStore ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(livetc.getName()));
    liveServer = addServer(new InVMNodeManagerServer(liveConf, nodeManager));
    liveJMSServer = new JMSServerManagerImpl(liveServer);
    liveJMSServer.setRegistry(new JndiBindingRegistry(ctx1));
    liveJMSServer.getActiveMQServer().setIdentity("JMSLive");
    log.info("Starting life");
    liveJMSServer.start();
    JMSUtil.waitForServer(backupServer);
}
Also used : InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) NodeManager(org.apache.activemq.artemis.core.server.NodeManager) InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) InVMNodeManagerServer(org.apache.activemq.artemis.tests.util.InVMNodeManagerServer) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)

Example 3 with ReplicaPolicyConfiguration

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

the class ClusterTestBase method setupBackupServer.

/**
 * Server lacks a {@link ClusterConnectionConfiguration} necessary for the remote (replicating)
 * backup case.
 * <br>
 * Use
 * {@link #setupClusterConnectionWithBackups(String, String, org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType, int, boolean, int, int[])}
 * to add it.
 *
 * @param node
 * @param liveNode
 * @param fileStorage
 * @param sharedStorage
 * @param netty
 * @throws Exception
 */
protected void setupBackupServer(final int node, final int liveNode, final boolean fileStorage, final boolean sharedStorage, final boolean netty) throws Exception {
    if (servers[node] != null) {
        throw new IllegalArgumentException("Already a server at node " + node);
    }
    TransportConfiguration liveConfig = createTransportConfiguration(netty, false, generateParams(liveNode, netty));
    TransportConfiguration backupConfig = createTransportConfiguration(netty, false, generateParams(node, netty));
    TransportConfiguration acceptorConfig = createTransportConfiguration(netty, true, generateParams(node, netty));
    Configuration configuration = createBasicConfig(sharedStorage ? liveNode : node).clearAcceptorConfigurations().addAcceptorConfiguration(acceptorConfig).addConnectorConfiguration(liveConfig.getName(), liveConfig).addConnectorConfiguration(backupConfig.getName(), backupConfig).setHAPolicyConfiguration(sharedStorage ? new SharedStoreSlavePolicyConfiguration() : new ReplicaPolicyConfiguration());
    ActiveMQServer server;
    if (sharedStorage) {
        server = createInVMFailoverServer(true, configuration, nodeManagers[liveNode], liveNode);
    } else {
        boolean enablePersistency = fileStorage ? true : configuration.isPersistenceEnabled();
        server = addServer(ActiveMQServers.newActiveMQServer(configuration, enablePersistency));
    }
    server.setIdentity(this.getClass().getSimpleName() + "/Backup(" + node + " of live " + liveNode + ")");
    servers[node] = addServer(server);
}
Also used : ActiveMQServer(org.apache.activemq.artemis.core.server.ActiveMQServer) GroupingHandlerConfiguration(org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) 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) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) HAPolicyConfiguration(org.apache.activemq.artemis.core.config.HAPolicyConfiguration) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)

Example 4 with ReplicaPolicyConfiguration

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

the class GroupingFailoverTestBase method testGroupingLocalHandlerFailsMultipleGroups.

@Test
public void testGroupingLocalHandlerFailsMultipleGroups() 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);
    waitForBindings(0, "queues.testaddress", 1, 0, true);
    createQueue(1, "queues.testaddress", "queue0", null, 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);
    sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
    sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id2"));
    sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id3"));
    sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id4"));
    sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id5"));
    sendWithProperty(0, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id6"));
    verifyReceiveAllWithGroupIDRoundRobin(0, 30, 0, 1);
    if (!isSharedStore()) {
        SharedNothingBackupActivation backupActivation = (SharedNothingBackupActivation) servers[2].getActivation();
        assertTrue(backupActivation.waitForBackupSync(10, TimeUnit.SECONDS));
    }
    closeSessionFactory(0);
    servers[0].fail(true);
    waitForServerRestart(2);
    setupSessionFactory(2, isNetty());
    addConsumer(2, 2, "queue0", null);
    waitForBindings(2, "queues.testaddress", 1, 1, true);
    waitForBindings(2, "queues.testaddress", 1, 1, false);
    waitForBindings(1, "queues.testaddress", 1, 1, true);
    waitForBindings(1, "queues.testaddress", 1, 1, false);
    sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id1"));
    sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id2"));
    sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id3"));
    sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id4"));
    sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id5"));
    sendWithProperty(2, "queues.testaddress", 10, false, Message.HDR_GROUP_ID, new SimpleString("id6"));
    verifyReceiveAllWithGroupIDRoundRobin(2, 30, 1, 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) SharedNothingBackupActivation(org.apache.activemq.artemis.core.server.impl.SharedNothingBackupActivation) Test(org.junit.Test)

Example 5 with ReplicaPolicyConfiguration

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

the class MultipleLivesMultipleBackupsFailoverTest method createBackupConfig.

protected void createBackupConfig(NodeManager nodeManager, int liveNode, int nodeid, boolean createClusterConnections, int[] otherBackupNodes, int... otherClusterNodes) throws Exception {
    Configuration config1 = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(isNetty(), true, generateParams(nodeid, isNetty()))).setHAPolicyConfiguration(sharedStore ? new SharedStoreSlavePolicyConfiguration() : new ReplicaPolicyConfiguration()).setBindingsDirectory(getBindingsDir() + "_" + liveNode).setJournalDirectory(getJournalDir() + "_" + liveNode).setPagingDirectory(getPageDir() + "_" + liveNode).setLargeMessagesDirectory(getLargeMessagesDir() + "_" + liveNode);
    for (int node : otherBackupNodes) {
        TransportConfiguration liveConnector = createTransportConfiguration(isNetty(), false, generateParams(node, isNetty()));
        config1.addConnectorConfiguration(liveConnector.getName(), liveConnector);
    }
    TransportConfiguration backupConnector = createTransportConfiguration(isNetty(), false, generateParams(nodeid, isNetty()));
    config1.addConnectorConfiguration(backupConnector.getName(), backupConnector);
    String[] clusterNodes = new String[otherClusterNodes.length];
    for (int i = 0; i < otherClusterNodes.length; i++) {
        TransportConfiguration connector = createTransportConfiguration(isNetty(), false, generateParams(otherClusterNodes[i], isNetty()));
        config1.addConnectorConfiguration(connector.getName(), connector);
        clusterNodes[i] = connector.getName();
    }
    config1.addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), clusterNodes));
    servers.put(nodeid, new SameProcessActiveMQServer(createInVMFailoverServer(true, config1, nodeManager, liveNode)));
}
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) 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) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)

Aggregations

ReplicaPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)13 ReplicatedPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration)10 SharedStoreSlavePolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration)7 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)6 Configuration (org.apache.activemq.artemis.core.config.Configuration)6 SharedStoreMasterPolicyConfiguration (org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration)6 ArrayList (java.util.ArrayList)3 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)3 ClusterConnectionConfiguration (org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)3 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)3 SameProcessActiveMQServer (org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer)3 HAPolicyConfiguration (org.apache.activemq.artemis.core.config.HAPolicyConfiguration)2 NodeManager (org.apache.activemq.artemis.core.server.NodeManager)2 InVMNodeManager (org.apache.activemq.artemis.core.server.impl.InVMNodeManager)2 Test (org.junit.Test)2 File (java.io.File)1 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)1 BroadcastGroupConfiguration (org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration)1 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)1 CoreQueueConfiguration (org.apache.activemq.artemis.core.config.CoreQueueConfiguration)1