use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ScheduleRunner method createProcessEntity.
private ProcessEntity createProcessEntity(ScheduleCron scheduleCron) {
String pipelineName = scheduleCron.getPipelineName();
ScheduleEntity scheduleEntity = scheduleService.getSavedSchedule(pipelineName).get();
String lastProcessId = scheduleEntity.getProcessId();
String nextProcessId = nextProcessId(lastProcessId);
Optional<ProcessEntity> processEntity = processService.getSavedProcess(pipelineName, nextProcessId);
if (processEntity.isPresent()) {
throw new PipeliteException("Scheduled new process already exists: " + pipelineName + " " + nextProcessId);
}
return processService.createExecution(pipelineName, nextProcessId, ProcessEntity.DEFAULT_PRIORITY);
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class PipelineRunner method runProcesses.
private void runProcesses() {
if (processQueue.get() == null) {
return;
}
while (true) {
ProcessEntity processEntity = processQueue.get().nextProcess(this.getActiveProcessCount());
if (processEntity == null) {
return;
}
runProcess(processEntity);
}
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class MailServiceTest method sendFailedStageExecutionMessageWithNullLog.
@Test
public void sendFailedStageExecutionMessageWithNullLog() {
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
Process process = new ProcessBuilder(processId).execute("STAGE1").withSyncTestExecutor().build();
Stage stage = process.getStage("STAGE1").get();
StageEntity.createExecution(pipelineName, processId, stage).setStageState(StageState.ERROR);
StageLogEntity stageLogEntity = new StageLogEntity();
stageLogEntity.setPipelineName(pipelineName);
stageLogEntity.setProcessId(processId);
stageLogEntity.setStageName("STAGE1");
stageLogEntity.setStageLog(null);
stageService.saveStageLog(stageLogEntity);
ProcessEntity processEntity = new ProcessEntity();
processEntity.setPipelineName(pipelineName);
processEntity.setProcessId(processId);
processEntity.setProcessState(ProcessState.PENDING);
processEntity.setPriority(5);
process.setProcessEntity(processEntity);
process.setProcessEntity(processEntity);
assertThat(mailService.getStageExecutionSubject(process, stage)).isEqualTo("Pipelite stage (ERROR): " + pipelineName + "/" + processId + "/STAGE1");
assertThat(mailService.getExecutionBody(process, "SUBJECT")).isEqualTo("SUBJECT\n" + "\n" + "Process:\n" + "---------------\n" + "{\n" + " \"processId\" : \"" + processId + "\",\n" + " \"pipelineName\" : \"" + pipelineName + "\",\n" + " \"processState\" : \"PENDING\",\n" + " \"executionCount\" : 0,\n" + " \"priority\" : 5\n" + "}\n" + "\n" + "Stages:\n" + "---------------\n" + "{\n" + " \"processId\" : \"" + processId + "\",\n" + " \"pipelineName\" : \"" + pipelineName + "\",\n" + " \"stageName\" : \"STAGE1\",\n" + " \"stageState\" : \"ERROR\",\n" + " \"executionCount\" : 0\n" + "}\n" + "\n" + "Error logs:\n" + "---------------\n");
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class MailServiceTest method sendProcessExecutionMessage.
@Test
public void sendProcessExecutionMessage() {
Process process = new ProcessBuilder("PROCESS_ID").execute("STAGE1").withSyncTestExecutor().build();
StageEntity.createExecution("PIPELINE_NAME", "PROCESS_ID", process.getStage("STAGE1").get());
ProcessEntity processEntity = new ProcessEntity();
processEntity.setPipelineName("PIPELINE_NAME");
processEntity.setProcessId("PROCESS_ID");
processEntity.setProcessState(ProcessState.PENDING);
processEntity.setPriority(5);
process.setProcessEntity(processEntity);
assertThat(mailService.getProcessExecutionSubject(process)).isEqualTo("Pipelite process (PENDING): PIPELINE_NAME/PROCESS_ID");
assertThat(mailService.getExecutionBody(process, "SUBJECT")).isEqualTo("SUBJECT\n" + "\n" + "Process:\n" + "---------------\n" + "{\n" + " \"processId\" : \"PROCESS_ID\",\n" + " \"pipelineName\" : \"PIPELINE_NAME\",\n" + " \"processState\" : \"PENDING\",\n" + " \"executionCount\" : 0,\n" + " \"priority\" : 5\n" + "}\n" + "\n" + "Stages:\n" + "---------------\n" + "{\n" + " \"processId\" : \"PROCESS_ID\",\n" + " \"pipelineName\" : \"PIPELINE_NAME\",\n" + " \"stageName\" : \"STAGE1\",\n" + " \"stageState\" : \"PENDING\",\n" + " \"executionCount\" : 0\n" + "}\n");
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class MailServiceTest method sendFailedStageExecutionMessageWithLog.
@Test
public void sendFailedStageExecutionMessageWithLog() {
String pipelineName = PipeliteIdCreator.pipelineName();
String processId = PipeliteIdCreator.processId();
Process process = new ProcessBuilder(processId).execute("STAGE1").withSyncTestExecutor().build();
Stage stage = process.getStage("STAGE1").get();
StageEntity.createExecution(pipelineName, processId, stage).setStageState(StageState.ERROR);
StageLogEntity stageLogEntity = new StageLogEntity();
stageLogEntity.setPipelineName(pipelineName);
stageLogEntity.setProcessId(processId);
stageLogEntity.setStageName("STAGE1");
stageLogEntity.setStageLog("TEST");
stageService.saveStageLog(stageLogEntity);
ProcessEntity processEntity = new ProcessEntity();
processEntity.setPipelineName(pipelineName);
processEntity.setProcessId(processId);
processEntity.setProcessState(ProcessState.PENDING);
processEntity.setPriority(5);
process.setProcessEntity(processEntity);
process.setProcessEntity(processEntity);
assertThat(mailService.getStageExecutionSubject(process, stage)).isEqualTo("Pipelite stage (ERROR): " + pipelineName + "/" + processId + "/STAGE1");
assertThat(mailService.getExecutionBody(process, "SUBJECT")).isEqualTo("SUBJECT\n" + "\n" + "Process:\n" + "---------------\n" + "{\n" + " \"processId\" : \"" + processId + "\",\n" + " \"pipelineName\" : \"" + pipelineName + "\",\n" + " \"processState\" : \"PENDING\",\n" + " \"executionCount\" : 0,\n" + " \"priority\" : 5\n" + "}\n" + "\n" + "Stages:\n" + "---------------\n" + "{\n" + " \"processId\" : \"" + processId + "\",\n" + " \"pipelineName\" : \"" + pipelineName + "\",\n" + " \"stageName\" : \"STAGE1\",\n" + " \"stageState\" : \"ERROR\",\n" + " \"executionCount\" : 0\n" + "}\n" + "\n" + "Error logs:\n" + "---------------\n" + "\n" + "Stage: STAGE1\n" + "===============\n" + "TEST\n");
}
Aggregations