use of org.apache.storm.testing.AckFailMapTracker in project storm by apache.
the class TestingTest method testAdvanceClusterTime.
@Test
public void testAdvanceClusterTime() throws Exception {
Config daemonConf = new Config();
daemonConf.put(Config.TOPOLOGY_ENABLE_MESSAGE_TIMEOUTS, true);
try (LocalCluster cluster = new LocalCluster.Builder().withDaemonConf(daemonConf).withSimulatedTime().build()) {
FeederSpout feeder = new FeederSpout(new Fields("field1"));
AckFailMapTracker tracker = new AckFailMapTracker();
feeder.setAckFailDelegate(tracker);
Map<String, Thrift.SpoutDetails> spoutMap = new HashMap<>();
spoutMap.put("1", Thrift.prepareSpoutDetails(feeder));
Map<String, Thrift.BoltDetails> boltMap = new HashMap<>();
boltMap.put("2", Thrift.prepareBoltDetails(Collections.singletonMap(Utils.getGlobalStreamId("1", null), Thrift.prepareShuffleGrouping()), new AckEveryOtherBolt()));
StormTopology topology = Thrift.buildTopology(spoutMap, boltMap);
Config stormConf = new Config();
stormConf.put(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS, 10);
cluster.submitTopology("timeout-tester", stormConf, topology);
feeder.feed(new Values("a"), 1);
feeder.feed(new Values("b"), 2);
feeder.feed(new Values("c"), 3);
cluster.advanceClusterTime(9);
assertAcked(tracker, 1, 3);
assertThat(tracker.isFailed(2), is(false));
cluster.advanceClusterTime(12);
assertFailed(tracker, 2);
}
}
Aggregations