use of org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal in project activemq-artemis by apache.
the class ServerLocatorConnectTest method testMultipleConnectorSingleServerNoConnect.
@Test
public void testMultipleConnectorSingleServerNoConnect() throws Exception {
ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(5, isNetty())));
ClientSessionFactoryInternal csf = null;
try {
csf = locator.connect();
} catch (ActiveMQNotConnectedException nce) {
// ok
} catch (Exception e) {
assertTrue(e instanceof ActiveMQException);
fail("Invalid Exception type:" + ((ActiveMQException) e).getType());
}
assertNull(csf);
locator.close();
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal in project activemq-artemis by apache.
the class ClusterManager method stop.
@Override
public void stop() throws Exception {
haManager.stop();
synchronized (this) {
if (state == State.STOPPED || state == State.STOPPING) {
return;
}
state = State.STOPPING;
clusterController.stop();
for (BroadcastGroup group : broadcastGroups.values()) {
group.stop();
managementService.unregisterBroadcastGroup(group.getName());
}
broadcastGroups.clear();
for (ClusterConnection clusterConnection : clusterConnections.values()) {
clusterConnection.stop();
managementService.unregisterCluster(clusterConnection.getName().toString());
}
for (Bridge bridge : bridges.values()) {
bridge.stop();
managementService.unregisterBridge(bridge.getName().toString());
}
bridges.clear();
}
for (ServerLocatorInternal clusterLocator : clusterLocators) {
try {
clusterLocator.close();
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.errorClosingServerLocator(e, clusterLocator);
}
}
clusterLocators.clear();
state = State.STOPPED;
clearClusterConnections();
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal 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.client.impl.ServerLocatorInternal in project activemq-artemis by apache.
the class ClusterTestBase method setupSessionFactory.
protected void setupSessionFactory(final int node, final int backupNode, final boolean netty, final boolean blocking) throws Exception {
if (sfs[node] != null) {
throw new IllegalArgumentException("Already a server at " + node);
}
Map<String, Object> params = generateParams(node, netty);
TransportConfiguration serverToTC = createTransportConfiguration(netty, false, params);
locators[node] = addServerLocator(ActiveMQClient.createServerLocatorWithHA(serverToTC)).setRetryInterval(100).setRetryIntervalMultiplier(1d).setReconnectAttempts(300).setBlockOnNonDurableSend(blocking).setBlockOnDurableSend(blocking);
final String identity = "TestClientConnector,live=" + node + ",backup=" + backupNode;
((ServerLocatorInternal) locators[node]).setIdentity(identity);
ClientSessionFactory sf = createSessionFactory(locators[node]);
sfs[node] = sf;
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal in project activemq-artemis by apache.
the class ClusterConnectionConfigTest method makeSureForwardingFlowControl.
private void makeSureForwardingFlowControl(int producerWindow, int... indices) throws NoSuchFieldException, IllegalAccessException {
for (int i : indices) {
ClusterConnectionImpl cc = (ClusterConnectionImpl) servers[i].getClusterManager().getClusterConnection("cluster" + i);
Map<String, MessageFlowRecord> map = cc.getRecords();
assertEquals(1, map.size());
MessageFlowRecord record = map.entrySet().iterator().next().getValue();
// NoSuchFieldException
Field f = record.getClass().getDeclaredField("targetLocator");
f.setAccessible(true);
ServerLocatorInternal targetLocator = (ServerLocatorInternal) f.get(record);
assertEquals(producerWindow, targetLocator.getProducerWindowSize());
}
}
Aggregations