Search in sources :

Example 6 with ListSource

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));
}
Also used : Vertex(com.hazelcast.jet.core.Vertex) JetInstance(com.hazelcast.jet.JetInstance) ListSource(com.hazelcast.jet.core.TestProcessors.ListSource) AggregateOperations.summingLong(com.hazelcast.jet.aggregate.AggregateOperations.summingLong) DAG(com.hazelcast.jet.core.DAG)

Aggregations

ListSource (com.hazelcast.jet.core.TestProcessors.ListSource)6 DAG (com.hazelcast.jet.core.DAG)4 Vertex (com.hazelcast.jet.core.Vertex)4 Test (org.junit.Test)3 Job (com.hazelcast.jet.Job)2 AggregateOperations.summingLong (com.hazelcast.jet.aggregate.AggregateOperations.summingLong)2 StuckForeverSourceP (com.hazelcast.jet.core.TestProcessors.StuckForeverSourceP)2 Watermark (com.hazelcast.jet.core.Watermark)2 HazelcastInstance (com.hazelcast.core.HazelcastInstance)1 JetInstance (com.hazelcast.jet.JetInstance)1 JobConfig (com.hazelcast.jet.config.JobConfig)1 MockPS (com.hazelcast.jet.core.TestProcessors.MockPS)1 ParallelJVMTest (com.hazelcast.test.annotation.ParallelJVMTest)1 QuickTest (com.hazelcast.test.annotation.QuickTest)1