use of org.apache.activemq.artemis.core.client.impl.TopologyMemberImpl in project activemq-artemis by apache.
the class JMSUtil method waitForFailoverTopology.
public static void waitForFailoverTopology(final int timeToWait, final ActiveMQServer backupServer, final ActiveMQServer... liveServers) throws Exception {
long start = System.currentTimeMillis();
final int waitMillis = 2000;
final int sleepTime = 50;
int nWaits = 0;
while ((backupServer.getClusterManager() == null || backupServer.getClusterManager().getClusterConnections().size() != 1) && nWaits++ < waitMillis / sleepTime) {
Thread.sleep(sleepTime);
}
Set<ClusterConnection> ccs = backupServer.getClusterManager().getClusterConnections();
if (ccs.size() != 1) {
throw new IllegalStateException("You need a single cluster connection on this version of waitForTopology on ServiceTestBase");
}
boolean exists = false;
for (ActiveMQServer liveServer : liveServers) {
ClusterConnectionImpl clusterConnection = (ClusterConnectionImpl) ccs.iterator().next();
Topology topology = clusterConnection.getTopology();
TransportConfiguration nodeConnector = liveServer.getClusterManager().getClusterConnections().iterator().next().getConnector();
do {
Collection<TopologyMemberImpl> members = topology.getMembers();
for (TopologyMemberImpl member : members) {
if (member.getConnector().getA() != null && member.getConnector().getA().equals(nodeConnector)) {
exists = true;
break;
}
}
if (exists) {
break;
}
Thread.sleep(10);
} while (System.currentTimeMillis() - start < timeToWait);
if (!exists) {
String msg = "Timed out waiting for cluster topology of " + backupServer + " (received " + topology.getMembers().size() + ") topology = " + topology + ")";
throw new Exception(msg);
}
}
}
Aggregations