Search in sources :

Example 6 with ReplicatedPolicyConfiguration

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

the class ReplicatedFailoverTest method testReplicatedFailback.

@Test(timeout = 120000)
public /*
   * default maxSavedReplicatedJournalsSize is 2, this means the backup will fall back to replicated only twice, after this
   * it is stopped permanently
   *
   * */
void testReplicatedFailback() throws Exception {
    try {
        beforeWaitForRemoteBackupSynchronization();
        waitForRemoteBackupSynchronization(backupServer.getServer());
        createSessionFactory();
        ClientSession session = createSession(sf, true, true);
        session.createQueue(ADDRESS, ADDRESS, null, true);
        crash(session);
        ReplicatedPolicy haPolicy = (ReplicatedPolicy) liveServer.getServer().getHAPolicy();
        haPolicy.setCheckForLiveServer(true);
        liveServer.start();
        waitForRemoteBackupSynchronization(liveServer.getServer());
        waitForRemoteBackupSynchronization(backupServer.getServer());
        waitForServerToStart(liveServer.getServer());
        session = createSession(sf, true, true);
        crash(session);
        ReplicatedPolicyConfiguration replicatedPolicyConfiguration = (ReplicatedPolicyConfiguration) liveServer.getServer().getConfiguration().getHAPolicyConfiguration();
        replicatedPolicyConfiguration.setCheckForLiveServer(true);
        liveServer.start();
        waitForRemoteBackupSynchronization(liveServer.getServer());
        waitForRemoteBackupSynchronization(backupServer.getServer());
        waitForServerToStart(liveServer.getServer());
        session = createSession(sf, true, true);
        crash(session);
        replicatedPolicyConfiguration = (ReplicatedPolicyConfiguration) liveServer.getServer().getConfiguration().getHAPolicyConfiguration();
        replicatedPolicyConfiguration.setCheckForLiveServer(true);
        liveServer.start();
        waitForServerToStart(liveServer.getServer());
        backupServer.getServer().waitForActivation(5, TimeUnit.SECONDS);
        waitForRemoteBackupSynchronization(liveServer.getServer());
        waitForServerToStart(backupServer.getServer());
        assertTrue(backupServer.getServer().isStarted());
    } finally {
        if (sf != null) {
            sf.close();
        }
        try {
            liveServer.getServer().stop();
        } catch (Throwable ignored) {
        }
        try {
            backupServer.getServer().stop();
        } catch (Throwable ignored) {
        }
    }
}
Also used : ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ReplicatedPolicy(org.apache.activemq.artemis.core.server.cluster.ha.ReplicatedPolicy) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) Test(org.junit.Test)

Example 7 with ReplicatedPolicyConfiguration

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

the class MultipleLivesMultipleBackupsFailoverTest method createLiveConfig.

protected void createLiveConfig(NodeManager nodeManager, int liveNode, int... otherLiveNodes) 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()).setBindingsDirectory(getBindingsDir() + "_" + liveNode).setJournalDirectory(getJournalDir() + "_" + liveNode).setPagingDirectory(getPageDir() + "_" + liveNode).setLargeMessagesDirectory(getLargeMessagesDir() + "_" + liveNode).addConnectorConfiguration(liveConnector.getName(), liveConnector);
    String[] pairs = new String[otherLiveNodes.length];
    for (int i = 0; i < otherLiveNodes.length; i++) {
        TransportConfiguration otherLiveConnector = createTransportConfiguration(isNetty(), false, generateParams(otherLiveNodes[i], isNetty()));
        config0.addConnectorConfiguration(otherLiveConnector.getName(), otherLiveConnector);
        pairs[i] = otherLiveConnector.getName();
    }
    config0.addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), pairs));
    servers.put(liveNode, new SameProcessActiveMQServer(createInVMFailoverServer(true, config0, 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) 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)

Example 8 with ReplicatedPolicyConfiguration

use of org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration 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 9 with ReplicatedPolicyConfiguration

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

the class SharedNothingReplicationTest method createLiveConfiguration.

private Configuration createLiveConfiguration() throws Exception {
    Configuration conf = new ConfigurationImpl();
    conf.setName("localhost::live");
    File liveDir = brokersFolder.newFolder("live");
    conf.setBrokerInstance(liveDir);
    conf.addAcceptorConfiguration("live", "tcp://localhost:61616");
    conf.addConnectorConfiguration("backup", "tcp://localhost:61617");
    conf.addConnectorConfiguration("live", "tcp://localhost:61616");
    conf.setClusterUser("mycluster");
    conf.setClusterPassword("mypassword");
    ReplicatedPolicyConfiguration haPolicy = new ReplicatedPolicyConfiguration();
    haPolicy.setVoteOnReplicationFailure(false);
    haPolicy.setCheckForLiveServer(false);
    conf.setHAPolicyConfiguration(haPolicy);
    ClusterConnectionConfiguration ccconf = new ClusterConnectionConfiguration();
    ccconf.setStaticConnectors(new ArrayList<>()).getStaticConnectors().add("backup");
    ccconf.setName("cluster");
    ccconf.setConnectorName("live");
    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) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) File(java.io.File)

Example 10 with ReplicatedPolicyConfiguration

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

the class ReplicationMasterDefinition method buildConfiguration.

static HAPolicyConfiguration buildConfiguration(OperationContext context, ModelNode model) throws OperationFailedException {
    ReplicatedPolicyConfiguration haPolicyConfiguration = new ReplicatedPolicyConfiguration();
    haPolicyConfiguration.setCheckForLiveServer(CHECK_FOR_LIVE_SERVER.resolveModelAttribute(context, model).asBoolean()).setInitialReplicationSyncTimeout(INITIAL_REPLICATION_SYNC_TIMEOUT.resolveModelAttribute(context, model).asLong());
    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 : ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ModelNode(org.jboss.dmr.ModelNode)

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