use of pipelite.executor.AbstractAsyncExecutor 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;
}
Aggregations