Search in sources :

Example 1 with InitialElementProducer

use of teetime.stage.InitialElementProducer in project TeeTime by teetime-framework.

the class StageFactory method getProducerFromInputPort.

@SuppressWarnings("unchecked")
static <T> InitialElementProducer<T> getProducerFromInputPort(final InputPort<T> inputPort) {
    OutputPort<?> sourcePort = inputPort.getPipe().getSourcePort();
    AbstractStage owningStage = sourcePort.getOwningStage();
    if (owningStage instanceof InitialElementProducer) {
        return (InitialElementProducer<T>) owningStage;
    }
    String message = String.format("%s", owningStage);
    throw new IllegalArgumentException(message);
}
Also used : InitialElementProducer(teetime.stage.InitialElementProducer) AbstractStage(teetime.framework.AbstractStage)

Example 2 with InitialElementProducer

use of teetime.stage.InitialElementProducer 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 3 with InitialElementProducer

use of teetime.stage.InitialElementProducer in project TeeTime by teetime-framework.

the class OneExecutionProducerIT 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 InitialElementProducer<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 : InitialElementProducer(teetime.stage.InitialElementProducer) Execution(teetime.framework.Execution) Configuration(teetime.framework.Configuration) ArrayList(java.util.ArrayList)

Example 4 with InitialElementProducer

use of teetime.stage.InitialElementProducer in project iobserve-analysis by research-iobserve.

the class ComposedActionComputationTest method executeStage.

private SystemAdaptation executeStage(final AdaptationData adaptationData) {
    final InitialElementProducer<AdaptationData> producer = new InitialElementProducer<>(adaptationData);
    final ComposedActionComputation composedActionComputation = new ComposedActionComputation();
    final CollectorSink<SystemAdaptation> collector = new CollectorSink<>();
    final ComposedActionComputationTestConfig configuration = new ComposedActionComputationTestConfig(producer, this.actionFactoryInitializer, composedActionComputation, collector);
    final Execution<ComposedActionComputationTestConfig> execution = new Execution<>(configuration);
    execution.executeBlocking();
    return collector.getElements().get(0);
}
Also used : SystemAdaptation(org.iobserve.planning.systemadaptation.SystemAdaptation) InitialElementProducer(teetime.stage.InitialElementProducer) Execution(teetime.framework.Execution) CollectorSink(teetime.stage.CollectorSink) AdaptationData(org.iobserve.adaptation.data.AdaptationData) ComposedActionComputation(org.iobserve.adaptation.stages.ComposedActionComputation)

Aggregations

InitialElementProducer (teetime.stage.InitialElementProducer)4 Execution (teetime.framework.Execution)3 SystemAdaptation (org.iobserve.planning.systemadaptation.SystemAdaptation)2 CollectorSink (teetime.stage.CollectorSink)2 ArrayList (java.util.ArrayList)1 AdaptationData (org.iobserve.adaptation.data.AdaptationData)1 ExecutionPlan (org.iobserve.adaptation.executionplan.ExecutionPlan)1 AtomicActionComputation (org.iobserve.adaptation.stages.AtomicActionComputation)1 ComposedActionComputation (org.iobserve.adaptation.stages.ComposedActionComputation)1 AbstractStage (teetime.framework.AbstractStage)1 Configuration (teetime.framework.Configuration)1