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