use of pipelite.stage.parameters.ExecutorParameters in project pipelite by enasequence.
the class ProcessRunnerPoolTest method createProcess.
private Process createProcess(Function<StageExecutorRequest, StageExecutorResult> callback) {
String processId = PipeliteIdCreator.processId();
ExecutorParameters executorParams = new ExecutorParameters();
executorParams.setMaximumRetries(0);
Process process = new ProcessBuilder(processId).execute("STAGE1").withAsyncTestExecutor(callback, executorParams).build();
ProcessEntity processEntity = ProcessEntity.createExecution(PIPELINE_NAME, processId, ProcessEntity.DEFAULT_PRIORITY);
process.setProcessEntity(processEntity);
return process;
}
use of pipelite.stage.parameters.ExecutorParameters in project pipelite by enasequence.
the class StageRunner method getImmediateRetries.
/**
* Returns the maximum number of immediate retries for the stage.
*
* @return The maximum number of immediate retries.
*/
public static int getImmediateRetries(Stage stage) {
ExecutorParameters executorParams = stage.getExecutor().getExecutorParams();
int immediateRetries = ExecutorParameters.DEFAULT_IMMEDIATE_RETRIES;
if (executorParams.getImmediateRetries() != null) {
immediateRetries = executorParams.getImmediateRetries();
}
return Math.min(Math.max(0, immediateRetries), getMaximumRetries(stage));
}
use of pipelite.stage.parameters.ExecutorParameters 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.stage.parameters.ExecutorParameters in project pipelite by enasequence.
the class StageRunner method getMaximumRetries.
/**
* Returns the maximum number of retries for the stage.
*
* @return The maximum number of retries.
*/
public static int getMaximumRetries(Stage stage) {
ExecutorParameters executorParams = stage.getExecutor().getExecutorParams();
int maximumRetries = ExecutorParameters.DEFAULT_MAX_RETRIES;
if (executorParams.getMaximumRetries() != null) {
maximumRetries = executorParams.getMaximumRetries();
}
return Math.max(0, maximumRetries);
}
use of pipelite.stage.parameters.ExecutorParameters in project pipelite by enasequence.
the class ProcessRunnerTest method twoIndependentStagesProcess.
public static Process twoIndependentStagesProcess(StageState firstStageState, StageState secondStageState, int firstStageExecutions, int secondStageExecutions, int maximumRetries, int immediateRetries) {
ExecutorParameters executorParams = ExecutorParameters.builder().maximumRetries(maximumRetries).immediateRetries(immediateRetries).build();
Process process = new ProcessBuilder("pipelite-test").execute("STAGE0").withSyncTestExecutor((request) -> null, executorParams).execute("STAGE1").withSyncTestExecutor((request) -> null, executorParams).build();
List<Stage> stages = new ArrayList<>();
Stage firstStage = process.getStage("STAGE0").get();
StageEntity firstStageEntity = new StageEntity();
firstStage.setStageEntity(firstStageEntity);
firstStageEntity.setStageState(firstStageState);
firstStageEntity.setExecutionCount(firstStageExecutions);
for (int i = 0; i < firstStageExecutions; ++i) {
firstStage.incrementImmediateExecutionCount();
}
stages.add(firstStage);
Stage secondStage = process.getStage("STAGE1").get();
StageEntity secondStageEntity = new StageEntity();
secondStage.setStageEntity(secondStageEntity);
secondStageEntity.setStageState(secondStageState);
secondStageEntity.setExecutionCount(secondStageExecutions);
for (int i = 0; i < secondStageExecutions; ++i) {
secondStage.incrementImmediateExecutionCount();
}
stages.add(secondStage);
return process;
}
Aggregations