}
});
dempsy.start();
Dempsy.Application.Cluster cluster = dempsy.getCluster(new ClusterId(FullApplication.class.getSimpleName(),MyAdaptor.class.getSimpleName()));
Dempsy.Application.Cluster.Node node = cluster.getNodes().get(0);
final StatsCollector collector = node.getStatsCollector();
// this checks that the throughput works.
assertTrue(poll(baseTimeoutMillis * 5, app, new Condition<Object>()
{
@Override
public boolean conditionMet(Object o)
{
return app.finalMessageCount.get() > 10;
}
}));
assertNotNull(zookeeperCluster);
assertEquals(0,((MetricGetters)collector).getDiscardedMessageCount());
assertEquals(0,((MetricGetters)collector).getMessageFailedCount());
// ok ... so now we have stuff going all the way through. let's kick
// the middle Mp's zookeeper cluster and see what happens.
ZooKeeper origZk = zookeeperCluster.zkref.get();
long sessionid = origZk.getSessionId();
ZooKeeper killer = new ZooKeeper(System.getProperty("zk_connect"),5000, new Watcher() { @Override public void process(WatchedEvent arg0) { } }, sessionid, null);
killer.close(); // tricks the server into expiring the other session
// // we should be getting failures now ...
// // but it's possible that it can reconnect prior to actually seeing an error so if this
// // fails frequently we need to remove this test.
// assertTrue(poll(baseTimeoutMillis, app, new Condition()
// {
// @Override
// public boolean conditionMet(Object o)
// {
// return collector.getMessageFailedCount() > 1;
// }
// }));
//... and then recover.
// get the MyMp prototype
cluster = dempsy.getCluster(new ClusterId(FullApplication.class.getSimpleName(),MyMp.class.getSimpleName()));
node = cluster.getNodes().get(0);
final MyMp prototype = (MyMp)node.getMpContainer().getPrototype();
// so let's see where we are
final long interimMessageCount = prototype.myMpReceived.get();