Search in sources :

Example 6 with ReplicaPolicyConfiguration

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

the class NettyFailoverTest method createTestableServer.

@Override
protected TestableServer createTestableServer(Configuration config) throws Exception {
    final boolean isBackup = config.getHAPolicyConfiguration() instanceof ReplicaPolicyConfiguration || config.getHAPolicyConfiguration() instanceof SharedStoreSlavePolicyConfiguration;
    NodeManager nodeManager = this.nodeManager;
    // create a separate NodeManager for the backup
    if (isBackup && nodeManagerType == NodeManagerType.Jdbc) {
        nodeManager = createNodeManager();
    }
    return new SameProcessActiveMQServer(createInVMFailoverServer(true, config, nodeManager, isBackup ? 2 : 1));
}
Also used : InVMNodeManager(org.apache.activemq.artemis.core.server.impl.InVMNodeManager) NodeManager(org.apache.activemq.artemis.core.server.NodeManager) JdbcNodeManager(org.apache.activemq.artemis.core.server.impl.jdbc.JdbcNodeManager) SameProcessActiveMQServer(org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)

Example 7 with ReplicaPolicyConfiguration

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

the class ReplicatedBackupUtils method configureReplicationPair.

public static void configureReplicationPair(Configuration backupConfig, TransportConfiguration backupConnector, TransportConfiguration backupAcceptor, Configuration liveConfig, TransportConfiguration liveConnector, TransportConfiguration liveAcceptor) {
    if (backupAcceptor != null) {
        backupConfig.clearAcceptorConfigurations().addAcceptorConfiguration(backupAcceptor);
    }
    if (liveAcceptor != null) {
        liveConfig.clearAcceptorConfigurations().addAcceptorConfiguration(liveAcceptor);
    }
    backupConfig.addConnectorConfiguration(BACKUP_NODE_NAME, backupConnector).addConnectorConfiguration(LIVE_NODE_NAME, liveConnector).addClusterConfiguration(ActiveMQTestBase.basicClusterConnectionConfig(BACKUP_NODE_NAME, LIVE_NODE_NAME)).setHAPolicyConfiguration(new ReplicaPolicyConfiguration());
    liveConfig.setName(LIVE_NODE_NAME).addConnectorConfiguration(LIVE_NODE_NAME, liveConnector).addConnectorConfiguration(BACKUP_NODE_NAME, backupConnector).setSecurityEnabled(false).addClusterConfiguration(ActiveMQTestBase.basicClusterConnectionConfig(LIVE_NODE_NAME, BACKUP_NODE_NAME)).setHAPolicyConfiguration(new ReplicatedPolicyConfiguration());
}
Also used : ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)

Example 8 with ReplicaPolicyConfiguration

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

the class SharedNothingReplicationTest method createBackupConfiguration.

private Configuration createBackupConfiguration() throws Exception {
    Configuration conf = new ConfigurationImpl();
    conf.setName("localhost::backup");
    File backupDir = brokersFolder.newFolder("backup");
    conf.setBrokerInstance(backupDir);
    ReplicaPolicyConfiguration haPolicy = new ReplicaPolicyConfiguration();
    haPolicy.setClusterName("cluster");
    conf.setHAPolicyConfiguration(haPolicy);
    conf.addAcceptorConfiguration("backup", "tcp://localhost:61617");
    conf.addConnectorConfiguration("live", "tcp://localhost:61616");
    conf.addConnectorConfiguration("backup", "tcp://localhost:61617");
    conf.setClusterUser("mycluster");
    conf.setClusterPassword("mypassword");
    ClusterConnectionConfiguration ccconf = new ClusterConnectionConfiguration();
    ccconf.setStaticConnectors(new ArrayList<>()).getStaticConnectors().add("live");
    ccconf.setName("cluster");
    ccconf.setConnectorName("backup");
    conf.addClusterConfiguration(ccconf);
    conf.setSecurityEnabled(false).setJMXManagementEnabled(false).setJournalType(JournalType.MAPPED).setJournalFileSize(1024 * 512).setConnectionTTLOverride(60_000L);
    return conf;
}
Also used : ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) File(java.io.File)

Example 9 with ReplicaPolicyConfiguration

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

the class FileConfigurationParser method createReplicaHaPolicy.

private ReplicaPolicyConfiguration createReplicaHaPolicy(Element policyNode) {
    ReplicaPolicyConfiguration configuration = new ReplicaPolicyConfiguration();
    configuration.setRestartBackup(getBoolean(policyNode, "restart-backup", configuration.isRestartBackup()));
    configuration.setGroupName(getString(policyNode, "group-name", configuration.getGroupName(), Validators.NO_CHECK));
    configuration.setAllowFailBack(getBoolean(policyNode, "allow-failback", configuration.isAllowFailBack()));
    configuration.setInitialReplicationSyncTimeout(getLong(policyNode, "initial-replication-sync-timeout", configuration.getInitialReplicationSyncTimeout(), Validators.GT_ZERO));
    configuration.setClusterName(getString(policyNode, "cluster-name", configuration.getClusterName(), Validators.NO_CHECK));
    configuration.setMaxSavedReplicatedJournalsSize(getInteger(policyNode, "max-saved-replicated-journals-size", configuration.getMaxSavedReplicatedJournalsSize(), Validators.MINUS_ONE_OR_GE_ZERO));
    configuration.setScaleDownConfiguration(parseScaleDownConfig(policyNode));
    configuration.setVoteOnReplicationFailure(getBoolean(policyNode, "vote-on-replication-failure", configuration.getVoteOnReplicationFailure()));
    configuration.setVoteRetries(getInteger(policyNode, "vote-retries", configuration.getVoteRetries(), Validators.MINUS_ONE_OR_GE_ZERO));
    configuration.setVoteRetryWait(getLong(policyNode, "vote-retry-wait", configuration.getVoteRetryWait(), Validators.GT_ZERO));
    configuration.setQuorumSize(getInteger(policyNode, "quorum-size", configuration.getQuorumSize(), Validators.MINUS_ONE_OR_GT_ZERO));
    return configuration;
}
Also used : ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration)

Example 10 with ReplicaPolicyConfiguration

use of org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration 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)

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