Search in sources :

Example 1 with Pipeline

use of pipelite.Pipeline in project pipelite by enasequence.

the class ProcessFactoryTest method createFailed.

@Test
public void createFailed() {
    ProcessEntity processEntity = new ProcessEntity();
    processEntity.setProcessId(PROCESS_ID);
    Pipeline pipeline = new Pipeline() {

        @Override
        public String pipelineName() {
            return PIPELINE_NAME;
        }

        @Override
        public Options configurePipeline() {
            return new Options().pipelineParallelism(5);
        }

        @Override
        public void configureProcess(ProcessBuilder builder) {
        }
    };
    assertThrows(PipeliteException.class, () -> ProcessFactory.create(processEntity, pipeline));
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) ProcessBuilder(pipelite.process.builder.ProcessBuilder) Pipeline(pipelite.Pipeline) Test(org.junit.jupiter.api.Test)

Example 2 with Pipeline

use of pipelite.Pipeline in project pipelite by enasequence.

the class RegisteredPipelineService method registerPipeline.

public void registerPipeline(RegisteredPipeline registeredPipeline) {
    String pipelineName = registeredPipeline.pipelineName();
    if (pipelineName == null || pipelineName.trim().isEmpty()) {
        throw new PipeliteException("Missing pipeline name");
    }
    if (registeredPipelineMap.containsKey(pipelineName)) {
        throw new PipeliteException("Non-unique pipeline name: " + pipelineName);
    }
    if (registeredPipeline instanceof Schedule) {
        Schedule schedule = (Schedule) registeredPipeline;
        String cron = schedule.configurePipeline().cron();
        if (cron == null) {
            throw new PipeliteException("Missing cron expression for pipeline schedule: " + pipelineName);
        }
        if (!CronUtils.validate(cron)) {
            throw new PipeliteException("Invalid cron expression '" + cron + "' for pipeline schedule: " + pipelineName);
        }
    } else if (registeredPipeline instanceof Pipeline) {
        Pipeline pipeline = (Pipeline) registeredPipeline;
        int pipelineParallelism = pipeline.configurePipeline().pipelineParallelism();
        if (pipelineParallelism < 1) {
            throw new PipeliteException("Invalid pipeline parallelism '" + pipelineParallelism + "' for pipeline: " + pipelineName);
        }
    }
    registeredPipelineMap.put(pipelineName, registeredPipeline);
}
Also used : Schedule(pipelite.Schedule) PipeliteException(pipelite.exception.PipeliteException) RegisteredPipeline(pipelite.RegisteredPipeline) Pipeline(pipelite.Pipeline)

Example 3 with Pipeline

use of pipelite.Pipeline in project pipelite by enasequence.

the class ProcessEntityCreator method create.

/**
 * Creates and saves process entities.
 *
 * @param processCnt the number of process entities to create
 * @return the number of created process entities
 */
public int create(int processCnt) {
    if (pipeline == null) {
        return 0;
    }
    int createCnt = 0;
    logContext(log.atInfo()).log("Creating new processes");
    while (processCnt-- > 0) {
        Pipeline.Process process = pipeline.nextProcess();
        if (process == null) {
            return createCnt;
        }
        ProcessEntity processEntity = create(processService, pipelineName, process);
        if (processEntity != null) {
            pipeline.confirmProcess(processEntity.getProcessId());
            createCnt++;
        }
    }
    logContext(log.atInfo()).log("Created " + createCnt + " new processes");
    return createCnt;
}
Also used : ProcessEntity(pipelite.entity.ProcessEntity) Pipeline(pipelite.Pipeline)

Example 4 with Pipeline

use of pipelite.Pipeline 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)

Example 5 with Pipeline

use of pipelite.Pipeline in project pipelite by enasequence.

the class PipelineRunnerProcessQueueTest method sync.

@Test
public void sync() {
    Pipeline pipeline = new ConfigurableTestPipeline<>(PARALLELISM, PROCESS_CNT, new SyncTestProcessConfiguration());
    test(pipeline);
}
Also used : ConfigurableTestPipeline(pipelite.tester.pipeline.ConfigurableTestPipeline) ConfigurableTestPipeline(pipelite.tester.pipeline.ConfigurableTestPipeline) Pipeline(pipelite.Pipeline) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

Pipeline (pipelite.Pipeline)8 Test (org.junit.jupiter.api.Test)4 ProcessEntity (pipelite.entity.ProcessEntity)3 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 PipeliteException (pipelite.exception.PipeliteException)2 ProcessBuilder (pipelite.process.builder.ProcessBuilder)2 ConfigurableTestPipeline (pipelite.tester.pipeline.ConfigurableTestPipeline)2 RegisteredPipeline (pipelite.RegisteredPipeline)1 Schedule (pipelite.Schedule)1 PipeliteConfiguration (pipelite.configuration.PipeliteConfiguration)1 PipeliteMetrics (pipelite.metrics.PipeliteMetrics)1 PipelineRunner (pipelite.runner.pipeline.PipelineRunner)1 ProcessQueue (pipelite.runner.process.ProcessQueue)1 ProcessQueueFactory (pipelite.runner.process.ProcessQueueFactory)1 ProcessRunner (pipelite.runner.process.ProcessRunner)1 ProcessRunnerFactory (pipelite.runner.process.ProcessRunnerFactory)1 ProcessEntityCreator (pipelite.runner.process.creator.ProcessEntityCreator)1 PipeliteServices (pipelite.service.PipeliteServices)1 RegisteredPipelineService (pipelite.service.RegisteredPipelineService)1