use of teetime.framework.TeeTimeScheduler 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));
}
use of teetime.framework.TeeTimeScheduler in project TeeTime by teetime-framework.
the class PipelineIT method shouldExecutePipelineCorrectlyThreeElementsWith3ExecutionsPerTask.
@Test
public void shouldExecutePipelineCorrectlyThreeElementsWith3ExecutionsPerTask() {
String[] inputElements = { "a", "b", "c" };
GlobalTaskPoolConfig<String> config = new GlobalTaskPoolConfig<>(inputElements);
TeeTimeScheduler scheduling = new GlobalTaskPoolScheduling(NUM_THREADS, config, 3);
Execution<GlobalTaskPoolConfig<String>> execution = new Execution<>(config, true, scheduling);
execution.executeBlocking();
List<String> processedElements = config.getSink().getElements();
List<String> expectedElements = Arrays.asList("a", "b", "c");
assertThat(WRONG_PIPELINE_EXECUTION, processedElements, is(equalTo(expectedElements)));
}
use of teetime.framework.TeeTimeScheduler in project TeeTime by teetime-framework.
the class PipelineIT method shouldExecuteReflexivePipeCorrectlyManyElements.
@Test
@Ignore("The reflexive pipe in the counter is not handled correctly by the scheduling strategy so far")
public void shouldExecuteReflexivePipeCorrectlyManyElements() {
int numElements = 1_000;
ManyElementsWithStatelessStageGlobalTaskPoolConfig config = new ManyElementsWithStatelessStageGlobalTaskPoolConfig(numElements);
TeeTimeScheduler scheduling = new GlobalTaskPoolScheduling(NUM_THREADS, config, 1);
Execution<ManyElementsWithStatelessStageGlobalTaskPoolConfig> execution = new Execution<>(config, true, scheduling);
execution.executeBlocking();
List<Integer> processedElements = config.getSink().getElements();
for (int i = 0; i < numElements; i++) {
assertThat(processedElements.get(i), is(i));
}
assertThat(processedElements, hasSize(numElements));
}
use of teetime.framework.TeeTimeScheduler 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));
}
use of teetime.framework.TeeTimeScheduler in project TeeTime by teetime-framework.
the class ThreeStagesGlobalTaskPoolIT method shouldExecutePipelineCorrectlyManyElements.
private void shouldExecutePipelineCorrectlyManyElements(final int numElements, final int numThreads, final int numExecutions) {
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 GlobalTaskPoolScheduling(numThreads, config, numExecutions);
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));
}
Aggregations