use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.
the class GroupingFailoverTestBase method waitForBackupTopologyAnnouncement.
public void waitForBackupTopologyAnnouncement(ClientSessionFactory sf) throws Exception {
long start = System.currentTimeMillis();
ServerLocator locator = sf.getServerLocator();
do {
Collection<TopologyMemberImpl> members = locator.getTopology().getMembers();
for (TopologyMemberImpl member : members) {
if (member.getBackup() != null) {
return;
}
}
Thread.sleep(10);
} while (System.currentTimeMillis() - start < ActiveMQTestBase.WAIT_TIMEOUT);
throw new IllegalStateException("Timed out waiting for backup announce");
}
use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.
the class IsolatedTopologyTest method checkTopology.
private void checkTopology(final ActiveMQServer serverParameter, final String clusterName, final String nodeId1, final String nodeId2, final TransportConfiguration cfg1, final TransportConfiguration cfg2) {
Topology topology = serverParameter.getClusterManager().getClusterConnection(clusterName).getTopology();
TopologyMemberImpl member1 = topology.getMember(nodeId1);
TopologyMemberImpl member2 = topology.getMember(nodeId2);
Assert.assertEquals(member1.getLive().getParams().toString(), cfg1.getParams().toString());
Assert.assertEquals(member2.getLive().getParams().toString(), cfg2.getParams().toString());
}
use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.
the class AutomaticColocatedQuorumVoteTest method testSimpleDistributionBackupStrategyScaleDown.
@Test
public void testSimpleDistributionBackupStrategyScaleDown() throws Exception {
ActiveMQServer server0 = createServer(0, 1, true);
ActiveMQServer server1 = createServer(1, 0, true);
TransportConfiguration liveConnector0 = getConnectorTransportConfiguration("liveConnector" + 0, 0);
TransportConfiguration liveConnector1 = getConnectorTransportConfiguration("liveConnector" + 1, 1);
try (ServerLocator serverLocator = ActiveMQClient.createServerLocatorWithoutHA(liveConnector0)) {
server0.start();
server1.start();
ClientSessionFactory sessionFactory0 = serverLocator.createSessionFactory(liveConnector0);
waitForRemoteBackup(sessionFactory0, 10);
ClientSessionFactory sessionFactory1 = serverLocator.createSessionFactory(liveConnector1);
waitForRemoteBackup(sessionFactory1, 10);
Topology topology = serverLocator.getTopology();
Collection<TopologyMemberImpl> members = topology.getMembers();
Assert.assertEquals(members.size(), 2);
Map<String, ActiveMQServer> backupServers0 = server0.getClusterManager().getHAManager().getBackupServers();
Assert.assertEquals(backupServers0.size(), 1);
Map<String, ActiveMQServer> backupServers1 = server1.getClusterManager().getHAManager().getBackupServers();
Assert.assertEquals(backupServers1.size(), 1);
ActiveMQServer backupServer0 = backupServers0.values().iterator().next();
ActiveMQServer backupServer1 = backupServers1.values().iterator().next();
waitForRemoteBackupSynchronization(backupServer0);
waitForRemoteBackupSynchronization(backupServer1);
Assert.assertEquals(server0.getNodeID(), backupServer1.getNodeID());
Assert.assertEquals(server1.getNodeID(), backupServer0.getNodeID());
Set<TransportConfiguration> backupAcceptors0 = backupServer0.getConfiguration().getAcceptorConfigurations();
Assert.assertEquals(0, backupAcceptors0.size());
Set<TransportConfiguration> backupAcceptors1 = backupServer1.getConfiguration().getAcceptorConfigurations();
Assert.assertEquals(0, backupAcceptors1.size());
Map<String, TransportConfiguration> connectorConfigurations0 = backupServer0.getConfiguration().getConnectorConfigurations();
Assert.assertEquals(2, connectorConfigurations0.size());
Assert.assertEquals("61616", connectorConfigurations0.get("liveConnector0").getParams().get("port"));
Assert.assertEquals("61617", connectorConfigurations0.get("remoteConnector0").getParams().get("port"));
Map<String, TransportConfiguration> connectorConfigurations1 = backupServer1.getConfiguration().getConnectorConfigurations();
Assert.assertEquals(2, connectorConfigurations1.size());
Assert.assertEquals("61617", connectorConfigurations1.get("liveConnector1").getParams().get("port"));
Assert.assertEquals("61616", connectorConfigurations1.get("remoteConnector1").getParams().get("port"));
if (!replicated) {
Assert.assertEquals(server0.getConfiguration().getJournalDirectory(), backupServer1.getConfiguration().getJournalDirectory());
Assert.assertEquals(server0.getConfiguration().getBindingsDirectory(), backupServer1.getConfiguration().getBindingsDirectory());
Assert.assertEquals(server0.getConfiguration().getLargeMessagesDirectory(), backupServer1.getConfiguration().getLargeMessagesDirectory());
Assert.assertEquals(server0.getConfiguration().getPagingDirectory(), backupServer1.getConfiguration().getPagingDirectory());
Assert.assertEquals(server1.getConfiguration().getJournalDirectory(), backupServer0.getConfiguration().getJournalDirectory());
Assert.assertEquals(server1.getConfiguration().getBindingsDirectory(), backupServer0.getConfiguration().getBindingsDirectory());
Assert.assertEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory());
Assert.assertEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory());
} else {
Assert.assertNotEquals(server0.getConfiguration().getJournalDirectory(), backupServer1.getConfiguration().getJournalDirectory());
Assert.assertNotEquals(server0.getConfiguration().getBindingsDirectory(), backupServer1.getConfiguration().getBindingsDirectory());
Assert.assertNotEquals(server0.getConfiguration().getLargeMessagesDirectory(), backupServer1.getConfiguration().getLargeMessagesDirectory());
Assert.assertNotEquals(server0.getConfiguration().getPagingDirectory(), backupServer1.getConfiguration().getPagingDirectory());
Assert.assertNotEquals(server1.getConfiguration().getJournalDirectory(), backupServer0.getConfiguration().getJournalDirectory());
Assert.assertNotEquals(server1.getConfiguration().getBindingsDirectory(), backupServer0.getConfiguration().getBindingsDirectory());
Assert.assertNotEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory());
Assert.assertNotEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory());
}
} finally {
try {
server0.stop();
} catch (Throwable e) {
e.printStackTrace();
}
server1.stop();
}
}
use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.
the class AutomaticColocatedQuorumVoteTest method testSimpleDistributionBackupStrategyFull.
@Test
public void testSimpleDistributionBackupStrategyFull() throws Exception {
ActiveMQServer server0 = createServer(0, 1, false);
ActiveMQServer server1 = createServer(1, 0, false);
TransportConfiguration liveConnector0 = getConnectorTransportConfiguration("liveConnector" + 0, 0);
TransportConfiguration liveConnector1 = getConnectorTransportConfiguration("liveConnector" + 1, 1);
try (ServerLocator serverLocator = ActiveMQClient.createServerLocatorWithoutHA(liveConnector0)) {
server0.start();
server1.start();
ClientSessionFactory sessionFactory0 = serverLocator.createSessionFactory(liveConnector0);
waitForRemoteBackup(sessionFactory0, 10);
ClientSessionFactory sessionFactory1 = serverLocator.createSessionFactory(liveConnector1);
waitForRemoteBackup(sessionFactory1, 10);
Topology topology = serverLocator.getTopology();
Collection<TopologyMemberImpl> members = topology.getMembers();
Assert.assertEquals(members.size(), 2);
Map<String, ActiveMQServer> backupServers0 = server0.getClusterManager().getHAManager().getBackupServers();
Assert.assertEquals(backupServers0.size(), 1);
Map<String, ActiveMQServer> backupServers1 = server1.getClusterManager().getHAManager().getBackupServers();
Assert.assertEquals(backupServers1.size(), 1);
ActiveMQServer backupServer0 = backupServers0.values().iterator().next();
ActiveMQServer backupServer1 = backupServers1.values().iterator().next();
waitForRemoteBackupSynchronization(backupServer0);
waitForRemoteBackupSynchronization(backupServer1);
Assert.assertEquals(server0.getNodeID(), backupServer1.getNodeID());
Assert.assertEquals(server1.getNodeID(), backupServer0.getNodeID());
Set<TransportConfiguration> backupAcceptors0 = backupServer0.getConfiguration().getAcceptorConfigurations();
Assert.assertEquals(1, backupAcceptors0.size());
Assert.assertEquals("61716", backupAcceptors0.iterator().next().getParams().get("port"));
Set<TransportConfiguration> backupAcceptors1 = backupServer1.getConfiguration().getAcceptorConfigurations();
Assert.assertEquals(1, backupAcceptors1.size());
Assert.assertEquals("61717", backupAcceptors1.iterator().next().getParams().get("port"));
Map<String, TransportConfiguration> connectorConfigurations0 = backupServer0.getConfiguration().getConnectorConfigurations();
Assert.assertEquals(2, connectorConfigurations0.size());
Assert.assertEquals("61716", connectorConfigurations0.get("liveConnector0").getParams().get("port"));
Assert.assertEquals("61617", connectorConfigurations0.get("remoteConnector0").getParams().get("port"));
Map<String, TransportConfiguration> connectorConfigurations1 = backupServer1.getConfiguration().getConnectorConfigurations();
Assert.assertEquals(2, connectorConfigurations1.size());
Assert.assertEquals("61717", connectorConfigurations1.get("liveConnector1").getParams().get("port"));
Assert.assertEquals("61616", connectorConfigurations1.get("remoteConnector1").getParams().get("port"));
if (!replicated) {
Assert.assertEquals(server0.getConfiguration().getJournalDirectory(), backupServer1.getConfiguration().getJournalDirectory());
Assert.assertEquals(server0.getConfiguration().getBindingsDirectory(), backupServer1.getConfiguration().getBindingsDirectory());
Assert.assertEquals(server0.getConfiguration().getLargeMessagesDirectory(), backupServer1.getConfiguration().getLargeMessagesDirectory());
Assert.assertEquals(server0.getConfiguration().getPagingDirectory(), backupServer1.getConfiguration().getPagingDirectory());
Assert.assertEquals(server1.getConfiguration().getJournalDirectory(), backupServer0.getConfiguration().getJournalDirectory());
Assert.assertEquals(server1.getConfiguration().getBindingsDirectory(), backupServer0.getConfiguration().getBindingsDirectory());
Assert.assertEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory());
Assert.assertEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory());
} else {
Assert.assertNotEquals(server0.getConfiguration().getJournalDirectory(), backupServer1.getConfiguration().getJournalDirectory());
Assert.assertNotEquals(server0.getConfiguration().getBindingsDirectory(), backupServer1.getConfiguration().getBindingsDirectory());
Assert.assertNotEquals(server0.getConfiguration().getLargeMessagesDirectory(), backupServer1.getConfiguration().getLargeMessagesDirectory());
Assert.assertNotEquals(server0.getConfiguration().getPagingDirectory(), backupServer1.getConfiguration().getPagingDirectory());
Assert.assertNotEquals(server1.getConfiguration().getJournalDirectory(), backupServer0.getConfiguration().getJournalDirectory());
Assert.assertNotEquals(server1.getConfiguration().getBindingsDirectory(), backupServer0.getConfiguration().getBindingsDirectory());
Assert.assertNotEquals(server1.getConfiguration().getLargeMessagesDirectory(), backupServer0.getConfiguration().getLargeMessagesDirectory());
Assert.assertNotEquals(server1.getConfiguration().getPagingDirectory(), backupServer0.getConfiguration().getPagingDirectory());
}
} finally {
try {
server0.stop();
} catch (Throwable e) {
e.printStackTrace();
}
server1.stop();
}
}
use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.
the class ClusterTestBase method logTopologyDiagram.
private void logTopologyDiagram() {
StringBuffer topologyDiagram = new StringBuffer();
for (ActiveMQServer activeMQServer : servers) {
if (activeMQServer != null) {
topologyDiagram.append("\n").append(activeMQServer.getIdentity()).append("\n");
if (activeMQServer.isStarted()) {
Set<ClusterConnection> ccs = activeMQServer.getClusterManager().getClusterConnections();
if (ccs.size() >= 1) {
ClusterConnectionImpl clusterConnection = (ClusterConnectionImpl) ccs.iterator().next();
Collection<TopologyMemberImpl> members = clusterConnection.getTopology().getMembers();
for (TopologyMemberImpl member : members) {
String nodeId = member.getNodeId();
String liveServer = null;
String backupServer = null;
for (ActiveMQServer server : servers) {
if (server != null && server.getNodeID() != null && server.isActive() && server.getNodeID().toString().equals(nodeId)) {
if (server.isActive()) {
liveServer = server.getIdentity();
if (member.getLive() != null) {
liveServer += "(notified)";
} else {
liveServer += "(not notified)";
}
} else {
backupServer = server.getIdentity();
if (member.getBackup() != null) {
liveServer += "(notified)";
} else {
liveServer += "(not notified)";
}
}
}
}
topologyDiagram.append("\t").append("|\n").append("\t->").append(liveServer).append("/").append(backupServer).append("\n");
}
} else {
topologyDiagram.append("-> no cluster connections\n");
}
} else {
topologyDiagram.append("-> stopped\n");
}
}
}
topologyDiagram.append("\n");
log.info(topologyDiagram.toString());
}
Aggregations