Search in sources :

Example 6 with Execution

use of teetime.framework.Execution in project TeeTime by teetime-framework.

the class MultipleExecutionsProducerIT method testRegularExecution.

void testRegularExecution(final List<String> expectedElements, final int numThreads) {
    for (int numOfExecutions = 1; numOfExecutions < expectedElements.size() + 1; numOfExecutions++) {
        List<String> actualElements = new ArrayList<>();
        Configuration configuration = new Configuration().from(new ResponsiveProducer<String>(expectedElements)).end(new CollectorSink<String>(actualElements));
        GlobalTaskPoolScheduling scheduler = new GlobalTaskPoolScheduling(numThreads, configuration, numOfExecutions);
        Execution<Configuration> execution = new Execution<>(configuration, true, scheduler);
        execution.executeBlocking();
        assertThat("failed with numOfExecutions=" + numOfExecutions, actualElements, is(equalTo(expectedElements)));
    }
}
Also used : ResponsiveProducer(teetime.stage.ResponsiveProducer) Execution(teetime.framework.Execution) Configuration(teetime.framework.Configuration) ArrayList(java.util.ArrayList)

Example 7 with Execution

use of teetime.framework.Execution in project TeeTime by teetime-framework.

the class ParallelCounterConfigIT method testParallelExecution.

private void testParallelExecution(final int numElements, final int numThreads, final int numExecutions) {
    List<Integer> processedElements = new ArrayList<>();
    ParallelCounterConfig config = new ParallelCounterConfig(numElements, numThreads, processedElements);
    TeeTimeScheduler scheduling = new GlobalTaskPoolScheduling(numThreads, config, numExecutions);
    Execution<ParallelCounterConfig> execution = new Execution<>(config, true, scheduling);
    execution.executeBlocking();
    for (int i = 0; i < numElements; i++) {
        assertThat(processedElements.get(i), is(i));
    }
    assertThat(processedElements, hasSize(numElements));
}
Also used : Execution(teetime.framework.Execution) ArrayList(java.util.ArrayList) TeeTimeScheduler(teetime.framework.TeeTimeScheduler)

Example 8 with Execution

use of teetime.framework.Execution in project TeeTime by teetime-framework.

the class ProducerConsumerGlobalTaskPoolIT method shouldExecuteProducerConsumer.

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

Example 9 with Execution

use of teetime.framework.Execution in project iobserve-analysis by research-iobserve.

the class AtomicActionComputationTest method executeStage.

private ExecutionPlan executeStage(final SystemAdaptation systemAdaptationModel) {
    final InitialElementProducer<SystemAdaptation> producer = new InitialElementProducer<>(systemAdaptationModel);
    final AtomicActionComputation atomicActionComputation = new AtomicActionComputation();
    final CollectorSink<ExecutionPlan> collector = new CollectorSink<>();
    final AtomicActionComputationTestConfig configuration = new AtomicActionComputationTestConfig(producer, atomicActionComputation, collector);
    final Execution<AtomicActionComputationTestConfig> execution = new Execution<>(configuration);
    execution.executeBlocking();
    return collector.getElements().get(0);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) InitialElementProducer(teetime.stage.InitialElementProducer) ExecutionPlan(org.iobserve.adaptation.executionplan.ExecutionPlan) Execution(teetime.framework.Execution) CollectorSink(teetime.stage.CollectorSink) AtomicActionComputation(org.iobserve.adaptation.stages.AtomicActionComputation)

Example 10 with Execution

use of teetime.framework.Execution 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

Execution (teetime.framework.Execution)19 Test (org.junit.Test)10 TeeTimeScheduler (teetime.framework.TeeTimeScheduler)10 Configuration (teetime.framework.Configuration)7 ArrayList (java.util.ArrayList)6 CollectorSink (teetime.stage.CollectorSink)6 File (java.io.File)3 List (java.util.List)3 IntStream (java.util.stream.IntStream)3 Matchers (org.hamcrest.Matchers)3 Assert (org.junit.Assert)3 IMonitorablePipe (teetime.framework.pipe.IMonitorablePipe)3 Counter (teetime.stage.Counter)3 InitialElementProducer (teetime.stage.InitialElementProducer)3 StreamProducer (teetime.stage.StreamProducer)3 NonBlockingRoundRobinStrategy (teetime.stage.basic.distributor.strategy.NonBlockingRoundRobinStrategy)3 StopWatch (teetime.util.StopWatch)3 SystemAdaptation (org.iobserve.planning.systemadaptation.SystemAdaptation)2 FixMethodOrder (org.junit.FixMethodOrder)2 Ignore (org.junit.Ignore)2