From 404fb6c8b22d5b5a2cf280c149c3102563cbf63a Mon Sep 17 00:00:00 2001 From: wangqi <1942460489@qq.com> Date: Mon, 2 Sep 2024 00:06:39 +0800 Subject: [PATCH] feature: update scheduler and workflow --- .../common/dict/schedule/ScheduleStatus.java | 61 +++++ .../dict/workflow/WorkflowExecuteType.java | 64 +++++ .../dict/workflow/WorkflowInstanceEvent.java | 65 +++++ .../dict/workflow/WorkflowInstanceState.java | 64 +++++ .../workflow/WorkflowTaskInstanceEvent.java | 65 +++++ .../workflow/WorkflowTaskInstanceStage.java | 64 +++++ .../dict/workflow/WorkflowTaskType.java | 60 +++++ .../common/dict/workflow/WorkflowType.java | 60 +++++ .../framework/dag/task/RetryableTask.java | 24 -- .../framework/dag/task/SkippableTask.java | 6 - .../sliew/carp/framework/dag/task/Task.java | 13 - .../carp/framework/dag/task/TaskResult.java | 4 - .../task/graph/StageDefinitionBuilder.java | 109 -------- .../dag/task/graph/StageGraphBuilder.java | 75 ------ .../framework/dag/task/graph/TaskNode.java | 214 ---------------- .../dag/task/listener/ExecutionListener.java | 33 --- .../dag/task/listener/StageListener.java | 22 -- .../dag/task/model/ExecutionStatus.java | 74 ------ .../dag/task/model/ExecutionType.java | 9 - .../dag/task/model/PipelineExecution.java | 100 -------- .../dag/task/model/StageExecution.java | 126 --------- .../dag/task/model/SyntheticStageOwner.java | 6 - .../dag/task/model/TaskExecution.java | 40 --- .../pipeline/graph/StageGraphBuilderImpl.java | 153 ----------- .../pipeline/model/PipelineExecutionImpl.java | 172 ------------- .../dag/task/pipeline/model/StageContext.java | 89 ------- .../pipeline/model/StateExecutionImpl.java | 240 ------------------ .../pipeline/model/TaskExecutionImpl.java | 72 ------ .../controller/CarpJobConfigController.java | 88 +++++++ .../controller/CarpJobGroupController.java | 87 +++++++ .../controller/CarpJobInstanceController.java | 88 +++++++ .../entity}/ScheduleJobInstance.java | 2 +- .../mapper/ScheduleJobInstanceMapper.java | 4 +- .../service/ScheduleJobConfigService.java | 13 +- .../service/ScheduleJobGroupService.java | 9 +- .../service/ScheduleJobInstanceService.java | 18 +- .../service/ScheduleJobManageService.java | 32 +++ .../convert/ScheduleJobInstanceConvert.java | 4 +- .../dto}/ScheduleJobInstanceDTO.java | 2 +- .../impl/ScheduleJobConfigServiceImpl.java | 102 ++++++++ .../impl/ScheduleJobGroupServiceImpl.java | 97 +++++++ .../impl/ScheduleJobInstanceServiceImpl.java | 102 ++++++++ .../param/ScheduleJobConfigAddParam.java | 47 ++++ .../param/ScheduleJobConfigListParam.java | 34 +++ .../param/ScheduleJobConfigPageParam.java | 41 +++ .../param/ScheduleJobConfigUpdateParam.java | 43 ++++ .../param/ScheduleJobGroupAddParam.java | 38 +++ .../param/ScheduleJobGroupPageParam.java | 33 +++ .../param/ScheduleJobGroupUpdateParam.java | 39 +++ .../param/ScheduleJobInstanceAddParam.java | 49 ++++ .../param/ScheduleJobInstanceListParam.java | 34 +++ .../param/ScheduleJobInstancePageParam.java | 38 +++ .../param/ScheduleJobInstanceUpdateParam.java | 49 ++++ .../mapper/ScheduleJobInstanceMapper.xml | 2 +- .../core/service/impl/SecRoleServiceImpl.java | 2 +- .../carp-module-workflow-api/pom.xml | 39 +++ .../api/graph/WorkflowDefinitionGraph.java | 27 ++ .../api/graph/WorkflowExecutionGraph.java | 27 ++ .../service/WorkflowDefinitionService.java | 36 +++ .../service/dto/WorkflowDefinitionDTO.java | 49 ++++ .../dto/WorkflowDefinitionDagMeta.java | 28 ++ .../param/WorkflowDefinitionListParam.java | 38 +++ .../workflow/api/task/RetryableTask.java | 40 +++ .../workflow/api/task/SkippableTask.java | 24 ++ .../carp/module/workflow/api/task/Task.java | 30 +++ .../module/workflow/api/task/TaskResult.java | 22 ++ carp-modules/carp-module-workflow/pom.xml | 36 +++ carp-modules/pom.xml | 1 + pom.xml | 15 +- 69 files changed, 1988 insertions(+), 1605 deletions(-) create mode 100644 carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/schedule/ScheduleStatus.java create mode 100644 carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowExecuteType.java create mode 100644 carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowInstanceEvent.java create mode 100644 carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowInstanceState.java create mode 100644 carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskInstanceEvent.java create mode 100644 carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskInstanceStage.java create mode 100644 carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskType.java create mode 100644 carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowType.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/RetryableTask.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/SkippableTask.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/Task.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/TaskResult.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/StageDefinitionBuilder.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/StageGraphBuilder.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/TaskNode.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/listener/ExecutionListener.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/listener/StageListener.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/ExecutionStatus.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/ExecutionType.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/PipelineExecution.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/StageExecution.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/SyntheticStageOwner.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/TaskExecution.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/graph/StageGraphBuilderImpl.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/PipelineExecutionImpl.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/StageContext.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/StateExecutionImpl.java delete mode 100644 carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/TaskExecutionImpl.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobConfigController.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobGroupController.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobInstanceController.java rename carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/{service/dto => repository/entity}/ScheduleJobInstance.java (97%) create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobManageService.java rename carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/{repository/entity => service/dto}/ScheduleJobInstanceDTO.java (96%) create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobConfigServiceImpl.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobGroupServiceImpl.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobInstanceServiceImpl.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigAddParam.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigListParam.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigPageParam.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigUpdateParam.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupAddParam.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupPageParam.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupUpdateParam.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceAddParam.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceListParam.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstancePageParam.java create mode 100644 carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceUpdateParam.java create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/pom.xml create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/graph/WorkflowDefinitionGraph.java create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/graph/WorkflowExecutionGraph.java create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/WorkflowDefinitionService.java create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/dto/WorkflowDefinitionDTO.java create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/dto/WorkflowDefinitionDagMeta.java create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/param/WorkflowDefinitionListParam.java create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/RetryableTask.java create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/SkippableTask.java create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/Task.java create mode 100644 carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/TaskResult.java create mode 100644 carp-modules/carp-module-workflow/pom.xml diff --git a/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/schedule/ScheduleStatus.java b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/schedule/ScheduleStatus.java new file mode 100644 index 00000000..94b7d902 --- /dev/null +++ b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/schedule/ScheduleStatus.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.framework.common.dict.schedule; + +import cn.sliew.carp.framework.common.dict.DictInstance; +import cn.sliew.carp.framework.common.dict.common.YesOrNo; +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Arrays; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum ScheduleStatus implements DictInstance { + + STOP(YesOrNo.NO.getValue(), "STOP"), + RUNNING(YesOrNo.YES.getValue(), "RUNNING"), + ; + + @JsonCreator + public static ScheduleStatus of(String value) { + return Arrays.stream(values()) + .filter(instance -> instance.getValue().equals(value)) + .findAny().orElseThrow(() -> new EnumConstantNotPresentException(ScheduleStatus.class, value)); + } + + @EnumValue + private String value; + private String label; + + ScheduleStatus(String value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getLabel() { + return label; + } +} diff --git a/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowExecuteType.java b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowExecuteType.java new file mode 100644 index 00000000..c1b79afc --- /dev/null +++ b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowExecuteType.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.framework.common.dict.workflow; + +import cn.sliew.carp.framework.common.dict.DictInstance; +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Arrays; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum WorkflowExecuteType implements DictInstance { + + SEQUENTIAL("0", "Sequential"), + PARALLEL("1", "Parallel"), + DEPENDENT("2", "Dependent"), + IF("3", "If"), + SWITCH("4", "Switch"), + WHILE("5", "While"), + ; + + @JsonCreator + public static WorkflowExecuteType of(String value) { + return Arrays.stream(values()) + .filter(instance -> instance.getValue().equals(value)) + .findAny().orElseThrow(() -> new EnumConstantNotPresentException(WorkflowExecuteType.class, value)); + } + + @EnumValue + private String value; + private String label; + + WorkflowExecuteType(String value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getLabel() { + return label; + } +} diff --git a/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowInstanceEvent.java b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowInstanceEvent.java new file mode 100644 index 00000000..9fc12cda --- /dev/null +++ b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowInstanceEvent.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.framework.common.dict.workflow; + +import cn.sliew.carp.framework.common.dict.DictInstance; +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Arrays; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum WorkflowInstanceEvent implements DictInstance { + + COMMAND_DEPLOY("0", "COMMAND_DEPLOY"), + COMMAND_SHUTDOWN("1", "COMMAND_SHUTDOWN"), + COMMAND_SUSPEND("2", "COMMAND_SUSPEND"), + COMMAND_RESUME("3", "COMMAND_RESUME"), + PROCESS_TASK_CHANGE("4", "PROCESS_TASK_CHANGE"), + PROCESS_SUCCESS("5", "PROCESS_SUCCESS"), + PROCESS_FAILURE("6", "PROCESS_FAILURE"), + ; + + @JsonCreator + public static WorkflowInstanceEvent of(String value) { + return Arrays.stream(values()) + .filter(instance -> instance.getValue().equals(value)) + .findAny().orElseThrow(() -> new EnumConstantNotPresentException(WorkflowInstanceEvent.class, value)); + } + + @EnumValue + private String value; + private String label; + + WorkflowInstanceEvent(String value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getLabel() { + return label; + } +} diff --git a/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowInstanceState.java b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowInstanceState.java new file mode 100644 index 00000000..7f895ff0 --- /dev/null +++ b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowInstanceState.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.framework.common.dict.workflow; + +import cn.sliew.carp.framework.common.dict.DictInstance; +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Arrays; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum WorkflowInstanceState implements DictInstance { + + PENDING("0", "PENDING"), + RUNNING("1", "RUNNING"), + SUSPEND("2", "SUSPEND"), + SUCCESS("3", "SUCCESS"), + FAILURE("4", "FAILURE"), + TERMINATED("5", "TERMINATED"), + ; + + @JsonCreator + public static WorkflowInstanceState of(String value) { + return Arrays.stream(values()) + .filter(instance -> instance.getValue().equals(value)) + .findAny().orElseThrow(() -> new EnumConstantNotPresentException(WorkflowInstanceState.class, value)); + } + + @EnumValue + private String value; + private String label; + + WorkflowInstanceState(String value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getLabel() { + return label; + } +} diff --git a/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskInstanceEvent.java b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskInstanceEvent.java new file mode 100644 index 00000000..d438ac5e --- /dev/null +++ b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskInstanceEvent.java @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.framework.common.dict.workflow; + +import cn.sliew.carp.framework.common.dict.DictInstance; +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Arrays; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum WorkflowTaskInstanceEvent implements DictInstance { + + COMMAND_DEPLOY("0", "COMMAND_DEPLOY"), + COMMAND_SHUTDOWN("1", "COMMAND_SHUTDOWN"), + COMMAND_SUSPEND("2", "COMMAND_SUSPEND"), + COMMAND_RESUME("3", "COMMAND_RESUME"), + + PROCESS_SUCCESS("4", "PROCESS_SUCCESS"), + PROCESS_FAILURE("5", "PROCESS_FAILURE"), + ; + + @JsonCreator + public static WorkflowTaskInstanceEvent of(String value) { + return Arrays.stream(values()) + .filter(instance -> instance.getValue().equals(value)) + .findAny().orElseThrow(() -> new EnumConstantNotPresentException(WorkflowTaskInstanceEvent.class, value)); + } + + @EnumValue + private String value; + private String label; + + WorkflowTaskInstanceEvent(String value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getLabel() { + return label; + } +} diff --git a/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskInstanceStage.java b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskInstanceStage.java new file mode 100644 index 00000000..dbc0dcc4 --- /dev/null +++ b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskInstanceStage.java @@ -0,0 +1,64 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.framework.common.dict.workflow; + +import cn.sliew.carp.framework.common.dict.DictInstance; +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Arrays; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum WorkflowTaskInstanceStage implements DictInstance { + + PENDING("0", "PENDING"), + RUNNING("1", "RUNNING"), + SUSPEND("3", "SUSPEND"), + SUCCESS("4", "SUCCESS"), + FAILURE("5", "FAILURE"), + TERMINATED("6", "TERMINATED"), + ; + + @JsonCreator + public static WorkflowTaskInstanceStage of(String value) { + return Arrays.stream(values()) + .filter(instance -> instance.getValue().equals(value)) + .findAny().orElseThrow(() -> new EnumConstantNotPresentException(WorkflowTaskInstanceStage.class, value)); + } + + @EnumValue + private String value; + private String label; + + WorkflowTaskInstanceStage(String value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getLabel() { + return label; + } +} diff --git a/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskType.java b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskType.java new file mode 100644 index 00000000..728c686b --- /dev/null +++ b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowTaskType.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.framework.common.dict.workflow; + +import cn.sliew.carp.framework.common.dict.DictInstance; +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Arrays; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum WorkflowTaskType implements DictInstance { + + SUB_WORKFLOW("0", "SUB_WORKFLOW"), + JAVA("1", "JAVA"), + ; + + @JsonCreator + public static WorkflowTaskType of(String value) { + return Arrays.stream(values()) + .filter(instance -> instance.getValue().equals(value)) + .findAny().orElseThrow(() -> new EnumConstantNotPresentException(WorkflowTaskType.class, value)); + } + + @EnumValue + private String value; + private String label; + + WorkflowTaskType(String value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getLabel() { + return label; + } +} diff --git a/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowType.java b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowType.java new file mode 100644 index 00000000..28fc6d9a --- /dev/null +++ b/carp-framework/carp-framework-common/src/main/java/cn/sliew/carp/framework/common/dict/workflow/WorkflowType.java @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.framework.common.dict.workflow; + +import cn.sliew.carp.framework.common.dict.DictInstance; +import com.baomidou.mybatisplus.annotation.EnumValue; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Arrays; + +@JsonFormat(shape = JsonFormat.Shape.OBJECT) +public enum WorkflowType implements DictInstance { + + SYSTEM("0", "系统"), + USER("1", "用户"), + ; + + @JsonCreator + public static WorkflowType of(String value) { + return Arrays.stream(values()) + .filter(instance -> instance.getValue().equals(value)) + .findAny().orElseThrow(() -> new EnumConstantNotPresentException(WorkflowType.class, value)); + } + + @EnumValue + private String value; + private String label; + + WorkflowType(String value, String label) { + this.value = value; + this.label = label; + } + + @Override + public String getValue() { + return value; + } + + @Override + public String getLabel() { + return label; + } +} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/RetryableTask.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/RetryableTask.java deleted file mode 100644 index 4053d39c..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/RetryableTask.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.sliew.carp.framework.dag.task; - -import cn.sliew.carp.framework.dag.task.model.StageExecution; - -import java.time.Duration; - -public interface RetryableTask extends Task{ - - long getBackoffPeriod(); - - long getTimeout(); - - default long getDynamicTimeout(StageExecution stage) { - return getTimeout(); - } - - default long getDynamicBackoffPeriod(Duration taskDuration) { - return getBackoffPeriod(); - } - - default long getDynamicBackoffPeriod(StageExecution stage, Duration taskDuration) { - return getDynamicBackoffPeriod(taskDuration); - } -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/SkippableTask.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/SkippableTask.java deleted file mode 100644 index fac17d64..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/SkippableTask.java +++ /dev/null @@ -1,6 +0,0 @@ -package cn.sliew.carp.framework.dag.task; - -public interface SkippableTask extends Task{ - - -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/Task.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/Task.java deleted file mode 100644 index 8a7e6cd5..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/Task.java +++ /dev/null @@ -1,13 +0,0 @@ -package cn.sliew.carp.framework.dag.task; - -import cn.sliew.carp.framework.dag.task.model.StageExecution; - -public interface Task { - - TaskResult execute(StageExecution state); - - TaskResult onTimeout(StageExecution stage); - - void onCancel(StageExecution stage); - -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/TaskResult.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/TaskResult.java deleted file mode 100644 index 66f69acc..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/TaskResult.java +++ /dev/null @@ -1,4 +0,0 @@ -package cn.sliew.carp.framework.dag.task; - -public class TaskResult { -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/StageDefinitionBuilder.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/StageDefinitionBuilder.java deleted file mode 100644 index 59c52774..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/StageDefinitionBuilder.java +++ /dev/null @@ -1,109 +0,0 @@ -package cn.sliew.carp.framework.dag.task.graph; - -import cn.sliew.carp.framework.dag.task.model.StageExecution; -import jakarta.annotation.Nonnull; - -import static cn.sliew.carp.framework.dag.task.graph.TaskNode.Builder; -import static cn.sliew.carp.framework.dag.task.graph.TaskNode.GraphType.FULL; - -/** - * Provides a low-level API for building stages. - * - *

A stage in its simplest form will consist of a series of Tasks that are executed serially. - * However, a stage can also configure other stages to be run before it, or after it, and or on - * failure only. This can enable you to build stages which compose and abstract the details of other - * stages. - */ -public interface StageDefinitionBuilder { - - default @Nonnull TaskNode.TaskGraph buildTaskGraph(@Nonnull StageExecution stage) { - Builder graphBuilder = Builder(FULL); - taskGraph(stage, graphBuilder); - return graphBuilder.build(); - } - - /** - * Implement this method to define any tasks that should run as part of this stage's workflow. - * - * @param stage The execution runtime of the stage - * @param builder The task graph builder - */ - default void taskGraph(@Nonnull StageExecution stage, @Nonnull Builder builder) { - } - - /** - * Implement this method to define any stages that should run before any tasks in this stage as - * part of a composed workflow. - * - * @param parent The execution runtime of the stage (which is the parent of any stages created - * herein) - * @param graph The stage graph builder - */ - default void beforeStages(@Nonnull StageExecution parent, @Nonnull StageGraphBuilder graph) { - } - - /** - * Implement this method to define any stages that should run after any tasks in this stage as - * part of a composed workflow. - * - * @param parent The execution runtime of the stage (which is the parent of any stages created - * herein) - * @param graph The stage graph builder - */ - default void afterStages(@Nonnull StageExecution parent, @Nonnull StageGraphBuilder graph) { - } - - /** - * Implement this method to define any stages that should run in response to a failure in tasks, - * before or after stages. - * - * @param stage The execution runtime of the stage - * @param graph The stage graph builder - */ - default void onFailureStages(@Nonnull StageExecution stage, @Nonnull StageGraphBuilder graph) { - } - - /** - * Returns the stage type this builder handles. - */ - @SuppressWarnings("unchecked") - default @Nonnull String getType() { - return getType((Class) this.getExtensionClass()); - } - - /** - * Implementations can override this if they need any special cleanup on restart. - * - * @param stage The execution runtime of the stage - */ - default void prepareStageForRestart(@Nonnull StageExecution stage) { - } - - /** - * Get the pipeline configuration-friendly type name for this stage. - * - *

If a stage class is {@code MyFancyStage}, the resulting type would be {@code myFancy}. - * - * @param clazz The stage definition builder class - */ - static String getType(Class clazz) { - String className = clazz.getSimpleName(); - if (className.equals("")) { - throw new IllegalStateException( - "StageDefinitionBuilder.getType() cannot be called on an anonymous type"); - } - return className.substring(0, 1).toLowerCase() - + className - .substring(1) - .replaceFirst("StageDefinitionBuilder$", "") - .replaceFirst("Stage$", ""); - } - - /** - * Return true if the stage can be manually skipped from the API. - */ - default boolean canManuallySkip(StageExecution stage) { - return false; - } - -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/StageGraphBuilder.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/StageGraphBuilder.java deleted file mode 100644 index 31d10a4b..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/StageGraphBuilder.java +++ /dev/null @@ -1,75 +0,0 @@ -package cn.sliew.carp.framework.dag.task.graph; - -import cn.sliew.carp.framework.dag.task.model.StageExecution; -import jakarta.annotation.Nonnull; - -import java.util.function.Consumer; - -/** - * Provides a low-level API for manipulating a stage DAG. - */ -public interface StageGraphBuilder { - - /** - * Adds a new stage to the graph. By default the new stage is not dependent on any others. Use - * {@link #connect(StageExecution, StageExecution)} to make it depend on other stages or have - * other stages depend on it. - * - * @param init builder for setting up the stage. You do not need to configure {@link - * StageExecution#getExecution()}, {@link StageExecution#getParentStageId()}, {@link - * StageExecution#getSyntheticStageOwner()} or {@link StageExecution#getRefId()} as this - * method will do that automatically. - * @return the newly created stage. - */ - @Nonnull - StageExecution add(@Nonnull Consumer init); - - /** - * Adds a new stage to the graph. By default the new stage is not dependent on any others. Use - * {@link #connect(StageExecution, StageExecution)} to make it depend on other stages or have - * other stages depend on it. - */ - void add(@Nonnull StageExecution stage); - - /** - * Adds a new stage to the graph and makes it depend on {@code previous} via its {@link - * StageExecution#getRequisiteStageRefIds()}. - * - * @param previous The stage the new stage will depend on. If {@code previous} does not already - * exist in the graph, this method will add it. - * @param init See {@link #add(Consumer)} - * @return the newly created stage. - */ - @Nonnull - StageExecution connect(@Nonnull StageExecution previous, @Nonnull Consumer init); - - /** - * Makes {@code next} depend on {@code previous} via its {@link - * StageExecution#getRequisiteStageRefIds()}. If either {@code next} or {@code previous} are not - * yet present in the graph this method will add them. - */ - void connect(@Nonnull StageExecution previous, @Nonnull StageExecution next); - - /** - * Adds a new stage to the graph and makes it depend on the last stage that was added if any. - * - *

This is convenient for straightforward stage graphs to avoid having to pass around - * references to stages in order to use {@link #connect(StageExecution, Consumer)}. - * - *

If no stages have been added so far, this is synonymous with calling {@link #add(Consumer)}. - * - * @param init See {@link #add(Consumer)} - * @return the newly created stage. - */ - @Nonnull - StageExecution append(@Nonnull Consumer init); - - void append(@Nonnull StageExecution stage); - - /** - * Builds and returns the stages represented in the graph. This method is not typically useful to - * implementors of {@link StageDefinitionBuilder}, it's used internally and by tests. - */ - @Nonnull - Iterable build(); -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/TaskNode.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/TaskNode.java deleted file mode 100644 index 6176b8a5..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/graph/TaskNode.java +++ /dev/null @@ -1,214 +0,0 @@ -package cn.sliew.carp.framework.dag.task.graph; - -import cn.sliew.carp.framework.dag.task.Task; -import com.google.common.annotations.VisibleForTesting; -import jakarta.annotation.Nonnull; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; -import java.util.function.Consumer; - -/** - * A node in a {@link TaskGraph} which can be either an individual task or a sub-graph. - */ -public interface TaskNode { - - /** - * The type of graph, dictating how a {@link TaskGraph} will be evaluated. - */ - enum GraphType { - /** - * A graph representing an entire stage. - */ - FULL, - /** - * A graph representing a rolling-push style loop in a stage. - */ - LOOP, - /** - * A graph representing the pre-parallel tasks of a bake/deploy style stage - */ - HEAD, - /** - * A graph representing the post-parallel tasks of a bake/deploy style stage - */ - TAIL - } - - /** - * Build a new {@link TaskGraph}. - * - * @param type The type of graph - * @param closure A configuration block - */ - static TaskGraph build(GraphType type, Consumer closure) { - Builder builder = new Builder(type); - closure.accept(builder); - return builder.build(); - } - - /** - * Creates an empty {@link TaskGraph}. - */ - static TaskGraph emptyGraph(GraphType type) { - return build(type, builder -> { - }); - } - - /** - * Creates a {@link TaskGraph} with a single {@link Task}. - * - * @param name The human-friendly name of the task. - * @param implementingClass The {@link Task} class - */ - static TaskGraph singleton(GraphType type, String name, Class implementingClass) { - return build(type, builder -> builder.withTask(name, implementingClass)); - } - - /** - * Creates a {@link TaskDefinition} for the provided {@link Task} class. - * - * @param name The human-friendly name of the task. - */ - static TaskDefinition task(String name, Class implementingClass) { - return new TaskDefinition(name, implementingClass); - } - - static Builder Builder(GraphType type) { - return new Builder(type); - } - - class Builder { - private final GraphType type; - private final List graph = new ArrayList<>(); - - public Builder(GraphType type) { - this.type = type; - } - - /** - * Adds a task to the current graph. - * - * @param name the name of the task. - * @param implementingClass the class that implements the task. - * @return this builder with the new task appended. - */ - public Builder withTask(String name, Class implementingClass) { - graph.add(new TaskDefinition(name, implementingClass)); - return this; - } - - /** - * Adds a task to the current graph. - * - * @param task the task node to add - * @return this builder with the new task appended. - */ - public Builder withTask(TaskNode task) { - graph.add(task); - return this; - } - - /** - * Adds a sub-graph of tasks that may loop if any of them return {@link - * ExecutionStatus#REDIRECT}. The sub-graph will run after any previously added tasks and before - * any subsequently added ones. If the final task in the sub-graph returns {@link - * ExecutionStatus#REDIRECT} the tasks in the sub-graph will be run again. If it returns {@link - * ExecutionStatus#SUCCEEDED} the sub-graph will exit. - * - * @param subGraph a lambda that defines the tasks for the sub-graph by adding them to a @{link - * {@link TaskNode#Builder}. - * @return this builder with the sub-graph appended. - */ - public Builder withLoop(Consumer subGraph) { - Builder subGraphBuilder = new Builder(GraphType.LOOP); - subGraph.accept(subGraphBuilder); - graph.add(subGraphBuilder.build()); - return this; - } - - TaskGraph build() { - return new TaskGraph(type, graph); - } - } - - /** - * A graph or sub-graph of tasks. - */ - class TaskGraph implements TaskNode, Iterable { - - private final GraphType type; - private final List graph; - - @VisibleForTesting - public TaskGraph(GraphType type, List graph) { - this.type = type; - this.graph = graph; - } - - @Override - public Iterator iterator() { - return graph.iterator(); - } - - public ListIterator listIterator() { - return graph.listIterator(); - } - - public boolean isEmpty() { - return graph.isEmpty(); - } - - public GraphType getType() { - return type; - } - } - - /** - * This is an abstraction above TaskDefinition that allows more flexibility for the implementing - * class name. - */ - interface DefinedTask { - - /** - * Returns the name of the task - */ - @Nonnull - String getName(); - - /** - * Returns the name of the class implementing the stage - */ - @Nonnull - String getImplementingClassName(); - } - - /** - * An individual task. - */ - class TaskDefinition implements TaskNode, DefinedTask { - private final String name; - private final Class implementingClass; - - public TaskDefinition(@Nonnull String name, @Nonnull Class implementingClass) { - this.name = name; - this.implementingClass = implementingClass; - } - - @Override - public @Nonnull String getName() { - return name; - } - - public @Nonnull Class getImplementingClass() { - return implementingClass; - } - - @Override - public @Nonnull String getImplementingClassName() { - return getImplementingClass().getCanonicalName(); - } - } -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/listener/ExecutionListener.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/listener/ExecutionListener.java deleted file mode 100644 index c0044366..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/listener/ExecutionListener.java +++ /dev/null @@ -1,33 +0,0 @@ -package cn.sliew.carp.framework.dag.task.listener; - -import cn.sliew.carp.framework.dag.task.model.ExecutionStatus; -import cn.sliew.carp.framework.dag.task.model.PipelineExecution; -import jakarta.annotation.Nonnull; -import org.springframework.core.Ordered; - -public interface ExecutionListener extends Ordered, Comparable { - default void beforeInitialPersist(@Nonnull PipelineExecution execution) { - // do nothing - } - - default void beforeExecution(@Nonnull Persister persister, @Nonnull PipelineExecution execution) { - // do nothing - } - - default void afterExecution( - @Nonnull Persister persister, - @Nonnull PipelineExecution execution, - @Nonnull ExecutionStatus executionStatus, - boolean wasSuccessful) { - // do nothing - } - - default int getOrder() { - return 0; - } - - @Override - default int compareTo(@Nonnull ExecutionListener o) { - return o.getOrder() - getOrder(); - } -} \ No newline at end of file diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/listener/StageListener.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/listener/StageListener.java deleted file mode 100644 index c3530939..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/listener/StageListener.java +++ /dev/null @@ -1,22 +0,0 @@ -package cn.sliew.carp.framework.dag.task.listener; - -import cn.sliew.carp.framework.dag.task.model.StageExecution; -import cn.sliew.carp.framework.dag.task.model.TaskExecution; - -public interface StageListener { - default void beforeTask(StageExecution stage, TaskExecution task) { - // do nothing - } - - default void beforeStage(StageExecution stage) { - // do nothing - } - - default void afterTask(StageExecution stage, TaskExecution task) { - // do nothing - } - - default void afterStage(StageExecution stage) { - // do nothing - } -} \ No newline at end of file diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/ExecutionStatus.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/ExecutionStatus.java deleted file mode 100644 index 43bd301d..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/ExecutionStatus.java +++ /dev/null @@ -1,74 +0,0 @@ -package cn.sliew.carp.framework.dag.task.model; - -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; - -public enum ExecutionStatus { - - /** The task has yet to start. */ - NOT_STARTED(false, false), - - /** The task is still running and the {@code Task} may be re-executed in order to continue. */ - RUNNING(false, false), - - /** The task is still running and the {@code Task} may be resumed in order to continue. */ - PAUSED(false, false), - - /** The task is complete but the pipeline should now be stopped pending a trigger of some kind. */ - SUSPENDED(false, false), - - /** The task executed successfully and the pipeline may now proceed to the next task. */ - SUCCEEDED(true, false), - - /** The task execution failed, but the pipeline may proceed to the next task. */ - FAILED_CONTINUE(true, false), - - /** The task failed and the failure was terminal. The pipeline will not progress any further. */ - TERMINAL(true, true), - - /** The task was canceled. The pipeline will not progress any further. */ - CANCELED(true, true), - - /** - * The step completed but is indicating that a decision path should be followed, not the default - * path. - */ - REDIRECT(false, false), - - /** The task was stopped. The pipeline will not progress any further. */ - STOPPED(true, true), - - /** The task was skipped and the pipeline will proceed to the next task. */ - SKIPPED(true, false), - - /** The task is not started and must be transitioned to NOT_STARTED. */ - BUFFERED(false, false), - ; - - public static final Collection COMPLETED = - Collections.unmodifiableList(Arrays.asList(CANCELED, SUCCEEDED, STOPPED, SKIPPED, TERMINAL, FAILED_CONTINUE));public enum ExecutionType { - /** Executions will show under the "Pipelines" tab of Deck. */ - PIPELINE, - - /** Executions will show under the "Tasks" tab of Deck. */ - ORCHESTRATION; - - @Override - public String toString() { - return name().toLowerCase(); - } - } - private static final Collection SUCCESSFUL = - Collections.unmodifiableList(Arrays.asList(SUCCEEDED, STOPPED, SKIPPED)); - private static final Collection FAILURE = - Collections.unmodifiableList(Arrays.asList(TERMINAL, STOPPED, FAILED_CONTINUE)); - - private final boolean complete; - private final boolean halt; - - ExecutionStatus(boolean complete, boolean halt) { - this.complete = complete; - this.halt = halt; - } -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/ExecutionType.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/ExecutionType.java deleted file mode 100644 index 99b4f638..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/ExecutionType.java +++ /dev/null @@ -1,9 +0,0 @@ -package cn.sliew.carp.framework.dag.task.model; - -public enum ExecutionType { - /** Executions will show under the "Pipelines" tab of Deck. */ - PIPELINE, - - /** Executions will show under the "Tasks" tab of Deck. */ - ORCHESTRATION; -} \ No newline at end of file diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/PipelineExecution.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/PipelineExecution.java deleted file mode 100644 index 34f2f899..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/PipelineExecution.java +++ /dev/null @@ -1,100 +0,0 @@ -package cn.sliew.carp.framework.dag.task.model; - -import jakarta.annotation.Nonnull; -import org.springframework.scheduling.Trigger; - -import java.util.List; -import java.util.Map; - -/** - * The runtime execution state of a Pipeline. - */ -public interface PipelineExecution { - - @Nonnull - ExecutionType getType(); - - String getId(); - - String getApplication(); - - String getName(); - - Long getBuildTime(); - - boolean isCanceled(); - - String getCanceledBy(); - - String getCancellationReason(); - - boolean isLimitConcurrent(); - - int getMaxConcurrentExecutions(); - - boolean isKeepWaitingPipelines(); - - Map getContext(); - - List getStages(); - - Long getStartTime(); - - Long getEndTime(); - - Long getStartTimeExpiry(); - - ExecutionStatus getStatus(); - - PausedDetails getPaused(); - - String getOrigin(); - - Trigger getTrigger(); - - String getDescription(); - - String getPipelineConfigId(); - - PipelineSource getSource(); - - String getSpelEvaluator(); - - void setSpelEvaluator(String spelEvaluator); - - Map getTemplateVariables(); - - String getPartition(); - - // ------- - - StageExecution namedStage(String type); - - StageExecution stageById(String stageId); - - StageExecution stageByRef(String refId); - - /** - * Based on the value of `status`, will also update synthetic fields like `canceled` and `endTime` - */ - void updateStatus(ExecutionStatus status); - - - class PausedDetails { - String pausedBy; - - String resumedBy; - - Long pauseTime; - - Long resumeTime; - } - - class PipelineSource { - private String id; - - private String type; - - private String version; - } -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/StageExecution.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/StageExecution.java deleted file mode 100644 index 55b827c0..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/StageExecution.java +++ /dev/null @@ -1,126 +0,0 @@ -package cn.sliew.carp.framework.dag.task.model; - -import jakarta.annotation.Nonnull; -import jakarta.annotation.Nullable; - -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Predicate; - -/** The runtime execution state of a stage. */ -public interface StageExecution { - - @Nonnull - String getId(); - - @Nullable - String getRefId(); - - @Nonnull - String getType(); - - @Nonnull - String getName(); - - PipelineExecution getExecution(); - - @Nullable - Long getStartTime(); - - @Nullable - Long getEndTime(); - - @Nullable - Long getStartTimeExpiry(); - - @Nonnull - ExecutionStatus getStatus(); - - @Nonnull - Map getContext(); - - @Nonnull - Map getOutputs(); - - @Nonnull - List getTasks(); - - @Nullable - SyntheticStageOwner getSyntheticStageOwner(); - - @Nullable - String getParentStageId(); - - @Nonnull - Collection getRequisiteStageRefIds(); - - @Nullable - Long getScheduledTime(); - - // ------------- InternalStageExecution? - // A lot of these methods are used in a single place somewhere in Orca. I don't know why we - // decided to put a bunch - // of these methods on the class...? - - TaskExecution taskById(@Nonnull String taskId); - - @Nonnull - List ancestors(); - - @Nonnull - List directAncestors(); - - @Nullable - StageExecution findAncestor(@Nonnull Predicate predicate); - - @Nonnull - List allDownstreamStages(); - - @Nonnull - List directChildren(); - - @Nonnull - O mapTo(@Nonnull Class type); - - @Nonnull - O mapTo(@Nullable String pointer, @Nonnull Class type); - - @Nonnull - O decodeBase64(@Nullable String pointer, @Nonnull Class type); - - void resolveStrategyParams(); - - @Nullable - StageExecution getParent(); - - @Nonnull - StageExecution getTopLevelStage(); - - @Nonnull - Optional getParentWithTimeout(); - - @Nonnull - Optional getTimeout(); - - boolean getAllowSiblingStagesToContinueOnFailure(); - - void setAllowSiblingStagesToContinueOnFailure(boolean allowSiblingStagesToContinueOnFailure); - - boolean getContinuePipelineOnFailure(); - - void setContinuePipelineOnFailure(boolean continuePipelineOnFailure); - - boolean isJoin(); - - boolean isManualJudgmentType(); - - boolean withPropagateAuthentication(); - - void appendErrorMessage(String errorMessage); - - @Nonnull - List downstreamStages(); - -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/SyntheticStageOwner.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/SyntheticStageOwner.java deleted file mode 100644 index 7ac660df..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/SyntheticStageOwner.java +++ /dev/null @@ -1,6 +0,0 @@ -package cn.sliew.carp.framework.dag.task.model; - -public enum SyntheticStageOwner { - STAGE_BEFORE, - STAGE_AFTER -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/TaskExecution.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/TaskExecution.java deleted file mode 100644 index 7187c42d..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/model/TaskExecution.java +++ /dev/null @@ -1,40 +0,0 @@ -package cn.sliew.carp.framework.dag.task.model; - -import jakarta.annotation.Nonnull; -import jakarta.annotation.Nullable; - -import java.util.Map; - -/** - * The runtime execution state of a task. - */ -public interface TaskExecution { - - @Nonnull - String getId(); - - @Nonnull - String getImplementingClass(); - - @Nonnull - String getName(); - - @Nullable - Long getStartTime(); - - @Nullable - Long getEndTime(); - - @Nonnull - ExecutionStatus getStatus(); - - boolean isStageStart(); - - boolean isStageEnd(); - - boolean isLoopStart(); - - boolean isLoopEnd(); - - Map getTaskExceptionDetails(); -} \ No newline at end of file diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/graph/StageGraphBuilderImpl.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/graph/StageGraphBuilderImpl.java deleted file mode 100644 index cbe923eb..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/graph/StageGraphBuilderImpl.java +++ /dev/null @@ -1,153 +0,0 @@ -package cn.sliew.carp.framework.dag.task.pipeline.graph; - -import cn.sliew.carp.framework.dag.task.graph.StageGraphBuilder; -import cn.sliew.carp.framework.dag.task.model.StageExecution; -import cn.sliew.carp.framework.dag.task.model.SyntheticStageOwner; -import com.google.common.graph.GraphBuilder; -import com.google.common.graph.MutableGraph; -import jakarta.annotation.Nonnull; -import jakarta.annotation.Nullable; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; -import java.util.function.Consumer; - -import static cn.sliew.carp.framework.dag.task.model.SyntheticStageOwner.STAGE_AFTER; -import static cn.sliew.carp.framework.dag.task.model.SyntheticStageOwner.STAGE_BEFORE; - -public class StageGraphBuilderImpl implements StageGraphBuilder { - - private final StageExecution parent; - private final SyntheticStageOwner type; - private final MutableGraph graph = - GraphBuilder.directed().build(); // TODO: is this actually useful? - private final Optional requiredPrefix; - private @Nullable StageExecution lastAdded = null; - - private StageGraphBuilderImpl( - StageExecution parent, SyntheticStageOwner type, Optional requiredPrefix) { - this.parent = parent; - this.type = type; - this.requiredPrefix = requiredPrefix; - this.requiredPrefix.ifPresent(this::add); - } - - /** - * Create a new builder for the before stages of {@code parent}. - * - * @param parent - */ - public static @Nonnull StageGraphBuilderImpl beforeStages(@Nonnull StageExecution parent) { - return new StageGraphBuilderImpl(parent, STAGE_BEFORE, Optional.empty()); - } - - /** - * Create a new builder for the before stages of {@code parent}. - * - * @param parent - * @param requiredPrefix - */ - public static @Nonnull StageGraphBuilderImpl beforeStages( - @Nonnull StageExecution parent, @Nullable StageExecution requiredPrefix) { - return new StageGraphBuilderImpl(parent, STAGE_BEFORE, Optional.ofNullable(requiredPrefix)); - } - - /** - * Create a new builder for the after stages of {@code parent}. - * - * @param parent - */ - public static @Nonnull StageGraphBuilderImpl afterStages(@Nonnull StageExecution parent) { - return new StageGraphBuilderImpl(parent, STAGE_AFTER, Optional.empty()); - } - - @Override - public @Nonnull StageExecution add(@Nonnull Consumer init) { - StageExecution stage = newStage(init); - add(stage); - return stage; - } - - @Override - public void add(@Nonnull StageExecution stage) { - stage.setExecution(parent.getExecution()); - stage.setParentStageId(parent.getId()); - stage.setSyntheticStageOwner(type); - if (graph.addNode(stage)) { - stage.setRefId(generateRefId()); - } - lastAdded = stage; - } - - @Override - public @Nonnull StageExecution connect( - @Nonnull StageExecution previous, @Nonnull Consumer init) { - StageExecution stage = add(init); - connect(previous, stage); - return stage; - } - - @Override - public void connect(@Nonnull StageExecution previous, @Nonnull StageExecution next) { - add(previous); - add(next); - Set requisiteStageRefIds = new HashSet<>(next.getRequisiteStageRefIds()); - requisiteStageRefIds.add(previous.getRefId()); - next.setRequisiteStageRefIds(requisiteStageRefIds); - graph.putEdge(previous, next); - } - - @Override - public @Nonnull StageExecution append(@Nonnull Consumer init) { - if (lastAdded == null) { - return add(init); - } else { - return connect(lastAdded, init); - } - } - - @Override - public void append(@Nonnull StageExecution stage) { - if (lastAdded == null) { - add(stage); - } else { - connect(lastAdded, stage); - } - } - - @Override - public @Nonnull Iterable build() { - requiredPrefix.ifPresent( - prefix -> - graph - .nodes() - .forEach( - it -> { - if (it != prefix && it.getRequisiteStageRefIds().isEmpty()) { - connect(prefix, it); - } - })); - return graph.nodes(); - } - - private String generateRefId() { - long offset = - parent.getExecution().getStages().stream() - .filter( - i -> - parent.getId().equals(i.getParentStageId()) - && type == i.getSyntheticStageOwner()) - .count(); - - return format( - "%s%s%d", - parent.getRefId(), type == STAGE_BEFORE ? "<" : ">", offset + graph.nodes().size()); - } - - private StageExecution newStage(Consumer init) { - StageExecution stage = new StageExecutionImpl(); - init.accept(stage); - return stage; - } -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/PipelineExecutionImpl.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/PipelineExecutionImpl.java deleted file mode 100644 index 9045ee5d..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/PipelineExecutionImpl.java +++ /dev/null @@ -1,172 +0,0 @@ -package cn.sliew.carp.framework.dag.task.pipeline.model; - -import cn.sliew.carp.framework.dag.task.model.ExecutionStatus; -import cn.sliew.carp.framework.dag.task.model.ExecutionType; -import cn.sliew.carp.framework.dag.task.model.PipelineExecution; -import cn.sliew.carp.framework.dag.task.model.StageExecution; -import jakarta.annotation.Nonnull; -import lombok.extern.slf4j.Slf4j; - -import java.io.Serializable; -import java.util.List; -import java.util.Map; - -@Slf4j -public class PipelineExecutionImpl implements PipelineExecution, Serializable { - - @Nonnull - @Override - public ExecutionType getType() { - return null; - } - - @Override - public String getId() { - return ""; - } - - @Override - public String getApplication() { - return ""; - } - - @Override - public String getName() { - return ""; - } - - @Override - public Long getBuildTime() { - return 0; - } - - @Override - public boolean isCanceled() { - return false; - } - - @Override - public String getCanceledBy() { - return ""; - } - - @Override - public String getCancellationReason() { - return ""; - } - - @Override - public boolean isLimitConcurrent() { - return false; - } - - @Override - public int getMaxConcurrentExecutions() { - return 0; - } - - @Override - public boolean isKeepWaitingPipelines() { - return false; - } - - @Override - public Map getContext() { - return Map.of(); - } - - @Override - public List getStages() { - return List.of(); - } - - @Override - public Long getStartTime() { - return 0; - } - - @Override - public Long getEndTime() { - return 0; - } - - @Override - public Long getStartTimeExpiry() { - return 0; - } - - @Override - public ExecutionStatus getStatus() { - return null; - } - - @Override - public PausedDetails getPaused() { - return null; - } - - @Override - public String getOrigin() { - return ""; - } - - @Override - public Trigger getTrigger() { - return null; - } - - @Override - public String getDescription() { - return ""; - } - - @Override - public String getPipelineConfigId() { - return ""; - } - - @Override - public PipelineSource getSource() { - return null; - } - - @Override - public String getSpelEvaluator() { - return ""; - } - - @Override - public void setSpelEvaluator(String spelEvaluator) { - - } - - @Override - public Map getTemplateVariables() { - return Map.of(); - } - - @Override - public String getPartition() { - return ""; - } - - @Override - public StageExecution namedStage(String type) { - return null; - } - - @Override - public StageExecution stageById(String stageId) { - return null; - } - - @Override - public StageExecution stageByRef(String refId) { - return null; - } - - @Override - public void updateStatus(ExecutionStatus status) { - - } -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/StageContext.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/StageContext.java deleted file mode 100644 index 20dc157d..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/StageContext.java +++ /dev/null @@ -1,89 +0,0 @@ -package cn.sliew.carp.framework.dag.task.pipeline.model; - -import cn.sliew.carp.framework.dag.task.model.StageExecution; -import com.google.common.collect.ForwardingMap; -import jakarta.annotation.Nullable; -import org.springframework.scheduling.Trigger; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static java.util.stream.Collectors.toList; - -public class StageContext extends ForwardingMap implements Map { - - private final StageExecution stage; - private final Map delegate; - - public StageContext(StageExecution stage) { - this(stage, new HashMap<>()); - } - - public StageContext(StageContext stageContext) { - this(stageContext.stage, new HashMap<>(stageContext.delegate)); - } - - public StageContext(StageExecution stage, Map delegate) { - this.stage = stage; - this.delegate = delegate; - } - - @Override - protected Map delegate() { - return delegate; - } - - private Trigger getTrigger() { - return stage.getExecution().getTrigger(); - } - - @Override - public Object get(@Nullable Object key) { - if (delegate().containsKey(key)) { - return super.get(key); - } else { - return stage.ancestors().stream() - .filter(it -> it.getOutputs().containsKey(key)) - .findFirst() - .map(it -> it.getOutputs().get(key)) - .orElse(null); - } - } - - /** - * Get a value from the current context ONLY - never looking at the ancestors' outputs - * - * @param key The key to look - * @param defaultValue default value to return if key is not present - * @return value or null if not present - */ - public Object getCurrentOnly(@Nullable Object key, Object defaultValue) { - return super.getOrDefault(key, defaultValue); - } - /* - * Gets all objects matching 'key', sorted by proximity to the current stage. - * If the key exists in the current context, it will be the first element returned - */ - @SuppressWarnings("unchecked") - public List getAll(Object key) { - List result = - (List) - stage.ancestors().stream() - .filter(it -> it.getOutputs().containsKey(key)) - .map(it -> it.getOutputs().get(key)) - .collect(toList()); - - if (delegate.containsKey(key)) { - result.add(0, (E) delegate.get(key)); - } - - if (key.equals("artifacts")) { - result.add((E) getTrigger().getArtifacts()); - } else if (key.equals("resolvedExpectedArtifacts")) { - result.add((E) getTrigger().getResolvedExpectedArtifacts()); - } - - return result; - } -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/StateExecutionImpl.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/StateExecutionImpl.java deleted file mode 100644 index 380a2a8c..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/StateExecutionImpl.java +++ /dev/null @@ -1,240 +0,0 @@ -package cn.sliew.carp.framework.dag.task.pipeline.model; - -import cn.sliew.carp.framework.dag.task.model.*; -import jakarta.annotation.Nonnull; -import jakarta.annotation.Nullable; -import lombok.extern.slf4j.Slf4j; - -import java.io.Serializable; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Optional; -import java.util.function.Predicate; - -@Slf4j -public class StateExecutionImpl implements StageExecution, Serializable { - - @Nonnull - @Override - public String getId() { - return ""; - } - - @Nullable - @Override - public String getRefId() { - return ""; - } - - @Nonnull - @Override - public String getType() { - return ""; - } - - @Nonnull - @Override - public String getName() { - return ""; - } - - @Override - public PipelineExecution getExecution() { - return null; - } - - @Nullable - @Override - public Long getStartTime() { - return 0; - } - - @Nullable - @Override - public Long getEndTime() { - return 0; - } - - @Nullable - @Override - public Long getStartTimeExpiry() { - return 0; - } - - @Nonnull - @Override - public ExecutionStatus getStatus() { - return null; - } - - @Nonnull - @Override - public Map getContext() { - return Map.of(); - } - - @Nonnull - @Override - public Map getOutputs() { - return Map.of(); - } - - @Nonnull - @Override - public List getTasks() { - return List.of(); - } - - @Nullable - @Override - public SyntheticStageOwner getSyntheticStageOwner() { - return null; - } - - @Nullable - @Override - public String getParentStageId() { - return ""; - } - - @Nonnull - @Override - public Collection getRequisiteStageRefIds() { - return List.of(); - } - - @Nullable - @Override - public Long getScheduledTime() { - return 0; - } - - @Override - public TaskExecution taskById(@Nonnull String taskId) { - return null; - } - - @Nonnull - @Override - public List ancestors() { - return List.of(); - } - - @Nonnull - @Override - public List directAncestors() { - return List.of(); - } - - @Nullable - @Override - public StageExecution findAncestor(@Nonnull Predicate predicate) { - return null; - } - - @Nonnull - @Override - public List allDownstreamStages() { - return List.of(); - } - - @Nonnull - @Override - public List directChildren() { - return List.of(); - } - - @Nonnull - @Override - public O mapTo(@Nonnull Class type) { - return null; - } - - @Nonnull - @Override - public O mapTo(@Nullable String pointer, @Nonnull Class type) { - return null; - } - - @Nonnull - @Override - public O decodeBase64(@Nullable String pointer, @Nonnull Class type) { - return null; - } - - @Override - public void resolveStrategyParams() { - - } - - @Nullable - @Override - public StageExecution getParent() { - return null; - } - - @Nonnull - @Override - public StageExecution getTopLevelStage() { - return null; - } - - @Nonnull - @Override - public Optional getParentWithTimeout() { - return Optional.empty(); - } - - @Nonnull - @Override - public Optional getTimeout() { - return Optional.empty(); - } - - @Override - public boolean getAllowSiblingStagesToContinueOnFailure() { - return false; - } - - @Override - public void setAllowSiblingStagesToContinueOnFailure(boolean allowSiblingStagesToContinueOnFailure) { - - } - - @Override - public boolean getContinuePipelineOnFailure() { - return false; - } - - @Override - public void setContinuePipelineOnFailure(boolean continuePipelineOnFailure) { - - } - - @Override - public boolean isJoin() { - return false; - } - - @Override - public boolean isManualJudgmentType() { - return false; - } - - @Override - public boolean withPropagateAuthentication() { - return false; - } - - @Override - public void appendErrorMessage(String errorMessage) { - - } - - @Nonnull - @Override - public List downstreamStages() { - return List.of(); - } -} diff --git a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/TaskExecutionImpl.java b/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/TaskExecutionImpl.java deleted file mode 100644 index 6bc52020..00000000 --- a/carp-framework/carp-framework-dag/src/main/java/cn/sliew/carp/framework/dag/task/pipeline/model/TaskExecutionImpl.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.sliew.carp.framework.dag.task.pipeline.model; - -import cn.sliew.carp.framework.dag.task.model.ExecutionStatus; -import cn.sliew.carp.framework.dag.task.model.TaskExecution; -import jakarta.annotation.Nonnull; -import jakarta.annotation.Nullable; - -import java.util.Map; - -public class TaskExecutionImpl implements TaskExecution { - - @Nonnull - @Override - public String getId() { - return ""; - } - - @Nonnull - @Override - public String getImplementingClass() { - return ""; - } - - @Nonnull - @Override - public String getName() { - return ""; - } - - @Nullable - @Override - public Long getStartTime() { - return 0; - } - - @Nullable - @Override - public Long getEndTime() { - return 0; - } - - @Nonnull - @Override - public ExecutionStatus getStatus() { - return null; - } - - @Override - public boolean isStageStart() { - return false; - } - - @Override - public boolean isStageEnd() { - return false; - } - - @Override - public boolean isLoopStart() { - return false; - } - - @Override - public boolean isLoopEnd() { - return false; - } - - @Override - public Map getTaskExceptionDetails() { - return Map.of(); - } -} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobConfigController.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobConfigController.java new file mode 100644 index 00000000..202a0632 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobConfigController.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.controller; + +import cn.sliew.carp.framework.common.model.PageResult; +import cn.sliew.carp.framework.web.response.ApiResponseWrapper; +import cn.sliew.module.scheduler.service.ScheduleJobConfigService; +import cn.sliew.module.scheduler.service.dto.ScheduleJobConfigDTO; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigAddParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigListParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigPageParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigUpdateParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@ApiResponseWrapper +@RequestMapping("/api/carp/schedule/config") +@Tag(name = "调度管理-配置管理") +public class CarpJobConfigController { + + @Autowired + private ScheduleJobConfigService scheduleJobConfigService; + + @GetMapping("page") + @Operation(summary = "分页查询", description = "分页查询") + public PageResult list(@Valid ScheduleJobConfigPageParam param) { + return scheduleJobConfigService.list(param); + } + + @GetMapping + @Operation(summary = "查询所有", description = "查询所有") + public List listAll(@Valid ScheduleJobConfigListParam param) { + return scheduleJobConfigService.listAll(param); + } + + @GetMapping("{id}") + @Operation(summary = "查询详情", description = "查询详情") + public ScheduleJobConfigDTO get(@PathVariable("id") Long id) { + return scheduleJobConfigService.get(id); + } + + @PutMapping + @Operation(summary = "新增", description = "新增") + public Boolean add(@Valid @RequestBody ScheduleJobConfigAddParam param) { + return scheduleJobConfigService.add(param); + } + + @PostMapping + @Operation(summary = "更新", description = "更新") + public Boolean update(@Valid @RequestBody ScheduleJobConfigUpdateParam param) { + return scheduleJobConfigService.update(param); + } + + @DeleteMapping("{id}") + @Operation(summary = "删除", description = "删除") + public Boolean delete(@PathVariable("id") Long id) { + return scheduleJobConfigService.delete(id); + } + + @DeleteMapping("batch") + @Operation(summary = "批量删除", description = "批量删除") + public Boolean deleteBatch(@RequestBody List ids) { + return scheduleJobConfigService.deleteBatch(ids); + } + +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobGroupController.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobGroupController.java new file mode 100644 index 00000000..0b12d234 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobGroupController.java @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.controller; + +import cn.sliew.carp.framework.common.model.PageResult; +import cn.sliew.carp.framework.web.response.ApiResponseWrapper; +import cn.sliew.module.scheduler.service.ScheduleJobGroupService; +import cn.sliew.module.scheduler.service.dto.ScheduleJobGroupDTO; +import cn.sliew.module.scheduler.service.param.ScheduleJobGroupAddParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobGroupPageParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobGroupUpdateParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@ApiResponseWrapper +@RequestMapping("/api/carp/schedule/group") +@Tag(name = "调度管理-分组管理") +public class CarpJobGroupController { + + @Autowired + private ScheduleJobGroupService scheduleJobGroupService; + + @GetMapping("page") + @Operation(summary = "分页查询", description = "分页查询") + public PageResult list(@Valid ScheduleJobGroupPageParam param) { + return scheduleJobGroupService.list(param); + } + + @GetMapping + @Operation(summary = "查询所有", description = "查询所有") + public List listAll() { + return scheduleJobGroupService.listAll(); + } + + @GetMapping("{id}") + @Operation(summary = "查询详情", description = "查询详情") + public ScheduleJobGroupDTO get(@PathVariable("id") Long id) { + return scheduleJobGroupService.get(id); + } + + @PutMapping + @Operation(summary = "新增", description = "新增") + public Boolean add(@Valid @RequestBody ScheduleJobGroupAddParam param) { + return scheduleJobGroupService.add(param); + } + + @PostMapping + @Operation(summary = "更新", description = "更新") + public Boolean update(@Valid @RequestBody ScheduleJobGroupUpdateParam param) { + return scheduleJobGroupService.update(param); + } + + @DeleteMapping("{id}") + @Operation(summary = "删除", description = "删除") + public Boolean delete(@PathVariable("id") Long id) { + return scheduleJobGroupService.delete(id); + } + + @DeleteMapping("batch") + @Operation(summary = "批量删除", description = "批量删除") + public Boolean deleteBatch(@RequestBody List ids) { + return scheduleJobGroupService.deleteBatch(ids); + } + +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobInstanceController.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobInstanceController.java new file mode 100644 index 00000000..8ffd9923 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/controller/CarpJobInstanceController.java @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.controller; + +import cn.sliew.carp.framework.common.model.PageResult; +import cn.sliew.carp.framework.web.response.ApiResponseWrapper; +import cn.sliew.module.scheduler.service.dto.ScheduleJobInstanceDTO; +import cn.sliew.module.scheduler.service.ScheduleJobInstanceService; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstanceAddParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstanceListParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstancePageParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstanceUpdateParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.validation.Valid; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@RestController +@ApiResponseWrapper +@RequestMapping("/api/carp/schedule/instance") +@Tag(name = "调度管理-实例管理") +public class CarpJobInstanceController { + + @Autowired(required = false) + private ScheduleJobInstanceService scheduleJobInstanceService; + + @GetMapping("page") + @Operation(summary = "分页查询", description = "分页查询") + public PageResult list(@Valid ScheduleJobInstancePageParam param) { + return scheduleJobInstanceService.list(param); + } + + @GetMapping + @Operation(summary = "查询所有", description = "查询所有") + public List listAll(@Valid ScheduleJobInstanceListParam param) { + return scheduleJobInstanceService.listAll(param); + } + + @GetMapping("{id}") + @Operation(summary = "查询详情", description = "查询详情") + public ScheduleJobInstanceDTO get(@PathVariable("id") Long id) { + return scheduleJobInstanceService.get(id); + } + + @PutMapping + @Operation(summary = "新增", description = "新增") + public Boolean add(@Valid @RequestBody ScheduleJobInstanceAddParam param) { + return scheduleJobInstanceService.add(param); + } + + @PostMapping + @Operation(summary = "更新", description = "更新") + public Boolean update(@Valid @RequestBody ScheduleJobInstanceUpdateParam param) { + return scheduleJobInstanceService.update(param); + } + + @DeleteMapping("{id}") + @Operation(summary = "删除", description = "删除") + public Boolean delete(@PathVariable("id") Long id) { + return scheduleJobInstanceService.delete(id); + } + + @DeleteMapping("batch") + @Operation(summary = "批量删除", description = "批量删除") + public Boolean deleteBatch(@RequestBody List ids) { + return scheduleJobInstanceService.deleteBatch(ids); + } + +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/dto/ScheduleJobInstance.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/repository/entity/ScheduleJobInstance.java similarity index 97% rename from carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/dto/ScheduleJobInstance.java rename to carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/repository/entity/ScheduleJobInstance.java index 828f0eb6..90e225d0 100644 --- a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/dto/ScheduleJobInstance.java +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/repository/entity/ScheduleJobInstance.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package cn.sliew.module.scheduler.service.dto; +package cn.sliew.module.scheduler.repository.entity; import cn.sliew.carp.framework.mybatis.entity.BaseAuditDO; import com.baomidou.mybatisplus.annotation.TableField; diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/repository/mapper/ScheduleJobInstanceMapper.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/repository/mapper/ScheduleJobInstanceMapper.java index 8e2d38d7..b92563ae 100644 --- a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/repository/mapper/ScheduleJobInstanceMapper.java +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/repository/mapper/ScheduleJobInstanceMapper.java @@ -18,11 +18,11 @@ package cn.sliew.module.scheduler.repository.mapper; -import cn.sliew.module.scheduler.repository.entity.ScheduleJobInstanceDTO; +import cn.sliew.module.scheduler.repository.entity.ScheduleJobInstance; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.springframework.stereotype.Repository; @Repository -public interface ScheduleJobInstanceMapper extends BaseMapper { +public interface ScheduleJobInstanceMapper extends BaseMapper { } diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobConfigService.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobConfigService.java index e90b626b..cc6be251 100644 --- a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobConfigService.java +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobConfigService.java @@ -21,19 +21,26 @@ import cn.sliew.carp.framework.common.model.PageResult; import cn.sliew.module.scheduler.repository.entity.ScheduleJobConfig; import cn.sliew.module.scheduler.service.dto.ScheduleJobConfigDTO; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigAddParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigListParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigPageParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigUpdateParam; import com.baomidou.mybatisplus.extension.service.IService; import java.util.Collection; +import java.util.List; public interface ScheduleJobConfigService extends IService { - PageResult list(ScheduleJobConfigDTO param); + PageResult list(ScheduleJobConfigPageParam param); + + List listAll(ScheduleJobConfigListParam param); ScheduleJobConfigDTO get(Long id); - boolean add(ScheduleJobConfigDTO param); + boolean add(ScheduleJobConfigAddParam param); - boolean update(ScheduleJobConfigDTO param); + boolean update(ScheduleJobConfigUpdateParam param); boolean delete(Long id); diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobGroupService.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobGroupService.java index c5546c07..18e408e0 100644 --- a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobGroupService.java +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobGroupService.java @@ -21,6 +21,9 @@ import cn.sliew.carp.framework.common.model.PageResult; import cn.sliew.module.scheduler.repository.entity.ScheduleJobGroup; import cn.sliew.module.scheduler.service.dto.ScheduleJobGroupDTO; +import cn.sliew.module.scheduler.service.param.ScheduleJobGroupAddParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobGroupPageParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobGroupUpdateParam; import com.baomidou.mybatisplus.extension.service.IService; import java.util.Collection; @@ -28,15 +31,15 @@ public interface ScheduleJobGroupService extends IService { - PageResult list(ScheduleJobGroupDTO param); + PageResult list(ScheduleJobGroupPageParam param); List listAll(); ScheduleJobGroupDTO get(Long id); - boolean add(ScheduleJobGroupDTO param); + boolean add(ScheduleJobGroupAddParam param); - boolean update(ScheduleJobGroupDTO param); + boolean update(ScheduleJobGroupUpdateParam param); boolean delete(Long id); diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobInstanceService.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobInstanceService.java index 6c15c366..1dfa1cd0 100644 --- a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobInstanceService.java +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobInstanceService.java @@ -19,20 +19,28 @@ package cn.sliew.module.scheduler.service; import cn.sliew.carp.framework.common.model.PageResult; -import cn.sliew.module.scheduler.repository.entity.ScheduleJobInstanceDTO; +import cn.sliew.module.scheduler.service.dto.ScheduleJobInstanceDTO; +import cn.sliew.module.scheduler.repository.entity.ScheduleJobInstance; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstanceAddParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstanceListParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstancePageParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstanceUpdateParam; import com.baomidou.mybatisplus.extension.service.IService; import java.util.Collection; +import java.util.List; -public interface ScheduleJobInstanceService extends IService { +public interface ScheduleJobInstanceService extends IService { - PageResult list(ScheduleJobInstanceDTO param); + PageResult list(ScheduleJobInstancePageParam param); + + List listAll(ScheduleJobInstanceListParam param); ScheduleJobInstanceDTO get(Long id); - boolean add(ScheduleJobInstanceDTO param); + boolean add(ScheduleJobInstanceAddParam param); - boolean update(ScheduleJobInstanceDTO param); + boolean update(ScheduleJobInstanceUpdateParam param); boolean delete(Long id); diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobManageService.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobManageService.java new file mode 100644 index 00000000..754db746 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/ScheduleJobManageService.java @@ -0,0 +1,32 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service; + +public interface ScheduleJobManageService { + + void execute(String jobInstanceId); + + void schedule(String jobInstanceId); + + void unschedule(String jobInstanceId); + + void suspend(String jobInstanceId); + + void resume(String jobInstanceId); +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/convert/ScheduleJobInstanceConvert.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/convert/ScheduleJobInstanceConvert.java index 088c44cc..cb394bb1 100644 --- a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/convert/ScheduleJobInstanceConvert.java +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/convert/ScheduleJobInstanceConvert.java @@ -19,8 +19,8 @@ package cn.sliew.module.scheduler.service.convert; import cn.sliew.carp.framework.common.convert.BaseConvert; -import cn.sliew.module.scheduler.repository.entity.ScheduleJobInstanceDTO; -import cn.sliew.module.scheduler.service.dto.ScheduleJobInstance; +import cn.sliew.module.scheduler.service.dto.ScheduleJobInstanceDTO; +import cn.sliew.module.scheduler.repository.entity.ScheduleJobInstance; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/repository/entity/ScheduleJobInstanceDTO.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/dto/ScheduleJobInstanceDTO.java similarity index 96% rename from carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/repository/entity/ScheduleJobInstanceDTO.java rename to carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/dto/ScheduleJobInstanceDTO.java index 5509dd49..b0062938 100644 --- a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/repository/entity/ScheduleJobInstanceDTO.java +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/dto/ScheduleJobInstanceDTO.java @@ -16,7 +16,7 @@ * limitations under the License. */ -package cn.sliew.module.scheduler.repository.entity; +package cn.sliew.module.scheduler.service.dto; import cn.sliew.carp.framework.common.model.BaseDTO; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobConfigServiceImpl.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobConfigServiceImpl.java new file mode 100644 index 00000000..b3ec1ba2 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobConfigServiceImpl.java @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.impl; + +import cn.sliew.carp.framework.common.model.PageResult; +import cn.sliew.carp.framework.mybatis.DataSourceConstants; +import cn.sliew.module.scheduler.repository.entity.ScheduleJobConfig; +import cn.sliew.module.scheduler.repository.mapper.ScheduleJobConfigMapper; +import cn.sliew.module.scheduler.service.ScheduleJobConfigService; +import cn.sliew.module.scheduler.service.convert.ScheduleJobConfigConvert; +import cn.sliew.module.scheduler.service.dto.ScheduleJobConfigDTO; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigAddParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigListParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigPageParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobConfigUpdateParam; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.util.Collection; +import java.util.List; + +@Service +public class ScheduleJobConfigServiceImpl extends ServiceImpl implements ScheduleJobConfigService { + + @Override + public PageResult list(ScheduleJobConfigPageParam param) { + Page page = new Page<>(param.getCurrent(), param.getPageSize()); + LambdaQueryWrapper queryChainWrapper = Wrappers.lambdaQuery(ScheduleJobConfig.class) + .eq(ScheduleJobConfig::getJobGroupId, param.getJobGroupId()) + .eq(StringUtils.hasText(param.getType()), ScheduleJobConfig::getType, param.getType()) + .like(StringUtils.hasText(param.getName()), ScheduleJobConfig::getName, param.getName()) + .like(StringUtils.hasText(param.getHandler()), ScheduleJobConfig::getHandler, param.getHandler()) + .orderByAsc(ScheduleJobConfig::getId); + Page scheduleJobConfigPage = page(page, queryChainWrapper); + PageResult pageResult = new PageResult<>(scheduleJobConfigPage.getCurrent(), scheduleJobConfigPage.getSize(), scheduleJobConfigPage.getTotal()); + pageResult.setRecords(ScheduleJobConfigConvert.INSTANCE.toDto(scheduleJobConfigPage.getRecords())); + return pageResult; + } + + @Override + public List listAll(ScheduleJobConfigListParam param) { + LambdaQueryWrapper queryChainWrapper = Wrappers.lambdaQuery(ScheduleJobConfig.class) + .eq(ScheduleJobConfig::getJobGroupId, param.getJobGroupId()) + .eq(StringUtils.hasText(param.getType()), ScheduleJobConfig::getType, param.getType()) + .orderByAsc(ScheduleJobConfig::getId); + List list = list(queryChainWrapper); + return ScheduleJobConfigConvert.INSTANCE.toDto(list); + } + + @Override + public ScheduleJobConfigDTO get(Long id) { + ScheduleJobConfig entity = getOptById(id).orElseThrow(() -> new IllegalArgumentException("schedule job config not exists for id: " + id)); + return ScheduleJobConfigConvert.INSTANCE.toDto(entity); + } + + @Override + public boolean add(ScheduleJobConfigAddParam param) { + ScheduleJobConfig entity = new ScheduleJobConfig(); + BeanUtils.copyProperties(param, entity); + return save(entity); + } + + @Override + public boolean update(ScheduleJobConfigUpdateParam param) { + ScheduleJobConfig entity = new ScheduleJobConfig(); + BeanUtils.copyProperties(param, entity); + return updateById(entity); + } + + @Override + public boolean delete(Long id) { + return removeById(id); + } + + @Transactional(rollbackFor = {Exception.class}, transactionManager = DataSourceConstants.TRANSACTION_MANAGER_FACTORY) + @Override + public boolean deleteBatch(Collection ids) { + return removeBatchByIds(ids); + } +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobGroupServiceImpl.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobGroupServiceImpl.java new file mode 100644 index 00000000..f7f0c207 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobGroupServiceImpl.java @@ -0,0 +1,97 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.impl; + +import cn.sliew.carp.framework.common.model.PageResult; +import cn.sliew.carp.framework.mybatis.DataSourceConstants; +import cn.sliew.module.scheduler.repository.entity.ScheduleJobGroup; +import cn.sliew.module.scheduler.repository.mapper.ScheduleJobGroupMapper; +import cn.sliew.module.scheduler.service.ScheduleJobGroupService; +import cn.sliew.module.scheduler.service.convert.ScheduleJobGroupConvert; +import cn.sliew.module.scheduler.service.dto.ScheduleJobGroupDTO; +import cn.sliew.module.scheduler.service.param.ScheduleJobGroupAddParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobGroupPageParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobGroupUpdateParam; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.util.Collection; +import java.util.List; + +@Service +public class ScheduleJobGroupServiceImpl extends ServiceImpl implements ScheduleJobGroupService { + + @Override + public PageResult list(ScheduleJobGroupPageParam param) { + Page page = new Page<>(param.getCurrent(), param.getPageSize()); + LambdaQueryWrapper queryChainWrapper = Wrappers.lambdaQuery(ScheduleJobGroup.class) + .like(StringUtils.hasText(param.getNamespace()), ScheduleJobGroup::getNamespace, param.getNamespace()) + .like(StringUtils.hasText(param.getName()), ScheduleJobGroup::getName, param.getName()) + .orderByAsc(ScheduleJobGroup::getId); + Page scheduleJobGroupPage = page(page, queryChainWrapper); + PageResult pageResult = new PageResult<>(scheduleJobGroupPage.getCurrent(), scheduleJobGroupPage.getSize(), scheduleJobGroupPage.getTotal()); + pageResult.setRecords(ScheduleJobGroupConvert.INSTANCE.toDto(scheduleJobGroupPage.getRecords())); + return pageResult; + } + + @Override + public List listAll() { + LambdaQueryWrapper queryChainWrapper = Wrappers.lambdaQuery(ScheduleJobGroup.class) + .orderByAsc(ScheduleJobGroup::getId); + List list = list(queryChainWrapper); + return ScheduleJobGroupConvert.INSTANCE.toDto(list); + } + + @Override + public ScheduleJobGroupDTO get(Long id) { + ScheduleJobGroup entity = getOptById(id).orElseThrow(() -> new IllegalArgumentException("schedule job group not exists for id: " + id)); + return ScheduleJobGroupConvert.INSTANCE.toDto(entity); + } + + @Override + public boolean add(ScheduleJobGroupAddParam param) { + ScheduleJobGroup entity = new ScheduleJobGroup(); + BeanUtils.copyProperties(param, entity); + return save(entity); + } + + @Override + public boolean update(ScheduleJobGroupUpdateParam param) { + ScheduleJobGroup entity = new ScheduleJobGroup(); + BeanUtils.copyProperties(param, entity); + return updateById(entity); + } + + @Override + public boolean delete(Long id) { + return removeById(id); + } + + @Transactional(rollbackFor = {Exception.class}, transactionManager = DataSourceConstants.TRANSACTION_MANAGER_FACTORY) + @Override + public boolean deleteBatch(Collection ids) { + return removeBatchByIds(ids); + } +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobInstanceServiceImpl.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobInstanceServiceImpl.java new file mode 100644 index 00000000..5699ee87 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/impl/ScheduleJobInstanceServiceImpl.java @@ -0,0 +1,102 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.impl; + +import cn.sliew.carp.framework.common.model.PageResult; +import cn.sliew.carp.framework.mybatis.DataSourceConstants; +import cn.sliew.module.scheduler.repository.entity.ScheduleJobInstance; +import cn.sliew.module.scheduler.repository.mapper.ScheduleJobInstanceMapper; +import cn.sliew.module.scheduler.service.ScheduleJobInstanceService; +import cn.sliew.module.scheduler.service.convert.ScheduleJobInstanceConvert; +import cn.sliew.module.scheduler.service.dto.ScheduleJobInstanceDTO; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstanceAddParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstanceListParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstancePageParam; +import cn.sliew.module.scheduler.service.param.ScheduleJobInstanceUpdateParam; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.StringUtils; + +import java.util.Collection; +import java.util.List; + +@Service +public class ScheduleJobInstanceServiceImpl extends ServiceImpl implements ScheduleJobInstanceService { + + @Override + public PageResult list(ScheduleJobInstancePageParam param) { + Page page = new Page<>(param.getCurrent(), param.getPageSize()); + LambdaQueryWrapper queryChainWrapper = Wrappers.lambdaQuery(ScheduleJobInstance.class) + .eq(ScheduleJobInstance::getJobConfigId, param.getJobConfigId()) + .like(StringUtils.hasText(param.getName()), ScheduleJobInstance::getName, param.getName()) + .eq(StringUtils.hasText(param.getStatus()), ScheduleJobInstance::getStatus, param.getStatus()) + .orderByAsc(ScheduleJobInstance::getId); + Page scheduleJobInstancePage = page(page, queryChainWrapper); + PageResult pageResult = new PageResult<>(scheduleJobInstancePage.getCurrent(), scheduleJobInstancePage.getSize(), scheduleJobInstancePage.getTotal()); + pageResult.setRecords(ScheduleJobInstanceConvert.INSTANCE.toDto(scheduleJobInstancePage.getRecords())); + return pageResult; + } + + @Override + public List listAll(ScheduleJobInstanceListParam param) { + LambdaQueryWrapper queryChainWrapper = Wrappers.lambdaQuery(ScheduleJobInstance.class) + .eq(ScheduleJobInstance::getJobConfigId, param.getJobConfigId()) + .eq(StringUtils.hasText(param.getStatus()), ScheduleJobInstance::getStatus, param.getStatus()) + .orderByAsc(ScheduleJobInstance::getId); + List list = list(queryChainWrapper); + return ScheduleJobInstanceConvert.INSTANCE.toDto(list); + } + + @Override + public ScheduleJobInstanceDTO get(Long id) { + ScheduleJobInstance entity = getOptById(id).orElseThrow(() -> new IllegalArgumentException("schedule job instance not exists for id: " + id)); + return ScheduleJobInstanceConvert.INSTANCE.toDto(entity); + } + + @Override + public boolean add(ScheduleJobInstanceAddParam param) { + ScheduleJobInstance entity = new ScheduleJobInstance(); + BeanUtils.copyProperties(param, entity); + return save(entity); + } + + @Override + public boolean update(ScheduleJobInstanceUpdateParam param) { + ScheduleJobInstance entity = new ScheduleJobInstance(); + BeanUtils.copyProperties(param, entity); + return updateById(entity); + } + + @Override + public boolean delete(Long id) { + return removeById(id); + } + + @Transactional(rollbackFor = {Exception.class}, transactionManager = DataSourceConstants.TRANSACTION_MANAGER_FACTORY) + @Override + public boolean deleteBatch(Collection ids) { + return removeBatchByIds(ids); + } + +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigAddParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigAddParam.java new file mode 100644 index 00000000..59885fbd --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigAddParam.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class ScheduleJobConfigAddParam { + + @NotNull + @Schema(description = "任务分组 id") + private Long jobGroupId; + + @NotBlank + @Schema(description = "任务类型") + private String type; + + @NotBlank + @Schema(description = "任务名称") + private String name; + + @NotBlank + @Schema(description = "任务处理器") + private String handler; + + @Schema(description = "remark") + private String remark; +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigListParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigListParam.java new file mode 100644 index 00000000..3ca5e647 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigListParam.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class ScheduleJobConfigListParam { + + @NotNull + @Schema(description = "任务分组 id") + private Long jobGroupId; + + @Schema(description = "任务类型") + private String type; +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigPageParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigPageParam.java new file mode 100644 index 00000000..1c58845c --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigPageParam.java @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import cn.sliew.carp.framework.common.model.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class ScheduleJobConfigPageParam extends PageParam { + + @NotNull + @Schema(description = "任务分组 id") + private Long jobGroupId; + + @Schema(description = "任务类型") + private String type; + + @Schema(description = "任务名称") + private String name; + + @Schema(description = "任务处理器") + private String handler; +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigUpdateParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigUpdateParam.java new file mode 100644 index 00000000..b2dca9d7 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobConfigUpdateParam.java @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class ScheduleJobConfigUpdateParam { + + @NotNull + @Schema(description = "id") + private Long id; + + @NotBlank + @Schema(description = "任务名称") + private String name; + + @NotBlank + @Schema(description = "任务处理器") + private String handler; + + @Schema(description = "remark") + private String remark; +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupAddParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupAddParam.java new file mode 100644 index 00000000..32a2ec13 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupAddParam.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +@Data +public class ScheduleJobGroupAddParam { + + @NotBlank + @Schema(description = "命名空间") + private String namespace; + + @NotBlank + @Schema(description = "分组名称") + private String name; + + @Schema(description = "remark") + private String remark; +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupPageParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupPageParam.java new file mode 100644 index 00000000..22f9094f --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupPageParam.java @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import cn.sliew.carp.framework.common.model.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class ScheduleJobGroupPageParam extends PageParam { + + @Schema(description = "命名空间。模糊搜索") + private String namespace; + + @Schema(description = "分组名称。模糊搜索") + private String name; +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupUpdateParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupUpdateParam.java new file mode 100644 index 00000000..ed421124 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobGroupUpdateParam.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class ScheduleJobGroupUpdateParam { + + @NotNull + @Schema(description = "id") + private Long id; + + @NotBlank + @Schema(description = "分组名称") + private String name; + + @Schema(description = "remark") + private String remark; +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceAddParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceAddParam.java new file mode 100644 index 00000000..cbb324f7 --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceAddParam.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class ScheduleJobInstanceAddParam { + + @NotNull + @Schema(description = "任务配置id") + private Long jobConfigId; + + @NotBlank + @Schema(description = "实例名称") + private String name; + + @NotBlank + @Schema(description = "CRON表达式") + private String cron; + + @Schema(description = "参数") + private String params; + + @Schema(description = "超时时间(毫秒)") + private Long timeout; + + @Schema(description = "remark") + private String remark; +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceListParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceListParam.java new file mode 100644 index 00000000..dc78b19d --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceListParam.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class ScheduleJobInstanceListParam { + + @NotNull + @Schema(description = "任务配置id") + private Long jobConfigId; + + @Schema(description = "状态") + private String status; +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstancePageParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstancePageParam.java new file mode 100644 index 00000000..4c3864be --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstancePageParam.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import cn.sliew.carp.framework.common.model.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class ScheduleJobInstancePageParam extends PageParam { + + @NotNull + @Schema(description = "任务配置id") + private Long jobConfigId; + + @Schema(description = "实例名称") + private String name; + + @Schema(description = "状态") + private String status; +} diff --git a/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceUpdateParam.java b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceUpdateParam.java new file mode 100644 index 00000000..8120bb6e --- /dev/null +++ b/carp-modules/carp-module-scheduler/src/main/java/cn/sliew/module/scheduler/service/param/ScheduleJobInstanceUpdateParam.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.module.scheduler.service.param; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class ScheduleJobInstanceUpdateParam { + + @NotNull + @Schema(description = "id") + private Long id; + + @NotBlank + @Schema(description = "实例名称") + private String name; + + @NotBlank + @Schema(description = "CRON表达式") + private String cron; + + @Schema(description = "参数") + private String params; + + @Schema(description = "超时时间(毫秒)") + private Long timeout; + + @Schema(description = "remark") + private String remark; +} diff --git a/carp-modules/carp-module-scheduler/src/main/resources/cn/sliew/carp/module/scheduler/repository/mapper/ScheduleJobInstanceMapper.xml b/carp-modules/carp-module-scheduler/src/main/resources/cn/sliew/carp/module/scheduler/repository/mapper/ScheduleJobInstanceMapper.xml index acdb305c..8a6c671b 100644 --- a/carp-modules/carp-module-scheduler/src/main/resources/cn/sliew/carp/module/scheduler/repository/mapper/ScheduleJobInstanceMapper.xml +++ b/carp-modules/carp-module-scheduler/src/main/resources/cn/sliew/carp/module/scheduler/repository/mapper/ScheduleJobInstanceMapper.xml @@ -20,7 +20,7 @@ - + diff --git a/carp-modules/carp-module-security/carp-module-security-core/src/main/java/cn/sliew/carp/module/security/core/service/impl/SecRoleServiceImpl.java b/carp-modules/carp-module-security/carp-module-security-core/src/main/java/cn/sliew/carp/module/security/core/service/impl/SecRoleServiceImpl.java index 79ca68da..d7c7bdee 100644 --- a/carp-modules/carp-module-security/carp-module-security-core/src/main/java/cn/sliew/carp/module/security/core/service/impl/SecRoleServiceImpl.java +++ b/carp-modules/carp-module-security/carp-module-security-core/src/main/java/cn/sliew/carp/module/security/core/service/impl/SecRoleServiceImpl.java @@ -85,7 +85,7 @@ public boolean add(SecRoleAddParam param) { @Override public boolean update(SecRoleUpdateParam param) { SecRole entity = BeanUtil.copyProperties(param, SecRole.class); - return saveOrUpdate(entity); + return updateById(entity); } @Override diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/pom.xml b/carp-modules/carp-module-workflow/carp-module-workflow-api/pom.xml new file mode 100644 index 00000000..cd8e6f2b --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/pom.xml @@ -0,0 +1,39 @@ + + + + + 4.0.0 + + cn.sliew + carp-module-workflow + 0.0.12-SNAPSHOT + ../pom.xml + + carp-module-workflow-api + + + + ${project.parent.groupId} + carp-framework-dag + provided + + + + \ No newline at end of file diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/graph/WorkflowDefinitionGraph.java b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/graph/WorkflowDefinitionGraph.java new file mode 100644 index 00000000..5116194a --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/graph/WorkflowDefinitionGraph.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.workflow.api.graph; + +import cn.sliew.carp.framework.dag.service.dto.DagConfigStepDTO; +import com.google.common.graph.Graph; + +public interface WorkflowDefinitionGraph { + + Graph getGraph(); +} diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/graph/WorkflowExecutionGraph.java b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/graph/WorkflowExecutionGraph.java new file mode 100644 index 00000000..b7b98419 --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/graph/WorkflowExecutionGraph.java @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.workflow.api.graph; + +import cn.sliew.carp.framework.dag.service.dto.DagStepDTO; +import com.google.common.graph.Graph; + +public interface WorkflowExecutionGraph { + + Graph getGraph(); +} diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/WorkflowDefinitionService.java b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/WorkflowDefinitionService.java new file mode 100644 index 00000000..60eccaa6 --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/WorkflowDefinitionService.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.workflow.api.service; + +import cn.sliew.carp.framework.dag.service.dto.DagConfigDTO; +import cn.sliew.carp.framework.dag.service.dto.DagConfigStepDTO; +import cn.sliew.carp.module.workflow.api.service.param.WorkflowDefinitionListParam; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.graph.Graph; + +public interface WorkflowDefinitionService { + + Page list(WorkflowDefinitionListParam param); + + DagConfigDTO get(Long id); + + Graph getDag(Long id); + + DagConfigStepDTO getTaskDefinition(Long dagConfigStepId); +} diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/dto/WorkflowDefinitionDTO.java b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/dto/WorkflowDefinitionDTO.java new file mode 100644 index 00000000..a7d8ddbd --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/dto/WorkflowDefinitionDTO.java @@ -0,0 +1,49 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.workflow.api.service.dto; + +import cn.sliew.carp.framework.common.dict.workflow.WorkflowType; +import cn.sliew.carp.framework.common.model.BaseDTO; +import cn.sliew.carp.framework.dag.service.dto.DagConfigComplexDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.util.Map; + +@Data +public class WorkflowDefinitionDTO extends BaseDTO { + + @Schema(description = "workflow type") + private WorkflowType type; + + @Schema(description = "workflow name") + private String name; + + @Schema(description = "workflow param") + private Map param; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "schedule") + private WorkflowScheduleDTO schedule; + + @Schema(description = "dag") + private DagConfigComplexDTO dag; +} diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/dto/WorkflowDefinitionDagMeta.java b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/dto/WorkflowDefinitionDagMeta.java new file mode 100644 index 00000000..22987507 --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/dto/WorkflowDefinitionDagMeta.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.workflow.api.service.dto; + +import lombok.Data; + +@Data +public class WorkflowDefinitionDagMeta { + + private Long scheduleJobInstanceId; + +} diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/param/WorkflowDefinitionListParam.java b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/param/WorkflowDefinitionListParam.java new file mode 100644 index 00000000..1a603d1a --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/service/param/WorkflowDefinitionListParam.java @@ -0,0 +1,38 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.workflow.api.service.param; + +import cn.sliew.carp.framework.common.dict.workflow.WorkflowType; +import cn.sliew.carp.framework.common.model.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@Data +@EqualsAndHashCode(callSuper = true) +public class WorkflowDefinitionListParam extends PageParam { + + @NotNull + @Schema(description = "workflow type") + private WorkflowType type; + + @Schema(description = "workflow name") + private String name; +} diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/RetryableTask.java b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/RetryableTask.java new file mode 100644 index 00000000..71cfb2b3 --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/RetryableTask.java @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.workflow.api.task; + +import java.time.Duration; + +public interface RetryableTask extends Task{ + + long getBackoffPeriod(); + + long getTimeout(); + + default long getDynamicTimeout(StageExecution stage) { + return getTimeout(); + } + + default long getDynamicBackoffPeriod(Duration taskDuration) { + return getBackoffPeriod(); + } + + default long getDynamicBackoffPeriod(StageExecution stage, Duration taskDuration) { + return getDynamicBackoffPeriod(taskDuration); + } +} diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/SkippableTask.java b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/SkippableTask.java new file mode 100644 index 00000000..12bd6538 --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/SkippableTask.java @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.workflow.api.task; + +public interface SkippableTask extends Task{ + + +} diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/Task.java b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/Task.java new file mode 100644 index 00000000..6de383be --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/Task.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.workflow.api.task; + + +public interface Task { + + TaskResult execute(StageExecution state); + + TaskResult onTimeout(StageExecution stage); + + void onCancel(StageExecution stage); + +} diff --git a/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/TaskResult.java b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/TaskResult.java new file mode 100644 index 00000000..693c1e79 --- /dev/null +++ b/carp-modules/carp-module-workflow/carp-module-workflow-api/src/main/java/cn/sliew/carp/module/workflow/api/task/TaskResult.java @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.sliew.carp.module.workflow.api.task; + +public class TaskResult { +} diff --git a/carp-modules/carp-module-workflow/pom.xml b/carp-modules/carp-module-workflow/pom.xml new file mode 100644 index 00000000..02b58abf --- /dev/null +++ b/carp-modules/carp-module-workflow/pom.xml @@ -0,0 +1,36 @@ + + + + + 4.0.0 + + cn.sliew + carp-modules + 0.0.12-SNAPSHOT + ../pom.xml + + carp-module-workflow + pom + + + carp-module-workflow-api + + + \ No newline at end of file diff --git a/carp-modules/pom.xml b/carp-modules/pom.xml index bc5e879e..d9206b72 100644 --- a/carp-modules/pom.xml +++ b/carp-modules/pom.xml @@ -41,5 +41,6 @@ carp-module-scheduler carp-module-security carp-module-system + carp-module-workflow \ No newline at end of file diff --git a/pom.xml b/pom.xml index 7c65cffa..35281f82 100644 --- a/pom.xml +++ b/pom.xml @@ -166,6 +166,11 @@ carp-framework-common ${project.version} + + ${project.groupId} + carp-framework-dag + ${project.version} + ${project.groupId} carp-framework-exception @@ -173,22 +178,22 @@ ${project.groupId} - carp-framework-mongo + carp-framework-metrics ${project.version} ${project.groupId} - carp-framework-mybatis + carp-framework-mongo ${project.version} ${project.groupId} - carp-framework-web + carp-framework-mybatis ${project.version} ${project.groupId} - carp-framework-metrics + carp-framework-pekko ${project.version} @@ -198,7 +203,7 @@ ${project.groupId} - carp-framework-pekko + carp-framework-web ${project.version}