use of pipelite.executor.JsonSerializableExecutor 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.executor.JsonSerializableExecutor 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