use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessService method endExecution.
/**
* Called when the process execution ends. Sets the process state and the execution end time.
* Increases the process execution count. Saves the process.
*
* @param process the process
* @param processState the process state
*/
@Timed("pipelite.transactional")
public ProcessEntity endExecution(Process process, ProcessState processState) {
ProcessEntity processEntity = process.getProcessEntity();
processEntity.endExecution(processState);
ProcessEntity savedProcess = saveProcess(processEntity);
mailService.sendProcessExecutionMessage(process);
return savedProcess;
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ScheduleRunner method resumeSchedule.
protected void resumeSchedule(ScheduleCron scheduleCron) {
String pipelineName = scheduleCron.getPipelineName();
ScheduleEntity scheduleEntity = scheduleService.getSavedSchedule(pipelineName).get();
if (!scheduleEntity.isActive()) {
return;
}
logContext(log.atInfo(), pipelineName).log("Resuming schedule");
Optional<ProcessEntity> processEntity = getSavedProcess(scheduleEntity);
if (!processEntity.isPresent()) {
logContext(log.atSevere(), pipelineName, scheduleEntity.getProcessId()).log("Could not resume schedule because process does not exist");
} else {
executeSchedule(scheduleCron, processEntity.get(), ExecuteMode.RESUME);
}
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class MailService method getProcessExecutionSubject.
String getProcessExecutionSubject(Process process) {
ProcessEntity processEntity = process.getProcessEntity();
String state = "";
if (processEntity.getProcessState() != null) {
state = processEntity.getProcessState().name();
}
return "Pipelite process (" + state + "): " + processEntity.getPipelineName() + "/" + process.getProcessId();
}
use of pipelite.entity.ProcessEntity in project pipelite by enasequence.
the class ProcessEntityCreator method create.
/**
* Creates and saves a process entity.
*
* @param processService the process service
* @param pipelineName the pipeline name
* @param process the process for which the process entity is created
* @return the created process entity or null if it could not be created
*/
public static ProcessEntity create(ProcessService processService, String pipelineName, Pipeline.Process process) {
String processId = process.getProcessId();
if (processId == null || processId.trim().isEmpty()) {
throw new PipeliteException("Failed to create process: missing process id");
}
ProcessEntity processEntity;
String trimmedProcessId = processId.trim();
Optional<ProcessEntity> savedProcessEntity = processService.getSavedProcess(pipelineName, trimmedProcessId);
if (savedProcessEntity.isPresent()) {
// Process entity already exists
processEntity = savedProcessEntity.get();
} else {
processEntity = processService.createExecution(pipelineName, trimmedProcessId, process.getPriority().getInt());
if (processEntity == null) {
throw new RuntimeException("Failed to create process: " + trimmedProcessId);
}
}
return processEntity;
}
use of pipelite.entity.ProcessEntity 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;
}
Aggregations