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) {
}
}
}
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)));
}
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());
}
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;
}
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;
}
Aggregations