use of org.apache.activemq.artemis.core.server.impl.InVMNodeManager in project activemq-artemis by apache.
the class MultipleLivesMultipleBackupsFailoverTest method testMultipleFailovers2LiveServers.
@Test
public void testMultipleFailovers2LiveServers() throws Exception {
NodeManager nodeManager1 = new InVMNodeManager(!sharedStore);
NodeManager nodeManager2 = new InVMNodeManager(!sharedStore);
createLiveConfig(nodeManager1, 0, 3, 4, 5);
createBackupConfig(nodeManager1, 0, 1, true, new int[] { 0, 2 }, 3, 4, 5);
createBackupConfig(nodeManager1, 0, 2, true, new int[] { 0, 1 }, 3, 4, 5);
createLiveConfig(nodeManager2, 3, 0);
createBackupConfig(nodeManager2, 3, 4, true, new int[] { 3, 5 }, 0, 1, 2);
createBackupConfig(nodeManager2, 3, 5, true, new int[] { 3, 4 }, 0, 1, 2);
servers.get(0).start();
waitForServerToStart(servers.get(0).getServer());
servers.get(3).start();
waitForServerToStart(servers.get(3).getServer());
servers.get(1).start();
waitForServerToStart(servers.get(1).getServer());
servers.get(2).start();
servers.get(4).start();
waitForServerToStart(servers.get(4).getServer());
servers.get(5).start();
waitForServerToStart(servers.get(4).getServer());
locator = getServerLocator(0).setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true).setReconnectAttempts(15);
ClientSessionFactoryInternal sf = createSessionFactoryAndWaitForTopology(locator, 4, servers.get(0).getServer());
ClientSession session = sendAndConsume(sf, true);
System.out.println(((ServerLocatorInternal) locator).getTopology().describe());
Thread.sleep(500);
servers.get(0).crash(session);
int liveAfter0 = waitForNewLive(10000, true, servers, 1, 2);
locator2 = getServerLocator(3).setBlockOnNonDurableSend(true).setBlockOnDurableSend(true).setBlockOnAcknowledge(true).setReconnectAttempts(15);
ClientSessionFactoryInternal sf2 = createSessionFactoryAndWaitForTopology(locator2, 4);
ClientSession session2 = sendAndConsume(sf2, true);
System.setProperty("foo", "bar");
servers.get(3).crash(session2);
int liveAfter3 = waitForNewLive(10000, true, servers, 4, 5);
locator.close();
locator2.close();
if (liveAfter0 == 2) {
Thread.sleep(500);
servers.get(1).stop();
Thread.sleep(500);
servers.get(2).stop();
} else {
Thread.sleep(500);
servers.get(2).stop();
Thread.sleep(500);
servers.get(1).stop();
}
if (liveAfter3 == 4) {
Thread.sleep(500);
servers.get(5).stop();
Thread.sleep(500);
servers.get(4).stop();
} else {
Thread.sleep(500);
servers.get(4).stop();
Thread.sleep(500);
servers.get(5).stop();
}
}
use of org.apache.activemq.artemis.core.server.impl.InVMNodeManager in project activemq-artemis by apache.
the class NettyFailoverTest method createNodeManager.
@Override
protected NodeManager createNodeManager() throws Exception {
switch(nodeManagerType) {
case InVM:
return new InVMNodeManager(false);
case Jdbc:
final ThreadFactory daemonThreadFactory = t -> {
final Thread th = new Thread(t);
th.setDaemon(true);
return th;
};
final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(daemonThreadFactory);
scheduledExecutorServices.add(scheduledExecutorService);
final ExecutorService executor = Executors.newFixedThreadPool(2, daemonThreadFactory);
executors.add(executor);
final DatabaseStorageConfiguration dbConf = createDefaultDatabaseStorageConfiguration();
final ExecutorFactory executorFactory = new OrderedExecutorFactory(executor);
return JdbcNodeManager.with(dbConf, scheduledExecutorService, executorFactory, (code, message, file) -> {
code.printStackTrace();
Assert.fail(message);
});
default:
throw new AssertionError("enum type not supported!");
}
}
use of org.apache.activemq.artemis.core.server.impl.InVMNodeManager in project activemq-artemis by apache.
the class FailoverListenerTest 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()).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 SharedStoreBackupTest method createConfigs.
@Override
protected void createConfigs() throws Exception {
nodeManager = new InVMNodeManager(false);
TransportConfiguration liveConnector = getConnectorTransportConfiguration(true);
TransportConfiguration backupConnector = getConnectorTransportConfiguration(false);
System.out.println("backup config created - mnovak");
backupConfig = super.createDefaultConfig(false).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(false)).setHAPolicyConfiguration(new SharedStoreSlavePolicyConfiguration().setScaleDownConfiguration(new ScaleDownConfiguration().setEnabled(false)).setRestartBackup(false)).addConnectorConfiguration(liveConnector.getName(), liveConnector).addConnectorConfiguration(backupConnector.getName(), backupConnector).addClusterConfiguration(basicClusterConnectionConfig(backupConnector.getName(), liveConnector.getName()));
backupServer = createTestableServer(backupConfig);
liveConfig = super.createDefaultConfig(false).clearAcceptorConfigurations().addAcceptorConfiguration(getAcceptorTransportConfiguration(true)).setHAPolicyConfiguration(new SharedStoreMasterPolicyConfiguration().setFailoverOnServerShutdown(true)).addClusterConfiguration(basicClusterConnectionConfig(liveConnector.getName())).addConnectorConfiguration(liveConnector.getName(), liveConnector);
liveServer = createTestableServer(liveConfig);
}
use of org.apache.activemq.artemis.core.server.impl.InVMNodeManager in project activemq-artemis by apache.
the class BroadcastGroupImplTest method testBroadcastDatagramLength.
/**
* Test the broadcasted packages length.<br>
* Broadcast and MultiCast techniques are commonly limited in size by
* underlying hardware. Broadcast and MultiCast protocols are typically not
* guaranteed (UDP) and as such large packages may be silently discarded by
* underlying hardware.<br>
* This test validates that Artemis Server does not broadcast packages above
* a size of 1500 bytes. The limit is not derived from any normative
* documents, but is rather derived from common MTU for network equipment.
*/
@Test
public void testBroadcastDatagramLength() throws Throwable {
BroadcastEndpointFactoryImpl befi;
befi = new BroadcastEndpointFactoryImpl();
InVMNodeManager node;
node = new InVMNodeManager(false);
String name;
name = "BroadcastGroupImplTest";
BroadcastGroupImpl test;
test = new BroadcastGroupImpl(node, name, 1000, null, befi);
TransportConfiguration tcon;
tcon = new TransportConfiguration(getClass().getName());
test.addConnector(tcon);
// Broadcast
test.broadcastConnectors();
// Make sure we sent one package
assertEquals("Incorrect number of sent datagrams", 1, befi.sent);
}
Aggregations