use of com.hazelcast.jet.core.TestProcessors.ListSource in project hazelcast-jet by hazelcast.
the class Processors_globalAggregationIntegrationTest method runTest.
private void runTest(List<Long> sourceItems, Long expectedOutput) throws Exception {
JetInstance instance = createJetMember();
AggregateOperation1<Long, ?, Long> summingOp = summingLong((Long l) -> l);
DAG dag = new DAG();
Vertex source = dag.newVertex("source", () -> new ListSource(sourceItems)).localParallelism(1);
Vertex sink = dag.newVertex("sink", writeListP("sink"));
if (singleStageProcessor) {
Vertex aggregate = dag.newVertex("aggregate", Processors.aggregateP(summingOp)).localParallelism(1);
dag.edge(between(source, aggregate).distributed().allToOne()).edge(between(aggregate, sink).isolated());
} else {
Vertex accumulate = dag.newVertex("accumulate", Processors.accumulateP(summingOp));
Vertex combine = dag.newVertex("combine", combineP(summingOp)).localParallelism(1);
dag.edge(between(source, accumulate)).edge(between(accumulate, combine).distributed().allToOne()).edge(between(combine, sink).isolated());
}
instance.newJob(dag).join();
IList<Long> sinkList = instance.getList("sink");
assertEquals(singletonList(expectedOutput), new ArrayList<>(sinkList));
// wait a little more and make sure, that there are no more frames
Thread.sleep(1000);
assertEquals(singletonList(expectedOutput), new ArrayList<>(sinkList));
assertEquals(expectedOutput, sinkList.get(0));
}
Aggregations