use of com.hazelcast.jet.core.EventTimePolicy.DEFAULT_IDLE_TIMEOUT in project hazelcast by hazelcast.
the class StreamSourceTest method test.
private void test(long idleTimeout) {
StreamSource<Object> source = SourceBuilder.stream("src", Context::globalProcessorIndex).distributed(1).fillBufferFn((index, buf) -> {
// idle, there should be no output.
if (index == 0) {
buf.add("item");
Thread.sleep(10);
}
}).build();
if (idleTimeout != DEFAULT_IDLE_TIMEOUT) {
source = source.setPartitionIdleTimeout(idleTimeout);
}
Pipeline p = Pipeline.create();
p.readFrom(source).withTimestamps(o -> System.currentTimeMillis(), 0).window(WindowDefinition.tumbling(100)).aggregate(counting()).writeTo(sink);
Job job = allHazelcastInstances()[0].getJet().newJob(p);
if (idleTimeout > 10_000) {
assertTrueAllTheTime(() -> assertEquals("unexpected sink size", 0, sinkList.size()), 5);
} else if (idleTimeout < 1000) {
assertTrueEventually(() -> assertTrue("sink empty", sinkList.size() > 0));
} else {
fail("test not designed for idleTimeout=" + idleTimeout);
}
cancelAndJoin(job);
}
Aggregations