use of org.apache.activemq.artemis.core.server.impl.InVMNodeManager in project activemq-artemis by apache.
the class FailBackAutoTest method createConfigs.
@Override
protected void createConfigs() throws Exception {
nodeManager = new InVMNodeManager(false);
TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
backupConfig = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(false)).setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration().setRestartBackup(true)).addConnectorConfiguration(liveConnector.getName(), liveConnector).addConnectorConfiguration(backupConnector.getName(), backupConnector).addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName()));
backupServer = createTestableServer(backupConfig);
liveConfig = super.createDefaultInVMConfig().clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true)).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration()).addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName(), backupConnector.getName())).addConnectorConfiguration(liveConnector.getName(), liveConnector).addConnectorConfiguration(backupConnector.getName(), backupConnector);
liveServer = createTestableServer(liveConfig);
}
use of org.apache.activemq.artemis.core.server.impl.InVMNodeManager in project activemq-artemis by apache.
the class FailoverTest method testTimeoutOnFailoverConsume.
// https://issues.jboss.org/browse/HORNETQ-685
@Test(timeout = 120000)
public void testTimeoutOnFailoverConsume() throws Exception {
locator.setCallTimeout(5000).setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setAckBatchSize(0).setBlockOnAcknowledge(true).setReconnectAttempts(300).setRetryInterval(100).setAckBatchSize(0);
if (nodeManager instanceof InVMNodeManager) {
((InVMNodeManager) nodeManager).failoverPause = 5000L;
}
ClientSessionFactoryInternal sf1 = (ClientSessionFactoryInternal) createSessionFactory(locator);
final ClientSession session = createSession(sf1, true, true);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
for (int i = 0; i < 500; i++) {
ClientMessage message = session.createMessage(true);
message.putIntProperty("counter", i);
producer.send(message);
}
final CountDownLatch latch = new CountDownLatch(1);
final CountDownLatch endLatch = new CountDownLatch(1);
final ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
session.start();
final Map<Integer, ClientMessage> received = new HashMap<>();
consumer.setMessageHandler(new MessageHandler() {
@Override
public void onMessage(ClientMessage message) {
Integer counter = message.getIntProperty("counter");
received.put(counter, message);
try {
log.debug("acking message = id = " + message.getMessageID() + ", counter = " + message.getIntProperty("counter"));
message.acknowledge();
} catch (ActiveMQException e) {
e.printStackTrace();
return;
}
log.debug("Acked counter = " + counter);
if (counter.equals(10)) {
latch.countDown();
}
if (received.size() == 500) {
endLatch.countDown();
}
}
});
latch.await(10, TimeUnit.SECONDS);
log.info("crashing session");
crash(session);
endLatch.await(60, TimeUnit.SECONDS);
Assert.assertTrue("received only " + received.size(), received.size() == 500);
session.close();
}
use of org.apache.activemq.artemis.core.server.impl.InVMNodeManager in project activemq-artemis by apache.
the class FailoverTest method testTimeoutOnFailoverTransactionCommit.
// https://issues.jboss.org/browse/HORNETQ-685
@Test(timeout = 120000)
public void testTimeoutOnFailoverTransactionCommit() throws Exception {
locator.setCallTimeout(5000).setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setAckBatchSize(0).setReconnectAttempts(300).setRetryInterval(100);
if (nodeManager instanceof InVMNodeManager) {
((InVMNodeManager) nodeManager).failoverPause = 5000L;
}
ClientSessionFactoryInternal sf1 = (ClientSessionFactoryInternal) createSessionFactory(locator);
final ClientSession session = createSession(sf1, true, false, false);
session.createQueue(FailoverTestBase.ADDRESS, RoutingType.MULTICAST, FailoverTestBase.ADDRESS, null, true);
final CountDownLatch connectionFailed = new CountDownLatch(1);
session.addFailureListener(new SessionFailureListener() {
@Override
public void beforeReconnect(ActiveMQException exception) {
}
@Override
public void connectionFailed(ActiveMQException exception, boolean failedOver) {
}
@Override
public void connectionFailed(ActiveMQException exception, boolean failedOver, String scaleDownTargetNodeID) {
connectionFailed.countDown();
}
});
final ClientProducer producer = session.createProducer(FailoverTestBase.ADDRESS);
Xid xid = new XidImpl("uhuhuhu".getBytes(), 126512, "auhsduashd".getBytes());
session.start(xid, XAResource.TMNOFLAGS);
for (int i = 0; i < 500; i++) {
ClientMessage message = session.createMessage(true);
message.putIntProperty("counter", i);
producer.send(message);
}
session.end(xid, XAResource.TMSUCCESS);
session.prepare(xid);
crash(true, session);
try {
session.commit(xid, false);
} catch (XAException e) {
// there is still an edge condition that we must deal with
Assert.assertTrue(connectionFailed.await(10, TimeUnit.SECONDS));
session.commit(xid, false);
}
ClientConsumer consumer = session.createConsumer(FailoverTestBase.ADDRESS);
session.start();
for (int i = 0; i < 500; i++) {
ClientMessage m = consumer.receive(1000);
Assert.assertNotNull(m);
Assert.assertEquals(i, m.getIntProperty("counter").intValue());
}
}
use of org.apache.activemq.artemis.core.server.impl.InVMNodeManager in project activemq-artemis by apache.
the class LiveToLiveFailoverTest method createConfigs.
@Override
protected void createConfigs() throws Exception {
nodeManager0 = new InVMNodeManager(false);
nodeManager1 = new InVMNodeManager(false);
TransportConfiguration liveConnector0 = getConnectorTransportConfiguration(true, 0);
TransportConfiguration liveConnector1 = getConnectorTransportConfiguration(true, 1);
backupConfig = super.createDefaultInVMConfig(1).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true, 1)).setHAPolicyConfiguration(new ColocatedPolicyConfiguration().setRequestBackup(true).setLiveConfig(new SharedStoreMasterPolicyConfiguration()).setBackupConfig(new SharedStoreSlavePolicyConfiguration().setScaleDownConfiguration(new ScaleDownConfiguration().addConnector(liveConnector1.getName())))).addConnectorConfiguration(liveConnector0.getName(), liveConnector0).addConnectorConfiguration(liveConnector1.getName(), liveConnector1).addClusterConfiguration(basicClusterConnectionConfig(liveConnector1.getName(), liveConnector0.getName()));
backupServer = createColocatedTestableServer(backupConfig, nodeManager1, nodeManager0, 1);
liveConfig = super.createDefaultInVMConfig(0).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true, 0)).setHAPolicyConfiguration(new ColocatedPolicyConfiguration().setRequestBackup(true).setBackupRequestRetryInterval(1000).setLiveConfig(new SharedStoreMasterPolicyConfiguration()).setBackupConfig(new SharedStoreSlavePolicyConfiguration().setScaleDownConfiguration(new ScaleDownConfiguration()))).addConnectorConfiguration(liveConnector0.getName(), liveConnector0).addConnectorConfiguration(liveConnector1.getName(), liveConnector1).addClusterConfiguration(basicClusterConnectionConfig(liveConnector0.getName(), liveConnector1.getName()));
liveServer = createColocatedTestableServer(liveConfig, nodeManager0, nodeManager1, 0);
}
use of org.apache.activemq.artemis.core.server.impl.InVMNodeManager in project activemq-artemis by apache.
the class MultiServerTestBase method setupLiveServer.
protected Pair<ActiveMQServer, NodeManager> setupLiveServer(final int node, final boolean realFiles, final boolean sharedStorage) throws Exception {
NodeManager nodeManager = null;
TransportConfiguration serverConfigAcceptor = createTransportConfiguration(useNetty(), true, generateParams(node, useNetty()));
TransportConfiguration thisConnector = createTransportConfiguration(useNetty(), false, generateParams(node, useNetty()));
if (sharedStorage) {
nodeManager = new InVMNodeManager(false);
}
Configuration configuration = createBasicConfig(node).setJournalMaxIO_AIO(1000).setThreadPoolMaxSize(10).clearAcceptorConfigurations().addAcceptorConfiguration(serverConfigAcceptor).addConnectorConfiguration("thisConnector", thisConnector).setHAPolicyConfiguration(sharedStorage ? new SharedStoreMasterPolicyConfiguration() : new ReplicatedPolicyConfiguration());
List<String> targetServersOnConnection = new ArrayList<>();
for (int targetNode = 0; targetNode < getNumberOfServers(); targetNode++) {
if (targetNode == node) {
continue;
}
String targetConnectorName = "target-" + targetNode;
TransportConfiguration targetServer = createTransportConfiguration(useNetty(), false, generateParams(targetNode, useNetty()));
configuration.getConnectorConfigurations().put(targetConnectorName, targetServer);
targetServersOnConnection.add(targetConnectorName);
// The connector towards a backup.. just to have a reference so bridges can connect to backups on their configs
String backupConnectorName = "backup-" + targetNode;
TransportConfiguration backupConnector = createTransportConfiguration(useNetty(), false, generateParams(targetNode + getNumberOfServers(), useNetty()));
configuration.getConnectorConfigurations().put(backupConnectorName, backupConnector);
}
ClusterConnectionConfiguration clusterConf = new ClusterConnectionConfiguration().setName("localCluster" + node).setAddress("cluster-queues").setConnectorName("thisConnector").setRetryInterval(100).setConfirmationWindowSize(1024).setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND).setStaticConnectors(targetServersOnConnection);
configuration.getClusterConfigurations().add(clusterConf);
ActiveMQServer server;
if (sharedStorage) {
server = createInVMFailoverServer(realFiles, configuration, nodeManager, node);
} else {
server = createServer(realFiles, configuration);
}
server.setIdentity(this.getClass().getSimpleName() + "/Live(" + node + ")");
addServer(server);
return new Pair<>(server, nodeManager);
}
Aggregations