use of org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration in project activemq-artemis by apache.
the class FileConfigurationParserTest method testParsingHaSharedStoreWaitForActivation.
@Test
public void testParsingHaSharedStoreWaitForActivation() throws Exception {
FileConfigurationParser parser = new FileConfigurationParser();
String configStr = firstPart + "<ha-policy><shared-store><master><wait-for-activation>false</wait-for-activation></master></shared-store></ha-policy>" + lastPart;
ByteArrayInputStream input = new ByteArrayInputStream(configStr.getBytes(StandardCharsets.UTF_8));
Configuration config = parser.parseMainConfig(input);
HAPolicyConfiguration haConfig = config.getHAPolicyConfiguration();
assertTrue(haConfig instanceof SharedStoreMasterPolicyConfiguration);
SharedStoreMasterPolicyConfiguration masterConfig = (SharedStoreMasterPolicyConfiguration) haConfig;
assertFalse(masterConfig.isWaitForActivation());
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration in project activemq-artemis by apache.
the class FileLockTimeoutTest method doTest.
protected void doTest(final boolean useAIO) throws Exception {
if (useAIO) {
Assert.assertTrue(String.format("libAIO is not loaded on %s %s %s", System.getProperty("os.name"), System.getProperty("os.arch"), System.getProperty("os.version")), LibaioContext.isLoaded());
}
Configuration config = super.createDefaultInVMConfig().setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()).clearAcceptorConfigurations();
ActiveMQServer server1 = createServer(true, config);
if (useAIO) {
server1.getConfiguration().setJournalType(JournalType.ASYNCIO);
} else {
server1.getConfiguration().setJournalType(JournalType.NIO);
}
server1.start();
server1.waitForActivation(10, TimeUnit.SECONDS);
final ActiveMQServer server2 = createServer(true, config);
if (useAIO) {
server2.getConfiguration().setJournalType(JournalType.ASYNCIO);
} else {
server2.getConfiguration().setJournalType(JournalType.NIO);
}
server2.getConfiguration().setJournalLockAcquisitionTimeout(5000);
// if something happens that causes the timeout to misbehave we don't want the test to hang
ExecutorService service = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory());
Runnable r = new Runnable() {
@Override
public void run() {
try {
server2.start();
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
};
Future<?> f = service.submit(r);
try {
f.get(15, TimeUnit.SECONDS);
} catch (Exception e) {
IntegrationTestLogger.LOGGER.warn("aborting test because server is taking too long to start");
}
service.shutdown();
assertTrue("Expected to find AMQ224000", AssertionLoggerHandler.findText("AMQ224000"));
assertTrue("Expected to find \"timed out waiting for lock\"", AssertionLoggerHandler.findText("timed out waiting for lock"));
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration in project activemq-artemis by apache.
the class ClusterTestBase method setupLiveServer.
protected void setupLiveServer(final int node, final boolean fileStorage, final boolean sharedStorage, final boolean netty, boolean liveOnly) throws Exception {
if (servers[node] != null) {
throw new IllegalArgumentException("Already a server at node " + node);
}
HAPolicyConfiguration haPolicyConfiguration = null;
if (liveOnly) {
haPolicyConfiguration = new LiveOnlyPolicyConfiguration();
} else {
if (sharedStorage)
haPolicyConfiguration = new SharedStoreMasterPolicyConfiguration();
else
haPolicyConfiguration = new ReplicatedPolicyConfiguration();
}
Configuration configuration = createBasicConfig(node).setJournalMaxIO_AIO(1000).setThreadPoolMaxSize(10).clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(netty, true, generateParams(node, netty))).setHAPolicyConfiguration(haPolicyConfiguration).setResolveProtocols(isResolveProtocols());
ActiveMQServer server;
if (fileStorage) {
if (sharedStorage) {
server = createInVMFailoverServer(true, configuration, nodeManagers[node], node);
} else {
server = createServer(configuration);
}
} else {
if (sharedStorage) {
server = createInVMFailoverServer(false, configuration, nodeManagers[node], node);
} else {
server = createServer(false, configuration);
}
}
server.addProtocolManagerFactory(new CoreProtocolManagerFactory());
server.setIdentity(this.getClass().getSimpleName() + "/Live(" + node + ")");
servers[node] = addServer(server);
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration in project activemq-artemis by apache.
the class ClusterTestBase method setupLiveServerWithDiscovery.
protected void setupLiveServerWithDiscovery(final int node, final String groupAddress, final int port, final boolean fileStorage, final boolean netty, final boolean sharedStorage) throws Exception {
if (servers[node] != null) {
throw new IllegalArgumentException("Already a server at node " + node);
}
Map<String, Object> params = generateParams(node, netty);
TransportConfiguration connector = createTransportConfiguration(netty, false, params);
List<String> connectorPairs = new ArrayList<>();
connectorPairs.add(connector.getName());
UDPBroadcastEndpointFactory endpoint = new UDPBroadcastEndpointFactory().setGroupAddress(groupAddress).setGroupPort(port);
BroadcastGroupConfiguration bcConfig = new BroadcastGroupConfiguration().setName("bg1").setBroadcastPeriod(200).setConnectorInfos(connectorPairs).setEndpointFactory(endpoint);
DiscoveryGroupConfiguration dcConfig = new DiscoveryGroupConfiguration().setName("dg1").setRefreshTimeout(1000).setDiscoveryInitialWaitTimeout(1000).setBroadcastEndpointFactory(endpoint);
Configuration configuration = createBasicConfig(node).setJournalMaxIO_AIO(1000).clearAcceptorConfigurations().addAcceptorConfiguration(createTransportConfiguration(netty, true, params)).addConnectorConfiguration(connector.getName(), connector).addBroadcastGroupConfiguration(bcConfig).addDiscoveryGroupConfiguration(dcConfig.getName(), dcConfig).setHAPolicyConfiguration(sharedStorage ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration());
ActiveMQServer server;
if (fileStorage) {
if (sharedStorage) {
server = createInVMFailoverServer(true, configuration, nodeManagers[node], node);
} else {
server = addServer(ActiveMQServers.newActiveMQServer(configuration));
server.setIdentity("Server " + node);
}
} else {
if (sharedStorage) {
server = createInVMFailoverServer(false, configuration, nodeManagers[node], node);
} else {
server = addServer(ActiveMQServers.newActiveMQServer(configuration, false));
server.setIdentity("Server " + node);
}
}
servers[node] = server;
}
use of org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration in project activemq-artemis by apache.
the class JMSFailoverListenerTest method startServers.
/**
* @throws Exception
*/
protected void startServers() throws Exception {
NodeManager nodeManager = new InVMNodeManager(false);
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).setJournalType(getDefaultJournalType()).addAcceptorConfiguration(new TransportConfiguration(INVM_ACCEPTOR_FACTORY, backupParams)).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).setPersistenceEnabled(true).setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration()).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()).addAcceptorConfiguration(liveAcceptortc).setJournalType(getDefaultJournalType()).setBindingsDirectory(getBindingsDir()).setJournalMinFiles(2).setJournalDirectory(getJournalDir()).setPagingDirectory(getPageDir()).setLargeMessagesDirectory(getLargeMessagesDir()).addConnectorConfiguration(livetc.getName(), livetc).setPersistenceEnabled(true).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()).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);
}
Aggregations