use of org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer 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);
}
}
use of org.apache.activemq.artemis.tests.integration.cluster.util.SameProcessActiveMQServer 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);
}
Aggregations