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)));
}
}
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));
}
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));
}
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);
}
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));
}
Aggregations