ad.initialize();
List<ClusterDefinition> clusters = ad.getClusterDefinitions();
for (int i = clusters.size() - 1; i >= 0; i--)
{
ClusterDefinition cluster = clusters.get(i);
CheckCluster.toCheckAgainst = cluster.getClusterId();
DempsyHolder cur = new DempsyHolder();
cur.clusterid = cluster.getClusterId();
cur.actx = new ClassPathXmlApplicationContext(ctx);
cur.actx.registerShutdownHook();
cur.dempsy = (Dempsy)cur.actx.getBean("dempsy");
cur.dempsy.start();
dempsys.put(cluster.getClusterId(), cur);
}
// get the last FullApplication in the processing chain.
ClassPathXmlApplicationContext actx = dempsys.get(new ClusterId(FullApplication.class.getSimpleName(),MyRankMp.class.getSimpleName())).actx;
final FullApplication app = (FullApplication)actx.getBean("app");
// this checks that the throughput works.
assertTrue(poll(baseTimeoutMillis * 5, app, new Condition<Object>()
{
@Override
public boolean conditionMet(Object o)
{
return app.finalMessageCount.get() > 100;
}
}));
// now start another MyMp cluster.
spare = new DempsyHolder();
spare.clusterid = new ClusterId(FullApplication.class.getSimpleName(),MyMp.class.getSimpleName());
CheckCluster.toCheckAgainst = spare.clusterid;
spare.actx = new ClassPathXmlApplicationContext(ctx);
spare.dempsy = (Dempsy)spare.actx.getBean("dempsy");
spare.dempsy.start();
Dempsy.Application.Cluster cluster = spare.dempsy.getCluster(spare.clusterid);
Dempsy.Application.Cluster.Node node = cluster.getNodes().get(0);
final StatsCollector collector = node.getStatsCollector();
// we are going to create another node of the MyMp via a test hack
cluster = spare.dempsy.getCluster(new ClusterId(FullApplication.class.getSimpleName(),MyMp.class.getSimpleName()));
node = cluster.getNodes().get(0);
final MyMp spareprototype = (MyMp)node.getMpContainer().getPrototype();
// TODO, see if we really need that check, and if so, implement
// an alternate way to get it, since with the stats collector rework
// we no longer use an independent MetricsRegistry per StatsCollector