Search in sources :

Example 1 with ProcessEntityCreator

use of pipelite.runner.process.creator.ProcessEntityCreator in project pipelite by enasequence.

the class PipelineRunnerProcessQueueTest method test.

private void test(Pipeline pipeline) {
    ProcessEntityCreator processEntityCreator = new ProcessEntityCreator(pipeline, pipeliteServices.process());
    ProcessQueue processQueue = spy(new ProcessQueue(pipeliteConfiguration, pipeliteServices, pipeline));
    // Queue should be filled
    assertThat(processQueue.isRefreshQueue()).isTrue();
    // Queue should be empty
    assertThat(processQueue.getProcessQueueSize()).isZero();
    boolean lockProcess = true;
    PipelineRunner pipelineRunner = PipelineRunnerFactory.create(pipeliteConfiguration, pipeliteServices, pipeliteMetrics, pipeline, processEntityCreator, (pipeline1) -> processQueue, (pipelineName1, process1) -> new ProcessRunner(pipeliteConfiguration, pipeliteServices, pipeliteMetrics, pipelineName1, process1, lockProcess));
    // Wait for the processes to execute
    while (!pipelineRunner.isIdle()) {
        Time.wait(Duration.ofSeconds(1));
        pipelineRunner.runOneIteration();
    }
    // Refresh is called two times. Once before creating processes when
    // the process queue is created empty and immediately after
    // creating processing.
    verify(processQueue, times(2)).refreshQueue();
    assertThat(pipeliteMetrics.pipeline(pipeline.pipelineName()).stage().getSuccessCount()).isEqualTo(PROCESS_CNT);
    assertThat(processQueue.isRefreshQueue()).isFalse();
    assertThat(processQueue.getProcessQueueSize()).isZero();
}
Also used : ProcessQueue(pipelite.runner.process.ProcessQueue) ProcessEntityCreator(pipelite.runner.process.creator.ProcessEntityCreator) ProcessRunner(pipelite.runner.process.ProcessRunner)

Example 2 with ProcessEntityCreator

use of pipelite.runner.process.creator.ProcessEntityCreator in project pipelite by enasequence.

the class PipelineRunnerFactory method create.

public static PipelineRunner create(PipeliteConfiguration pipeliteConfiguration, PipeliteServices pipeliteServices, PipeliteMetrics pipeliteMetrics, String pipelineName) {
    // Get registered pipeline.
    RegisteredPipelineService registeredPipelineService = pipeliteServices.registeredPipeline();
    Pipeline pipeline = registeredPipelineService.getRegisteredPipeline(pipelineName, Pipeline.class);
    if (pipeline == null) {
        throw new PipeliteException("Missing pipeline: " + pipelineName);
    }
    // Get process creator.
    ProcessEntityCreator processEntityCreator = new ProcessEntityCreator(pipeline, pipeliteServices.process());
    ProcessQueueFactory processQueueFactory = (pipeline1) -> new ProcessQueue(pipeliteConfiguration, pipeliteServices, pipeline1);
    boolean lockProcess = true;
    ProcessRunnerFactory processRunnerFactory = (pipelineName1, process1) -> new ProcessRunner(pipeliteConfiguration, pipeliteServices, pipeliteMetrics, pipelineName1, process1, lockProcess);
    return create(pipeliteConfiguration, pipeliteServices, pipeliteMetrics, pipeline, processEntityCreator, processQueueFactory, processRunnerFactory);
}
Also used : ProcessQueue(pipelite.runner.process.ProcessQueue) ProcessRunnerFactory(pipelite.runner.process.ProcessRunnerFactory) PipeliteMetrics(pipelite.metrics.PipeliteMetrics) ProcessQueueFactory(pipelite.runner.process.ProcessQueueFactory) PipeliteException(pipelite.exception.PipeliteException) RegisteredPipelineService(pipelite.service.RegisteredPipelineService) ProcessEntityCreator(pipelite.runner.process.creator.ProcessEntityCreator) PipeliteConfiguration(pipelite.configuration.PipeliteConfiguration) Pipeline(pipelite.Pipeline) ProcessRunner(pipelite.runner.process.ProcessRunner) PipeliteServices(pipelite.service.PipeliteServices) ProcessQueueFactory(pipelite.runner.process.ProcessQueueFactory) ProcessRunnerFactory(pipelite.runner.process.ProcessRunnerFactory) RegisteredPipelineService(pipelite.service.RegisteredPipelineService) ProcessQueue(pipelite.runner.process.ProcessQueue) PipeliteException(pipelite.exception.PipeliteException) ProcessEntityCreator(pipelite.runner.process.creator.ProcessEntityCreator) ProcessRunner(pipelite.runner.process.ProcessRunner) Pipeline(pipelite.Pipeline)

Aggregations

ProcessQueue (pipelite.runner.process.ProcessQueue)2 ProcessRunner (pipelite.runner.process.ProcessRunner)2 ProcessEntityCreator (pipelite.runner.process.creator.ProcessEntityCreator)2 Pipeline (pipelite.Pipeline)1 PipeliteConfiguration (pipelite.configuration.PipeliteConfiguration)1 PipeliteException (pipelite.exception.PipeliteException)1 PipeliteMetrics (pipelite.metrics.PipeliteMetrics)1 ProcessQueueFactory (pipelite.runner.process.ProcessQueueFactory)1 ProcessRunnerFactory (pipelite.runner.process.ProcessRunnerFactory)1 PipeliteServices (pipelite.service.PipeliteServices)1 RegisteredPipelineService (pipelite.service.RegisteredPipelineService)1