use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class ProcessRunner method evaluateProcessState.
/**
* Evaluates the process state using the stage execution result types.
*
* @param process the process
* @return the process state
*/
public static ProcessState evaluateProcessState(Process process) {
int errorCount = 0;
for (Stage stage : process.getStages()) {
StageEntity stageEntity = stage.getStageEntity();
StageState stageState = stageEntity.getStageState();
if (stageState == SUCCESS) {
continue;
}
if (DependencyResolver.isEventuallyExecutableStage(process, stage)) {
return ProcessState.ACTIVE;
} else {
errorCount++;
}
}
if (errorCount > 0) {
return ProcessState.FAILED;
}
return ProcessState.COMPLETED;
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageService method deleteStageLog.
public static void deleteStageLog(StageLogRepository logRepository, Stage stage) {
StageEntity stageEntity = stage.getStageEntity();
StageLogEntityId stageLogEntityId = new StageLogEntityId(stageEntity.getProcessId(), stageEntity.getPipelineName(), stageEntity.getStageName());
if (logRepository.existsById(stageLogEntityId)) {
logRepository.deleteById(stageLogEntityId);
}
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageService method prepareSaveStage.
public static void prepareSaveStage(Stage stage) {
StageExecutor stageExecutor = stage.getExecutor();
StageEntity stageEntity = stage.getStageEntity();
stageEntity.setExecutorName(stageExecutor.getClass().getName());
if (stageExecutor instanceof JsonSerializableExecutor) {
stageEntity.setExecutorData(((JsonSerializableExecutor) stageExecutor).serialize());
}
if (stageExecutor.getExecutorParams() != null) {
stageEntity.setExecutorParams(stageExecutor.getExecutorParams().serialize());
}
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageExecutorSerializer method deserializeExecution.
/**
* Deserialize active stage executor and stage executor parameters. An asynchronous executor must
* be in the POLL state to be deserialized.
*
* @oaran stage the stage being executed
* @return true if the executor was deserialized
*/
public static <T extends ExecutorParameters> Boolean deserializeExecution(Stage stage, Deserialize deserialize) {
if (!(stage.getExecutor() instanceof JsonSerializableExecutor)) {
return false;
}
if (stage.getStageEntity().getStageState() != StageState.ACTIVE) {
return false;
}
StageEntity stageEntity = stage.getStageEntity();
if (stageEntity.getExecutorName() == null || stageEntity.getExecutorData() == null || stageEntity.getExecutorParams() == null) {
return false;
}
StageExecutor deserializedExecutor = deserializeExecutor(stage, deserialize);
if (deserializedExecutor == null) {
logContext(log.atSevere(), stage).log("Failed to deserialize executor");
return false;
}
if (deserialize == Deserialize.ASYNC_EXECUTOR) {
AbstractAsyncExecutor deserializedAsyncExecutor = (AbstractAsyncExecutor) deserializedExecutor;
if (deserializedAsyncExecutor.getJobId() == null) {
return false;
}
}
ExecutorParameters deserializedExecutorParams = deserializeExecutorParameters(stage, deserializedExecutor.getExecutorParamsType());
if (deserializedExecutorParams == null) {
return false;
}
logContext(log.atInfo(), stage).log("Using deserialized executor");
stage.setExecutor(deserializedExecutor);
deserializedExecutor.setExecutorParams(deserializedExecutorParams);
return true;
}
use of pipelite.entity.StageEntity in project pipelite by enasequence.
the class StageService method endExecution.
/**
* Called when the stage execution ends. Saves the stage and stage log.
*
* @param stage the stage
* @param result the stage execution result
*/
@Timed("pipelite.transactional")
public void endExecution(Stage stage, StageExecutorResult result) {
stage.incrementImmediateExecutionCount();
StageEntity stageEntity = stage.getStageEntity();
stageEntity.endExecution(result);
saveStage(stage);
saveStageLog(StageLogEntity.endExecution(stageEntity, result));
}
Aggregations