Search in sources :

Example 1 with PushPullScheduling

use of teetime.framework.scheduling.pushpullmodel.PushPullScheduling in project TeeTime by teetime-framework.

the class ThreeStagesPushPullIT method shouldExecutePipelineCorrectlyManyElements.

private void shouldExecutePipelineCorrectlyManyElements(final int numElements, final int numThreads) {
    List<Integer> processedElements = new ArrayList<>();
    IntStream inputElements = IntStream.iterate(0, i -> i + 1).limit(numElements);
    Configuration config = new Configuration().from(new StreamProducer<>(inputElements)).to(new Counter<>()).end(new CollectorSink<>(processedElements));
    TeeTimeScheduler scheduling = new PushPullScheduling(config);
    Execution<Configuration> execution = new Execution<>(config, true, scheduling);
    execution.executeBlocking();
    for (int i = 0; i < numElements; i++) {
        Integer actualElement = processedElements.get(i);
        assertThat(actualElement, is(i));
    }
    assertThat(processedElements, hasSize(numElements));
}
Also used : IntStream(java.util.stream.IntStream) MethodSorters(org.junit.runners.MethodSorters) StreamProducer(teetime.stage.StreamProducer) PushPullScheduling(teetime.framework.scheduling.pushpullmodel.PushPullScheduling) Matchers(org.hamcrest.Matchers) Test(org.junit.Test) TeeTimeScheduler(teetime.framework.TeeTimeScheduler) ArrayList(java.util.ArrayList) Configuration(teetime.framework.Configuration) List(java.util.List) CollectorSink(teetime.stage.CollectorSink) Execution(teetime.framework.Execution) Assert(org.junit.Assert) FixMethodOrder(org.junit.FixMethodOrder) Counter(teetime.stage.Counter) Configuration(teetime.framework.Configuration) ArrayList(java.util.ArrayList) PushPullScheduling(teetime.framework.scheduling.pushpullmodel.PushPullScheduling) Counter(teetime.stage.Counter) Execution(teetime.framework.Execution) TeeTimeScheduler(teetime.framework.TeeTimeScheduler) IntStream(java.util.stream.IntStream)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 IntStream (java.util.stream.IntStream)1 Matchers (org.hamcrest.Matchers)1 Assert (org.junit.Assert)1 FixMethodOrder (org.junit.FixMethodOrder)1 Test (org.junit.Test)1 MethodSorters (org.junit.runners.MethodSorters)1 Configuration (teetime.framework.Configuration)1 Execution (teetime.framework.Execution)1 TeeTimeScheduler (teetime.framework.TeeTimeScheduler)1 PushPullScheduling (teetime.framework.scheduling.pushpullmodel.PushPullScheduling)1 CollectorSink (teetime.stage.CollectorSink)1 Counter (teetime.stage.Counter)1 StreamProducer (teetime.stage.StreamProducer)1