diff --git a/.github/workflows/release-manual-docker-gravitino.yml b/.github/workflows/release-manual-docker-gravitino.yml new file mode 100644 index 000000000..f93689194 --- /dev/null +++ b/.github/workflows/release-manual-docker-gravitino.yml @@ -0,0 +1,69 @@ +# 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. + +name: Release-Docker-Gravitino + +on: + workflow_dispatch: + inputs: + gravitinoVersion: + description: 'gravitino version' + required: true + default: '0.5.0' + type: choice + options: + - 0.5.0 +env: + HUB: ghcr.io/flowerfine/scaleph-gravitino + GRAVITINO_VERSION: ${{ inputs.gravitinoVersion }} + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + timeout-minutes: 360 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Log in to the Container registry + uses: docker/login-action@v3 + with: + registry: ${{ env.HUB }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: amd64,arm64 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build image + uses: docker/build-push-action@v5 + with: + no-cache: false + cache-from: type=gha + cache-to: type=gha + push: true + context: . + build-args: | + GRAVITINO_VERSION=${{ env.GRAVITINO_VERSION }} + platforms: linux/amd64,linux/arm64 + file: tools/docker/build/scaleph-gravitino/Dockerfile + tags: ${{ env.HUB }}:${{ env.GRAVITINO_VERSION }} diff --git a/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/workflow/WorkflowController.java b/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/workflow/WorkflowController.java index 1416ad12d..8c0d124de 100644 --- a/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/workflow/WorkflowController.java +++ b/scaleph-api/src/main/java/cn/sliew/scaleph/api/controller/workflow/WorkflowController.java @@ -24,7 +24,7 @@ import cn.sliew.scaleph.workflow.service.WorkflowInstanceService; import cn.sliew.scaleph.workflow.service.WorkflowTaskInstanceService; import cn.sliew.scaleph.workflow.service.dto.WorkflowDefinitionDTO; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO2; +import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO; import cn.sliew.scaleph.workflow.service.param.WorkflowDefinitionListParam; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.graph.Graph; @@ -64,8 +64,8 @@ public ResponseEntity> listWorkflowDefinitions(@Vali @Logging @GetMapping("{workflowDefinitionId}") @Operation(summary = "查询 workflow 定义列表", description = "查询 workflow 定义列表") - public ResponseEntity>> listWorkflowTaskDefinitions(@PathVariable("workflowDefinitionId") Long workflowDefinitionId) { - Graph dag = workflowDefinitionService.getDag(workflowDefinitionId); + public ResponseEntity>> listWorkflowTaskDefinitions(@PathVariable("workflowDefinitionId") Long workflowDefinitionId) { + Graph dag = workflowDefinitionService.getDag(workflowDefinitionId); return new ResponseEntity<>(ResponseVO.success(dag.nodes()), HttpStatus.OK); } diff --git a/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/job/DataSourceType.java b/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/job/DataSourceType.java index fc3309695..f253979bd 100644 --- a/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/job/DataSourceType.java +++ b/scaleph-common/src/main/java/cn/sliew/scaleph/common/dict/job/DataSourceType.java @@ -28,54 +28,54 @@ @JsonFormat(shape = JsonFormat.Shape.OBJECT) public enum DataSourceType implements DictInstance { - MYSQL("MySQL", "MySQL"), - ORACLE("Oracle", "Oracle"), - POSTGRESQL("PostgreSQL", "PostgreSQL"), - SQLSERVER("SQLServer", "SQLServer"), - DMDB("DmDB", "DmDB"), - GBASE8A("GBase8a", "GBase8a"), - GREENPLUM("Greenplum", "Greenplum"), - PHOENIX("Phoenix", "Phoenix"), - - REDIS("Redis", "Redis"), - ELASTICSEARCH("Elasticsearch", "Elasticsearch"), - SOLR("Solr", "Solr"), - MONGODB("MongoDB", "MongoDB"), - TIDB("TiDB", "TiDB"), - CASSANDRA("Cassandra", "Cassandra"), - - KAFKA("Kafka", "Kafka"), - PULSAR("Pulsar", "Pulsar"), - DATAHUB("DataHub", "DataHub"), - - FTP("Ftp", "Ftp"), - SFTP("Sftp", "Sftp"), - OSS("OSS", "OSS"), - OSSJINDO("OSSJindo", "OSSJindo"), - S3("S3", "S3"), - HDFS("HDFS", "HDFS"), - - HIVE("Hive", "Hive"), - HBASE("HBase", "HBase"), - IMPALA("Impala", "Impala"), - DORIS("Doris", "Doris"), - STARROCKS("StarRocks", "StarRocks"), - CLICKHOUSE("ClickHouse", "ClickHouse"), - KUDU("Kudu", "Kudu"), - KYLIN("Kylin", "Kylin"), - DRUID("Druid", "Druid"), - MAXCOMPUTE("MaxCompute", "MaxCompute"), - - IOTDB("IoTDB", "IoTDB"), - NEO4J("Neo4j", "Neo4j"), - - HUDI("Hudi", "Hudi"), - ICEBERG("Iceberg", "Iceberg"), - - INFLUXDB("InfluxDB", "InfluxDB"), - EMAIL("Email", "Email"), - SOCKET("Socket", "Socket"), - HTTP("Http", "Http"), + MYSQL("MySQL", "MySQL", "mysql remark"), + ORACLE("Oracle", "Oracle", null), + POSTGRESQL("PostgreSQL", "PostgreSQL", null), + SQLSERVER("SQLServer", "SQLServer", null), + DMDB("DmDB", "DmDB", null), + GBASE8A("GBase8a", "GBase8a", null), + GREENPLUM("Greenplum", "Greenplum", null), + PHOENIX("Phoenix", "Phoenix", null), + + REDIS("Redis", "Redis", null), + ELASTICSEARCH("Elasticsearch", "Elasticsearch", null), + SOLR("Solr", "Solr", null), + MONGODB("MongoDB", "MongoDB", null), + TIDB("TiDB", "TiDB", null), + CASSANDRA("Cassandra", "Cassandra", null), + + KAFKA("Kafka", "Kafka", null), + PULSAR("Pulsar", "Pulsar", null), + DATAHUB("DataHub", "DataHub", null), + + FTP("Ftp", "Ftp", null), + SFTP("Sftp", "Sftp", null), + OSS("OSS", "OSS", null), + OSSJINDO("OSSJindo", "OSSJindo", null), + S3("S3", "S3", null), + HDFS("HDFS", "HDFS", null), + + HIVE("Hive", "Hive", null), + HBASE("HBase", "HBase", null), + IMPALA("Impala", "Impala", null), + DORIS("Doris", "Doris", null), + STARROCKS("StarRocks", "StarRocks", null), + CLICKHOUSE("ClickHouse", "ClickHouse", null), + KUDU("Kudu", "Kudu", null), + KYLIN("Kylin", "Kylin", null), + DRUID("Druid", "Druid", null), + MAXCOMPUTE("MaxCompute", "MaxCompute", null), + + IOTDB("IoTDB", "IoTDB", null), + NEO4J("Neo4j", "Neo4j", null), + + HUDI("Hudi", "Hudi", null), + ICEBERG("Iceberg", "Iceberg", null), + + INFLUXDB("InfluxDB", "InfluxDB", null), + EMAIL("Email", "Email", null), + SOCKET("Socket", "Socket", null), + HTTP("Http", "Http", null), ; @JsonCreator @@ -88,10 +88,12 @@ public static DataSourceType of(String value) { @EnumValue private String value; private String label; + private String remark; - DataSourceType(String value, String label) { + DataSourceType(String value, String label, String remark) { this.value = value; this.label = label; + this.remark = remark; } @Override @@ -103,4 +105,9 @@ public String getValue() { public String getLabel() { return label; } + + @Override + public String getRemark() { + return remark; + } } diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagInstance.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagInstance.java index f51ceb357..f0ca3b15b 100644 --- a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagInstance.java +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagInstance.java @@ -23,6 +23,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import java.util.Date; + /** * DAG 实例 */ @@ -32,9 +34,24 @@ public class DagInstance extends BaseDO { private static final long serialVersionUID = 1L; - @TableField("dag_meta") - private String dagMeta; + @TableField("dag_config_id") + private Long dagConfigId; + + @TableField("instance_id") + private String instanceId; + + @TableField("inputs") + private String inputs; + + @TableField("outputs") + private String outputs; + + @TableField("`status`") + private String status; + + @TableField("start_time") + private Date startTime; - @TableField("dag_attrs") - private String dagAttrs; + @TableField("end_time") + private Date endTime; } diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagLink.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagLink.java index 222c4a940..cbd301a2c 100644 --- a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagLink.java +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagLink.java @@ -23,6 +23,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import java.util.Date; + /** * DAG 连线 */ @@ -32,24 +34,27 @@ public class DagLink extends BaseDO { private static final long serialVersionUID = 1L; - @TableField("dag_id") - private Long dagId; + @TableField("dag_instance_id") + private Long dagInstanceId; + + @TableField("dag_config_link_id") + private Long dagConfigLinkId; - @TableField("link_id") - private String linkId; + @TableField("instance_id") + private String instanceId; - @TableField("link_name") - private String linkName; + @TableField("inputs") + private String inputs; - @TableField("from_step_id") - private String fromStepId; + @TableField("outputs") + private String outputs; - @TableField("to_step_id") - private String toStepId; + @TableField("`status`") + private String status; - @TableField("link_meta") - private String linkMeta; + @TableField("start_time") + private Date startTime; - @TableField("link_attrs") - private String linkAttrs; + @TableField("end_time") + private Date endTime; } diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagLinkVO.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagLinkVO.java new file mode 100644 index 000000000..66a179e00 --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagLinkVO.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.scaleph.dao.entity.master.dag; + +import cn.sliew.scaleph.dao.entity.BaseDO; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.Date; + +/** + * DAG 连线 + */ +@Data +@TableName("dag_link") +public class DagLinkVO extends BaseDO { + + private static final long serialVersionUID = 1L; + + @TableField("dag_instance_id") + private Long dagInstanceId; + + @TableField(value = "dag_config_link_id", exist = false) + private DagConfigLink dagConfigLink; + + @TableField("instance_id") + private String instanceId; + + @TableField("inputs") + private String inputs; + + @TableField("outputs") + private String outputs; + + @TableField("`status`") + private String status; + + @TableField("start_time") + private Date startTime; + + @TableField("end_time") + private Date endTime; +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagStep.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagStep.java index 6856b3528..93b5e92b5 100644 --- a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagStep.java +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagStep.java @@ -23,6 +23,8 @@ import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; +import java.util.Date; + /** * DAG 步骤 */ @@ -32,24 +34,27 @@ public class DagStep extends BaseDO { private static final long serialVersionUID = 1L; - @TableField("dag_id") - private Long dagId; + @TableField("dag_instance_id") + private Long dagInstanceId; + + @TableField("dag_config_step_id") + private Long dagConfigStepId; - @TableField("step_id") - private String stepId; + @TableField("instance_id") + private String instanceId; - @TableField("step_name") - private String stepName; + @TableField("inputs") + private String inputs; - @TableField("position_x") - private Integer positionX; + @TableField("outputs") + private String outputs; - @TableField("position_y") - private Integer positionY; + @TableField("`status`") + private String status; - @TableField("step_meta") - private String stepMeta; + @TableField("start_time") + private Date startTime; - @TableField("step_attrs") - private String stepAttrs; + @TableField("end_time") + private Date endTime; } diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagStepVO.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagStepVO.java new file mode 100644 index 000000000..bd979ca5e --- /dev/null +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/entity/master/dag/DagStepVO.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.scaleph.dao.entity.master.dag; + +import cn.sliew.scaleph.dao.entity.BaseDO; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +import java.util.Date; + +/** + * DAG 步骤 + */ +@Data +@TableName("dag_step") +public class DagStepVO extends BaseDO { + + private static final long serialVersionUID = 1L; + + @TableField("dag_instance_id") + private Long dagInstanceId; + + @TableField("dag_config_step_id") + private DagConfigStep dagConfigStep; + + @TableField("instance_id") + private String instanceId; + + @TableField("inputs") + private String inputs; + + @TableField("outputs") + private String outputs; + + @TableField("`status`") + private String status; + + @TableField("start_time") + private Date startTime; + + @TableField("end_time") + private Date endTime; +} diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dag/DagLinkMapper.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dag/DagLinkMapper.java index 98f603bb9..6a035a260 100644 --- a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dag/DagLinkMapper.java +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dag/DagLinkMapper.java @@ -19,13 +19,18 @@ package cn.sliew.scaleph.dao.mapper.master.dag; import cn.sliew.scaleph.dao.entity.master.dag.DagLink; +import cn.sliew.scaleph.dao.entity.master.dag.DagLinkVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; +import java.util.List; + /** * DAG 连线 Mapper 接口 */ @Repository public interface DagLinkMapper extends BaseMapper { + List listByDagInstanceId(@Param("dagInstanceId") Long dagInstanceId); } diff --git a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dag/DagStepMapper.java b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dag/DagStepMapper.java index 27fe01cde..b9ca2c057 100644 --- a/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dag/DagStepMapper.java +++ b/scaleph-dao/src/main/java/cn/sliew/scaleph/dao/mapper/master/dag/DagStepMapper.java @@ -19,13 +19,18 @@ package cn.sliew.scaleph.dao.mapper.master.dag; import cn.sliew.scaleph.dao.entity.master.dag.DagStep; +import cn.sliew.scaleph.dao.entity.master.dag.DagStepVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Param; import org.springframework.stereotype.Repository; +import java.util.List; + /** * DAG 步骤 Mapper 接口 */ @Repository public interface DagStepMapper extends BaseMapper { + List listByDagInstanceId(@Param("dagInstanceId") Long dagInstanceId); } diff --git a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagInstanceMapper.xml b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagInstanceMapper.xml index b39b94c85..f44e8e14b 100644 --- a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagInstanceMapper.xml +++ b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagInstanceMapper.xml @@ -26,8 +26,13 @@ - - + + + + + + + @@ -37,7 +42,7 @@ create_time, editor, update_time, - dag_meta, dag_attrs + dag_config_id, instance_id, inputs, outputs, `status`, start_time, end_time diff --git a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagLinkMapper.xml b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagLinkMapper.xml index e96e3f196..b908138c0 100644 --- a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagLinkMapper.xml +++ b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagLinkMapper.xml @@ -26,13 +26,32 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + @@ -42,7 +61,14 @@ create_time, editor, update_time, - dag_id, link_id, link_name, from_step_id, to_step_id, link_meta, link_attrs + dag_instance_id, dag_config_link_id, instance_id, inputs, outputs, `status`, start_time, end_time + + diff --git a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagStepMapper.xml b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagStepMapper.xml index 351e03210..1aed53293 100644 --- a/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagStepMapper.xml +++ b/scaleph-dao/src/main/resources/cn/sliew/scaleph/dao/mapper/master/dag/DagStepMapper.xml @@ -26,13 +26,31 @@ - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + @@ -42,7 +60,15 @@ create_time, editor, update_time, - dag_id, step_id, step_name, position_x, position_y, step_meta, step_attrs + dag_instance_id, dag_config_step_id, instance_id, inputs, outputs, `status`, start_time, end_time + + + diff --git a/scaleph-datasource/src/main/java/cn/sliew/scaleph/ds/gravitino/GravitinoInitializer.java b/scaleph-datasource/src/main/java/cn/sliew/scaleph/ds/gravitino/GravitinoInitializer.java index 61d84a885..bdc3fa87e 100644 --- a/scaleph-datasource/src/main/java/cn/sliew/scaleph/ds/gravitino/GravitinoInitializer.java +++ b/scaleph-datasource/src/main/java/cn/sliew/scaleph/ds/gravitino/GravitinoInitializer.java @@ -18,18 +18,25 @@ package cn.sliew.scaleph.ds.gravitino; +import cn.sliew.milky.common.util.JacksonUtil; import cn.sliew.scaleph.common.dict.job.DataSourceType; +import cn.sliew.scaleph.ds.modal.AbstractDataSource; +import cn.sliew.scaleph.ds.modal.jdbc.JdbcDataSource; import cn.sliew.scaleph.ds.service.DsInfoService; import cn.sliew.scaleph.ds.service.dto.DsInfoDTO; +import com.datastrato.gravitino.Catalog; import com.datastrato.gravitino.NameIdentifier; import com.datastrato.gravitino.client.GravitinoAdminClient; import com.datastrato.gravitino.client.GravitinoMetalake; +import com.fasterxml.jackson.databind.node.ObjectNode; import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.Collections; +import java.util.HashMap; import java.util.List; +import java.util.Map; @Component public class GravitinoInitializer implements InitializingBean { @@ -80,6 +87,7 @@ private void doInitDataSource(String metalakeName, DataSourceType type, DsInfoDT if (metalake.catalogExists(catalogName) == false) { switch (type) { case MYSQL: + initMySQL(metalake, catalogName, dsInfoDTO); break; case POSTGRESQL: break; @@ -97,4 +105,14 @@ private void doInitDataSource(String metalakeName, DataSourceType type, DsInfoDT } } } + + private void initMySQL(GravitinoMetalake metalake, NameIdentifier catalogName, DsInfoDTO dsInfoDTO) { + JdbcDataSource dataSource = (JdbcDataSource) AbstractDataSource.fromDsInfo((ObjectNode) JacksonUtil.toJsonNode(dsInfoDTO)); + Map properties = new HashMap<>(); + properties.put("jdbc-driver", dataSource.getDriverClassName()); + properties.put("jdbc-url", dataSource.getUrl()); + properties.put("jdbc-user", dataSource.getUser()); + properties.put("jdbc-password", dataSource.getPassword()); + metalake.createCatalog(catalogName, Catalog.Type.RELATIONAL, "jdbc-mysql", dataSource.getRemark(), properties); + } } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagConfigComplexService.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagConfigComplexService.java index e8c01f0dd..5e0a934e7 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagConfigComplexService.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagConfigComplexService.java @@ -20,9 +20,11 @@ import cn.sliew.scaleph.dag.service.dto.DagConfigComplexDTO; import cn.sliew.scaleph.dag.service.dto.DagConfigDTO; +import cn.sliew.scaleph.dag.service.dto.DagConfigStepDTO; import cn.sliew.scaleph.dag.service.param.DagConfigSimpleAddParam; import cn.sliew.scaleph.dag.service.param.DagConfigSimpleUpdateParam; import cn.sliew.scaleph.dag.service.vo.DagGraphVO; +import com.google.common.graph.Graph; import java.util.List; @@ -32,6 +34,8 @@ public interface DagConfigComplexService { DagConfigDTO selectSimpleOne(Long dagId); + Graph getDag(Long dagId); + Long insert(DagConfigSimpleAddParam param); int update(DagConfigSimpleUpdateParam param); diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagService.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagInstanceComplexService.java similarity index 60% rename from scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagService.java rename to scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagInstanceComplexService.java index 381c76145..51ef351fe 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagService.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagInstanceComplexService.java @@ -18,29 +18,19 @@ package cn.sliew.scaleph.dag.service; -import cn.sliew.scaleph.dag.service.dto.DagDTO; +import cn.sliew.scaleph.dag.service.dto.DagConfigStepDTO; +import cn.sliew.scaleph.dag.service.dto.DagInstanceComplexDTO; import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; -import cn.sliew.scaleph.dag.service.param.DagSimpleAddParam; -import cn.sliew.scaleph.dag.service.param.DagSimpleUpdateParam; -import cn.sliew.scaleph.dag.service.vo.DagGraphVO; +import cn.sliew.scaleph.dag.service.dto.DagStepDTO; +import com.google.common.graph.Graph; -import java.util.List; +public interface DagInstanceComplexService { -public interface DagService { + DagInstanceComplexDTO selectOne(Long dagInstanceId); - DagDTO selectOne(Long dagId); + DagInstanceDTO selectSimpleOne(Long dagInstanceId); - DagInstanceDTO selectSimpleOne(Long dagId); + Graph getDag(Long dagInstanceId, Graph configDag); - Long insert(DagSimpleAddParam param); - - int update(DagSimpleUpdateParam param); - - void replace(Long dagId, DagGraphVO graph); - - Long clone(Long dagId); - - int delete(Long dagId); - - int deleteBatch(List dagIds); + Long initialize(Long dagConfigId); } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagInstanceService.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagInstanceService.java index 505c49bb4..19d87f44a 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagInstanceService.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagInstanceService.java @@ -24,17 +24,9 @@ public interface DagInstanceService { - DagInstanceDTO selectOne(Long dagId); + DagInstanceDTO selectOne(Long dagInstanceId); Long insert(DagInstanceDTO instanceDTO); int update(DagInstanceDTO instanceDTO); - - void upsert(DagInstanceDTO instanceDTO); - - int delete(Long dagId); - - int deleteBatch(List dagIds); - - Long clone(Long dagId); } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagLinkService.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagLinkService.java index fe4135df0..2a4ce0042 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagLinkService.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagLinkService.java @@ -24,19 +24,9 @@ public interface DagLinkService { - List listLinks(Long dagId); + List listLinks(Long dagInstanceId); int insert(DagLinkDTO linkDTO); int update(DagLinkDTO linkDTO); - - int upsert(DagLinkDTO linkDTO); - - int deleteByDag(Long dagId); - - int deleteByDag(List dagIds); - - int deleteSurplusLinks(Long dagId, List linkIds); - - int clone(Long sourceDagId, Long targetDagId); } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagStepService.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagStepService.java index c76eee9e2..3c06b7757 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagStepService.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/DagStepService.java @@ -18,28 +18,17 @@ package cn.sliew.scaleph.dag.service; -import cn.sliew.scaleph.dag.service.dto.DagDTO; import cn.sliew.scaleph.dag.service.dto.DagStepDTO; import java.util.List; public interface DagStepService { - List listSteps(Long dagId); + List listSteps(Long dagInstanceId); - DagStepDTO selectOne(Long stepId); + DagStepDTO selectOne(Long id); int insert(DagStepDTO stepDTO); int update(DagStepDTO stepDTO); - - int upsert(DagStepDTO stepDTO); - - int deleteByDag(Long dagId); - - int deleteByDag(List dagIds); - - int deleteSurplusSteps(Long dagId, List stepIds); - - int clone(Long sourceDagId, Long targetDagId); } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagInstanceConvert.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagInstanceConvert.java index ad688a27c..62f707f9e 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagInstanceConvert.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagInstanceConvert.java @@ -20,6 +20,7 @@ import cn.sliew.milky.common.util.JacksonUtil; import cn.sliew.scaleph.common.convert.BaseConvert; +import cn.sliew.scaleph.dag.service.dto.DagConfigComplexDTO; import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; import cn.sliew.scaleph.dao.entity.master.dag.DagInstance; import org.mapstruct.Mapper; @@ -36,11 +37,14 @@ public interface DagInstanceConvert extends BaseConvert { default DagLink toDo(DagLinkDTO dto) { DagLink entity = new DagLink(); BeanUtils.copyProperties(dto, entity); - if (dto.getLinkMeta() != null) { - entity.setLinkMeta(dto.getLinkMeta().toString()); + if (dto.getDagConfigLink() != null) { + entity.setDagConfigLinkId(dto.getDagConfigLink().getId()); } - if (dto.getLinkAttrs() != null) { - entity.setLinkAttrs(dto.getLinkAttrs().toString()); + if (dto.getInputs() != null) { + entity.setInputs(dto.getInputs().toString()); + } + if (dto.getOutputs() != null) { + entity.setOutputs(dto.getOutputs().toString()); } return entity; } @@ -49,11 +53,14 @@ default DagLink toDo(DagLinkDTO dto) { default DagLinkDTO toDto(DagLink entity) { DagLinkDTO dto = new DagLinkDTO(); BeanUtils.copyProperties(entity, dto); - if (StringUtils.hasText(entity.getLinkMeta())) { - dto.setLinkMeta(JacksonUtil.toJsonNode(entity.getLinkMeta())); + DagConfigLinkDTO dagConfigLink = new DagConfigLinkDTO(); + dagConfigLink.setId(entity.getDagConfigLinkId()); + dto.setDagConfigLink(dagConfigLink); + if (StringUtils.hasText(entity.getInputs())) { + dto.setInputs(JacksonUtil.toJsonNode(entity.getInputs())); } - if (StringUtils.hasText(entity.getLinkAttrs())) { - dto.setLinkAttrs(JacksonUtil.toJsonNode(entity.getLinkAttrs())); + if (StringUtils.hasText(entity.getOutputs())) { + dto.setOutputs(JacksonUtil.toJsonNode(entity.getOutputs())); } return dto; } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagLinkVOConvert.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagLinkVOConvert.java new file mode 100644 index 000000000..0edc094ec --- /dev/null +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagLinkVOConvert.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.scaleph.dag.service.convert; + +import cn.sliew.milky.common.util.JacksonUtil; +import cn.sliew.scaleph.common.convert.BaseConvert; +import cn.sliew.scaleph.dag.service.dto.DagLinkDTO; +import cn.sliew.scaleph.dao.entity.master.dag.DagLinkVO; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; +import org.springframework.beans.BeanUtils; +import org.springframework.util.StringUtils; + +@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface DagLinkVOConvert extends BaseConvert { + DagLinkVOConvert INSTANCE = Mappers.getMapper(DagLinkVOConvert.class); + + @Override + default DagLinkVO toDo(DagLinkDTO dto) { + DagLinkVO entity = new DagLinkVO(); + BeanUtils.copyProperties(dto, entity); + if (dto.getDagConfigLink() != null) { + entity.setDagConfigLink(DagConfigLinkConvert.INSTANCE.toDo(dto.getDagConfigLink())); + } + if (dto.getInputs() != null) { + entity.setInputs(dto.getInputs().toString()); + } + if (dto.getOutputs() != null) { + entity.setOutputs(dto.getOutputs().toString()); + } + return entity; + } + + @Override + default DagLinkDTO toDto(DagLinkVO entity) { + DagLinkDTO dto = new DagLinkDTO(); + BeanUtils.copyProperties(entity, dto); + dto.setDagConfigLink(DagConfigLinkConvert.INSTANCE.toDto(entity.getDagConfigLink())); + if (StringUtils.hasText(entity.getInputs())) { + dto.setInputs(JacksonUtil.toJsonNode(entity.getInputs())); + } + if (StringUtils.hasText(entity.getOutputs())) { + dto.setOutputs(JacksonUtil.toJsonNode(entity.getOutputs())); + } + return dto; + } +} diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagStepConvert.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagStepConvert.java index 383e60c0a..d64c63ab3 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagStepConvert.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagStepConvert.java @@ -20,6 +20,7 @@ import cn.sliew.milky.common.util.JacksonUtil; import cn.sliew.scaleph.common.convert.BaseConvert; +import cn.sliew.scaleph.dag.service.dto.DagConfigStepDTO; import cn.sliew.scaleph.dag.service.dto.DagStepDTO; import cn.sliew.scaleph.dao.entity.master.dag.DagStep; import org.mapstruct.Mapper; @@ -36,11 +37,14 @@ public interface DagStepConvert extends BaseConvert { default DagStep toDo(DagStepDTO dto) { DagStep entity = new DagStep(); BeanUtils.copyProperties(dto, entity); - if (dto.getStepMeta() != null) { - entity.setStepMeta(dto.getStepMeta().toString()); + if (dto.getDagConfigStep() != null) { + entity.setDagConfigStepId(dto.getDagConfigStep().getId()); } - if (dto.getStepAttrs() != null) { - entity.setStepAttrs(dto.getStepAttrs().toString()); + if (dto.getInputs() != null) { + entity.setInputs(dto.getInputs().toString()); + } + if (dto.getOutputs() != null) { + entity.setOutputs(dto.getOutputs().toString()); } return entity; } @@ -49,11 +53,14 @@ default DagStep toDo(DagStepDTO dto) { default DagStepDTO toDto(DagStep entity) { DagStepDTO dto = new DagStepDTO(); BeanUtils.copyProperties(entity, dto); - if (StringUtils.hasText(entity.getStepMeta())) { - dto.setStepMeta(JacksonUtil.toJsonNode(entity.getStepMeta())); + DagConfigStepDTO dagConfigStep = new DagConfigStepDTO(); + dagConfigStep.setId(entity.getDagConfigStepId()); + dto.setDagConfigStep(dagConfigStep); + if (StringUtils.hasText(entity.getInputs())) { + dto.setInputs(JacksonUtil.toJsonNode(entity.getInputs())); } - if (StringUtils.hasText(entity.getStepAttrs())) { - dto.setStepAttrs(JacksonUtil.toJsonNode(entity.getStepAttrs())); + if (StringUtils.hasText(entity.getOutputs())) { + dto.setOutputs(JacksonUtil.toJsonNode(entity.getOutputs())); } return dto; } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagStepVOConvert.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagStepVOConvert.java new file mode 100644 index 000000000..b82ebacae --- /dev/null +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/convert/DagStepVOConvert.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.scaleph.dag.service.convert; + +import cn.sliew.milky.common.util.JacksonUtil; +import cn.sliew.scaleph.common.convert.BaseConvert; +import cn.sliew.scaleph.dag.service.dto.DagStepDTO; +import cn.sliew.scaleph.dao.entity.master.dag.DagStepVO; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; +import org.mapstruct.factory.Mappers; +import org.springframework.beans.BeanUtils; +import org.springframework.util.StringUtils; + +@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface DagStepVOConvert extends BaseConvert { + DagStepVOConvert INSTANCE = Mappers.getMapper(DagStepVOConvert.class); + + @Override + default DagStepVO toDo(DagStepDTO dto) { + DagStepVO entity = new DagStepVO(); + BeanUtils.copyProperties(dto, entity); + if (dto.getDagConfigStep() != null) { + entity.setDagConfigStep(DagConfigStepConvert.INSTANCE.toDo(dto.getDagConfigStep())); + } + if (dto.getInputs() != null) { + entity.setInputs(dto.getInputs().toString()); + } + if (dto.getOutputs() != null) { + entity.setOutputs(dto.getOutputs().toString()); + } + return entity; + } + + @Override + default DagStepDTO toDto(DagStepVO entity) { + DagStepDTO dto = new DagStepDTO(); + BeanUtils.copyProperties(entity, dto); + dto.setDagConfigStep(DagConfigStepConvert.INSTANCE.toDto(entity.getDagConfigStep())); + if (StringUtils.hasText(entity.getInputs())) { + dto.setInputs(JacksonUtil.toJsonNode(entity.getInputs())); + } + if (StringUtils.hasText(entity.getOutputs())) { + dto.setOutputs(JacksonUtil.toJsonNode(entity.getOutputs())); + } + return dto; + } +} diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagDTO.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagInstanceComplexDTO.java similarity index 95% rename from scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagDTO.java rename to scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagInstanceComplexDTO.java index 291e2414f..187e56354 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagDTO.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagInstanceComplexDTO.java @@ -28,7 +28,7 @@ */ @Data @Schema(name = "Dag", description = "DAG") -public class DagDTO extends DagInstanceDTO { +public class DagInstanceComplexDTO extends DagInstanceDTO { @Schema(description = "连线") private List links; diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagInstanceDTO.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagInstanceDTO.java index a70d3c116..dee0eadd6 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagInstanceDTO.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagInstanceDTO.java @@ -23,6 +23,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.Date; + /** * DAG 实例 */ @@ -32,9 +34,24 @@ public class DagInstanceDTO extends BaseDTO { private static final long serialVersionUID = 1L; - @Schema(description = "DAG元信息") - private JsonNode dagMeta; + @Schema(description = "DAG配置") + private DagConfigComplexDTO dagConfig; + + @Schema(description = "instance id") + private String instanceId; + + @Schema(description = "输入参数") + private JsonNode inputs; + + @Schema(description = "输出参数") + private JsonNode outputs; + + @Schema(description = "状态") + private String status; + + @Schema(description = "启动时间") + private Date startTime; - @Schema(description = "DAG属性") - private JsonNode dagAttrs; + @Schema(description = "结束时间") + private Date endTime; } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagLinkDTO.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagLinkDTO.java index dae6ab64e..7f8e624db 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagLinkDTO.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagLinkDTO.java @@ -23,6 +23,8 @@ import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.Date; + /** * DAG 连线 */ @@ -33,23 +35,26 @@ public class DagLinkDTO extends BaseDTO { private static final long serialVersionUID = 1L; @Schema(description = "DAG id") - private Long dagId; + private Long dagInstanceId; @Schema(description = "连线id") - private String linkId; + private DagConfigLinkDTO dagConfigLink; + + @Schema(description = "instance id") + private String instanceId; - @Schema(description = "连线名称") - private String linkName; + @Schema(description = "输入参数") + private JsonNode inputs; - @Schema(description = "源步骤id") - private String fromStepId; + @Schema(description = "输出参数") + private JsonNode outputs; - @Schema(description = "目标步骤id") - private String toStepId; + @Schema(description = "状态") + private String status; - @Schema(description = "连线元信息") - private JsonNode linkMeta; + @Schema(description = "启动时间") + private Date startTime; - @Schema(description = "连线属性") - private JsonNode linkAttrs; + @Schema(description = "结束时间") + private Date endTime; } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagStepDTO.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagStepDTO.java index ee7431cd6..88e46ca00 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagStepDTO.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/dto/DagStepDTO.java @@ -18,11 +18,14 @@ package cn.sliew.scaleph.dag.service.dto; +import cn.sliew.scaleph.dao.entity.master.dag.DagConfigStep; import cn.sliew.scaleph.system.model.BaseDTO; import com.fasterxml.jackson.databind.JsonNode; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; +import java.util.Date; + /** * DAG 步骤 */ @@ -33,23 +36,26 @@ public class DagStepDTO extends BaseDTO { private static final long serialVersionUID = 1L; @Schema(description = "DAG id") - private Long dagId; + private Long dagInstanceId; + + @Schema(description = "步骤") + private DagConfigStepDTO dagConfigStep; - @Schema(description = "步骤id") - private String stepId; + @Schema(description = "instance id") + private String instanceId; - @Schema(description = "步骤名称") - private String stepName; + @Schema(description = "输入参数") + private JsonNode inputs; - @Schema(description = "x坐标") - private Integer positionX; + @Schema(description = "输出参数") + private JsonNode outputs; - @Schema(description = "y坐标") - private Integer positionY; + @Schema(description = "状态") + private String status; - @Schema(description = "步骤元信息") - private JsonNode stepMeta; + @Schema(description = "启动时间") + private Date startTime; - @Schema(description = "步骤属性") - private JsonNode stepAttrs; + @Schema(description = "结束时间") + private Date endTime; } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagConfigComplexServiceImpl.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagConfigComplexServiceImpl.java index acc459f3b..e6b52e847 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagConfigComplexServiceImpl.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagConfigComplexServiceImpl.java @@ -32,11 +32,17 @@ import cn.sliew.scaleph.dag.service.vo.DagGraphVO; import cn.sliew.scaleph.dag.service.vo.EdgeCellVO; import cn.sliew.scaleph.dag.service.vo.NodeCellVO; +import com.google.common.graph.Graph; +import com.google.common.graph.GraphBuilder; +import com.google.common.graph.MutableGraph; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; @Service @@ -64,6 +70,24 @@ public DagConfigDTO selectSimpleOne(Long dagId) { return dagConfigService.selectOne(dagId); } + @Override + public Graph getDag(Long dagId) { + DagConfigComplexDTO dag = selectOne(dagId); + MutableGraph graph = GraphBuilder.directed().build(); + List steps = dag.getSteps(); + List links = dag.getLinks(); + if (CollectionUtils.isEmpty(steps)) { + return graph; + } + Map stepMap = new HashMap<>(); + for (DagConfigStepDTO step : steps) { + graph.addNode(step); + stepMap.put(step.getStepId(), step); + } + links.forEach(link -> graph.putEdge(stepMap.get(link.getFromStepId()), stepMap.get(link.getToStepId()))); + return graph; + } + @Override public Long insert(DagConfigSimpleAddParam param) { DagConfigDTO configDTO = new DagConfigDTO(); diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagInstanceComplexServiceImpl.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagInstanceComplexServiceImpl.java new file mode 100644 index 000000000..473ff45b4 --- /dev/null +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagInstanceComplexServiceImpl.java @@ -0,0 +1,123 @@ +/* + * 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.scaleph.dag.service.impl; + +import cn.sliew.scaleph.common.dict.workflow.WorkflowInstanceState; +import cn.sliew.scaleph.common.dict.workflow.WorkflowTaskInstanceStage; +import cn.sliew.scaleph.common.util.UUIDUtil; +import cn.sliew.scaleph.dag.service.*; +import cn.sliew.scaleph.dag.service.dto.*; +import com.google.common.graph.EndpointPair; +import com.google.common.graph.Graph; +import com.google.common.graph.GraphBuilder; +import com.google.common.graph.MutableGraph; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Service +public class DagInstanceComplexServiceImpl implements DagInstanceComplexService { + + @Autowired + private DagConfigComplexService dagConfigComplexService; + @Autowired + private DagInstanceService dagInstanceService; + @Autowired + private DagLinkService dagLinkService; + @Autowired + private DagStepService dagStepService; + + @Override + public DagInstanceComplexDTO selectOne(Long dagInstanceId) { + DagInstanceComplexDTO dagInstanceComplexDTO = new DagInstanceComplexDTO(); + DagInstanceDTO instanceDTO = dagInstanceService.selectOne(dagInstanceId); + BeanUtils.copyProperties(instanceDTO, dagInstanceComplexDTO); + dagInstanceComplexDTO.setLinks(dagLinkService.listLinks(dagInstanceId)); + dagInstanceComplexDTO.setSteps(dagStepService.listSteps(dagInstanceId)); + return dagInstanceComplexDTO; + } + + @Override + public DagInstanceDTO selectSimpleOne(Long dagInstanceId) { + return dagInstanceService.selectOne(dagInstanceId); + } + + @Override + public Graph getDag(Long dagInstanceId, Graph configDag) { + List dagStepDTOS = dagStepService.listSteps(dagInstanceId); + MutableGraph graph = GraphBuilder.directed().build(); + Map stepMap = new HashMap<>(); + for (DagStepDTO dagStepDTO : dagStepDTOS) { + stepMap.put(dagStepDTO.getDagConfigStep().getId(), dagStepDTO); + graph.addNode(dagStepDTO); + } + for (EndpointPair edge : configDag.edges()) { + DagConfigStepDTO source = edge.source(); + DagConfigStepDTO target = edge.target(); + graph.putEdge(stepMap.get(source.getId()), stepMap.get(target.getId())); + } + return graph; + } + + @Override + public Long initialize(Long dagConfigId) { + DagConfigComplexDTO dagConfigComplexDTO = dagConfigComplexService.selectOne(dagConfigId); + // 插入 dag_instance + DagInstanceDTO dagInstanceDTO = new DagInstanceDTO(); + dagInstanceDTO.setDagConfig(dagConfigComplexDTO); + dagInstanceDTO.setInstanceId(UUIDUtil.randomUUId()); + dagInstanceDTO.setInputs(dagConfigComplexDTO.getDagAttrs()); + dagInstanceDTO.setStatus(WorkflowInstanceState.PENDING.getValue()); + dagInstanceDTO.setStartTime(new Date()); + Long dagInstanceId = dagInstanceService.insert(dagInstanceDTO); + // 插入 dag_step + if (CollectionUtils.isEmpty(dagConfigComplexDTO.getSteps()) == false) { + for (DagConfigStepDTO dagConfigStepDTO : dagConfigComplexDTO.getSteps()) { + DagStepDTO dagStepDTO = new DagStepDTO(); + dagStepDTO.setDagInstanceId(dagInstanceId); + dagStepDTO.setDagConfigStep(dagConfigStepDTO); + dagStepDTO.setInstanceId(UUIDUtil.randomUUId()); + dagStepDTO.setInputs(dagConfigStepDTO.getStepAttrs()); + dagStepDTO.setStatus(WorkflowTaskInstanceStage.PENDING.getValue()); + dagStepDTO.setStartTime(new Date()); + dagStepService.insert(dagStepDTO); + } + } + // 插入 dag_link + if (CollectionUtils.isEmpty(dagConfigComplexDTO.getLinks()) == false) { + for (DagConfigLinkDTO dagConfigLinkDTO : dagConfigComplexDTO.getLinks()) { + DagLinkDTO dagLinkDTO = new DagLinkDTO(); + dagLinkDTO.setDagInstanceId(dagInstanceId); + dagLinkDTO.setDagConfigLink(dagConfigLinkDTO); + dagLinkDTO.setInstanceId(UUIDUtil.randomUUId()); + dagLinkDTO.setInputs(dagConfigLinkDTO.getLinkAttrs()); + dagLinkDTO.setStatus(WorkflowTaskInstanceStage.PENDING.getValue()); + dagLinkDTO.setStartTime(new Date()); + dagLinkService.insert(dagLinkDTO); + } + } + return dagInstanceId; + } +} diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagInstanceServiceImpl.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagInstanceServiceImpl.java index 608d6b182..6c2daa3bb 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagInstanceServiceImpl.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagInstanceServiceImpl.java @@ -26,8 +26,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import java.util.List; - @Service public class DagInstanceServiceImpl implements DagInstanceService { @@ -35,8 +33,8 @@ public class DagInstanceServiceImpl implements DagInstanceService { private DagInstanceMapper dagInstanceMapper; @Override - public DagInstanceDTO selectOne(Long dagId) { - DagInstance record = dagInstanceMapper.selectById(dagId); + public DagInstanceDTO selectOne(Long dagInstanceId) { + DagInstance record = dagInstanceMapper.selectById(dagInstanceId); return DagInstanceConvert.INSTANCE.toDto(record); } @@ -52,35 +50,4 @@ public int update(DagInstanceDTO instanceDTO) { DagInstance record = DagInstanceConvert.INSTANCE.toDo(instanceDTO); return dagInstanceMapper.updateById(record); } - - @Override - public void upsert(DagInstanceDTO instanceDTO) { - if (instanceDTO.getId() != null) { - update(instanceDTO); - } else { - insert(instanceDTO); - } - } - - @Override - public int delete(Long dagId) { - return dagInstanceMapper.deleteById(dagId); - } - - @Override - public int deleteBatch(List dagIds) { - return dagInstanceMapper.deleteBatchIds(dagIds); - } - - @Override - public Long clone(Long dagId) { - DagInstanceDTO instanceDTO = selectOne(dagId); - instanceDTO.setId(null); - instanceDTO.setCreator(null); - instanceDTO.setCreateTime(null); - instanceDTO.setEditor(null); - instanceDTO.setUpdateTime(null); - dagInstanceMapper.insert(DagInstanceConvert.INSTANCE.toDo(instanceDTO)); - return instanceDTO.getId(); - } } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagLinkServiceImpl.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagLinkServiceImpl.java index de1843479..c132322d8 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagLinkServiceImpl.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagLinkServiceImpl.java @@ -18,17 +18,17 @@ package cn.sliew.scaleph.dag.service.impl; +import cn.sliew.scaleph.common.dict.workflow.WorkflowTaskInstanceStage; +import cn.sliew.scaleph.common.util.UUIDUtil; import cn.sliew.scaleph.dag.service.DagLinkService; import cn.sliew.scaleph.dag.service.convert.DagLinkConvert; +import cn.sliew.scaleph.dag.service.convert.DagLinkVOConvert; import cn.sliew.scaleph.dag.service.dto.DagLinkDTO; import cn.sliew.scaleph.dao.entity.master.dag.DagLink; +import cn.sliew.scaleph.dao.entity.master.dag.DagLinkVO; import cn.sliew.scaleph.dao.mapper.master.dag.DagLinkMapper; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; import java.util.List; @@ -39,74 +39,22 @@ public class DagLinkServiceImpl implements DagLinkService { private DagLinkMapper dagLinkMapper; @Override - public List listLinks(Long dagId) { - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DagLink.class) - .eq(DagLink::getDagId, dagId); - List dagLinks = dagLinkMapper.selectList(queryWrapper); - return DagLinkConvert.INSTANCE.toDto(dagLinks); + public List listLinks(Long dagInstanceId) { + List dagLinkVOS = dagLinkMapper.listByDagInstanceId(dagInstanceId); + return DagLinkVOConvert.INSTANCE.toDto(dagLinkVOS); } @Override public int insert(DagLinkDTO linkDTO) { DagLink record = DagLinkConvert.INSTANCE.toDo(linkDTO); + record.setInstanceId(UUIDUtil.randomUUId()); + record.setStatus(WorkflowTaskInstanceStage.PENDING.getValue()); return dagLinkMapper.insert(record); } @Override public int update(DagLinkDTO linkDTO) { - LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate(DagLink.class) - .eq(DagLink::getDagId, linkDTO.getDagId()) - .eq(DagLink::getLinkId, linkDTO.getLinkId()); DagLink record = DagLinkConvert.INSTANCE.toDo(linkDTO); - return dagLinkMapper.update(record, updateWrapper); - } - - @Override - public int upsert(DagLinkDTO linkDTO) { - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DagLink.class) - .eq(DagLink::getDagId, linkDTO.getDagId()) - .eq(DagLink::getLinkId, linkDTO.getLinkId()); - if (dagLinkMapper.exists(queryWrapper)) { - return update(linkDTO); - } else { - return insert(linkDTO); - } - } - - @Override - public int deleteByDag(Long dagId) { - LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate(DagLink.class) - .eq(DagLink::getDagId, dagId); - return dagLinkMapper.delete(updateWrapper); - } - - @Override - public int deleteByDag(List dagIds) { - LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate(DagLink.class) - .in(DagLink::getDagId, dagIds); - return dagLinkMapper.delete(updateWrapper); - } - - @Override - public int deleteSurplusLinks(Long dagId, List linkIds) { - LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate(DagLink.class) - .eq(DagLink::getDagId, dagId) - .notIn(CollectionUtils.isEmpty(linkIds) == false, DagLink::getLinkId, linkIds); - return dagLinkMapper.delete(updateWrapper); - } - - @Override - public int clone(Long sourceDagId, Long targetDagId) { - List sourceLinks = listLinks(sourceDagId); - sourceLinks.stream().forEach(linkDTO -> { - linkDTO.setDagId(targetDagId); - linkDTO.setId(null); - linkDTO.setCreator(null); - linkDTO.setCreateTime(null); - linkDTO.setEditor(null); - linkDTO.setUpdateTime(null); - dagLinkMapper.insert(DagLinkConvert.INSTANCE.toDo(linkDTO)); - }); - return sourceLinks.size(); + return dagLinkMapper.updateById(record); } } diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagServiceImpl.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagServiceImpl.java deleted file mode 100644 index 78d6031e8..000000000 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagServiceImpl.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * 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.scaleph.dag.service.impl; - -import cn.sliew.milky.common.util.JacksonUtil; -import cn.sliew.scaleph.dag.service.DagInstanceService; -import cn.sliew.scaleph.dag.service.DagLinkService; -import cn.sliew.scaleph.dag.service.DagService; -import cn.sliew.scaleph.dag.service.DagStepService; -import cn.sliew.scaleph.dag.service.dto.DagDTO; -import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; -import cn.sliew.scaleph.dag.service.dto.DagLinkDTO; -import cn.sliew.scaleph.dag.service.dto.DagStepDTO; -import cn.sliew.scaleph.dag.service.param.DagSimpleAddParam; -import cn.sliew.scaleph.dag.service.param.DagSimpleUpdateParam; -import cn.sliew.scaleph.dag.service.vo.DagGraphVO; -import cn.sliew.scaleph.dag.service.vo.EdgeCellVO; -import cn.sliew.scaleph.dag.service.vo.NodeCellVO; -import org.springframework.beans.BeanUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.stream.Collectors; - -@Service -public class DagServiceImpl implements DagService { - - @Autowired - private DagInstanceService dagInstanceService; - @Autowired - private DagLinkService dagLinkService; - @Autowired - private DagStepService dagStepService; - - @Override - public DagDTO selectOne(Long dagId) { - DagDTO dagDTO = new DagDTO(); - DagInstanceDTO instanceDTO = dagInstanceService.selectOne(dagId); - BeanUtils.copyProperties(instanceDTO, dagDTO); - dagDTO.setLinks(dagLinkService.listLinks(dagId)); - dagDTO.setSteps(dagStepService.listSteps(dagId)); - return dagDTO; - } - - @Override - public DagInstanceDTO selectSimpleOne(Long dagId) { - return dagInstanceService.selectOne(dagId); - } - - @Override - public Long insert(DagSimpleAddParam param) { - DagInstanceDTO instanceDTO = new DagInstanceDTO(); - BeanUtils.copyProperties(param, instanceDTO); - return dagInstanceService.insert(instanceDTO); - } - - @Override - public int update(DagSimpleUpdateParam param) { - DagInstanceDTO instanceDTO = new DagInstanceDTO(); - BeanUtils.copyProperties(param, instanceDTO); - return dagInstanceService.update(instanceDTO); - } - - @Override - public void replace(Long dagId, DagGraphVO graph) { - saveSteps(dagId, graph.getNodes()); - saveLinks(dagId, graph.getEdges()); - } - - private void saveSteps(Long dagId, List nodes) { - List stepIds = nodes.stream().map(NodeCellVO::getId) - .collect(Collectors.toList()); - dagStepService.deleteSurplusSteps(dagId, stepIds); - for (NodeCellVO node : nodes) { - DagStepDTO stepDTO = new DagStepDTO(); - stepDTO.setDagId(dagId); - stepDTO.setStepId(node.getId()); - if (node.getData() != null) { - stepDTO.setStepName(node.getData().getLabel()); - stepDTO.setStepMeta(JacksonUtil.toJsonNode(node.getData().getMeta())); - stepDTO.setStepAttrs(JacksonUtil.toJsonNode(node.getData().getAttrs())); - } - stepDTO.setPositionX(node.getPosition().getX()); - stepDTO.setPositionY(node.getPosition().getY()); - dagStepService.upsert(stepDTO); - } - } - - private void saveLinks(Long jobId, List edges) { - List linkIds = edges.stream().map(EdgeCellVO::getId) - .collect(Collectors.toList()); - dagLinkService.deleteSurplusLinks(jobId, linkIds); - for (EdgeCellVO edge : edges) { - DagLinkDTO linkDTO = new DagLinkDTO(); - linkDTO.setDagId(jobId); - linkDTO.setLinkId(edge.getId()); - if (edge.getData() != null) { - linkDTO.setLinkName(edge.getData().getLabel()); - linkDTO.setLinkMeta(JacksonUtil.toJsonNode(edge.getData().getMeta())); - linkDTO.setLinkAttrs(JacksonUtil.toJsonNode(edge.getData().getAttrs())); - } - linkDTO.setFromStepId(edge.getSource().getCell()); - linkDTO.setToStepId(edge.getTarget().getCell()); - dagLinkService.upsert(linkDTO); - } - } - - @Override - public Long clone(Long dagId) { - Long cloneDagId = dagInstanceService.clone(dagId); - dagLinkService.clone(dagId, cloneDagId); - dagStepService.clone(dagId, cloneDagId); - return cloneDagId; - } - - @Override - public int delete(Long dagId) { - dagLinkService.deleteByDag(dagId); - dagStepService.deleteByDag(dagId); - return dagInstanceService.delete(dagId); - } - - @Override - public int deleteBatch(List dagIds) { - dagLinkService.deleteByDag(dagIds); - dagStepService.deleteByDag(dagIds); - return dagInstanceService.deleteBatch(dagIds); - } -} diff --git a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagStepServiceImpl.java b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagStepServiceImpl.java index 1b6b7f42c..f7368c87e 100644 --- a/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagStepServiceImpl.java +++ b/scaleph-support/scaleph-dag/src/main/java/cn/sliew/scaleph/dag/service/impl/DagStepServiceImpl.java @@ -20,15 +20,13 @@ import cn.sliew.scaleph.dag.service.DagStepService; import cn.sliew.scaleph.dag.service.convert.DagStepConvert; +import cn.sliew.scaleph.dag.service.convert.DagStepVOConvert; import cn.sliew.scaleph.dag.service.dto.DagStepDTO; import cn.sliew.scaleph.dao.entity.master.dag.DagStep; +import cn.sliew.scaleph.dao.entity.master.dag.DagStepVO; import cn.sliew.scaleph.dao.mapper.master.dag.DagStepMapper; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; import java.util.List; @@ -41,17 +39,15 @@ public class DagStepServiceImpl implements DagStepService { private DagStepMapper dagStepMapper; @Override - public List listSteps(Long dagId) { - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DagStep.class) - .eq(DagStep::getDagId, dagId); - List dagSteps = dagStepMapper.selectList(queryWrapper); - return DagStepConvert.INSTANCE.toDto(dagSteps); + public List listSteps(Long dagInstanceId) { + List dagStepVOS = dagStepMapper.listByDagInstanceId(dagInstanceId); + return DagStepVOConvert.INSTANCE.toDto(dagStepVOS); } @Override - public DagStepDTO selectOne(Long stepId) { - DagStep record = dagStepMapper.selectById(stepId); - checkState(record != null, () -> "dag step not exists for id: " + stepId); + public DagStepDTO selectOne(Long id) { + DagStep record = dagStepMapper.selectById(id); + checkState(record != null, () -> "dag step not exists for id: " + id); return DagStepConvert.INSTANCE.toDto(record); } @@ -63,59 +59,7 @@ public int insert(DagStepDTO stepDTO) { @Override public int update(DagStepDTO stepDTO) { - LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate(DagStep.class) - .eq(DagStep::getDagId, stepDTO.getDagId()) - .eq(DagStep::getStepId, stepDTO.getStepId()); DagStep record = DagStepConvert.INSTANCE.toDo(stepDTO); - return dagStepMapper.update(record, updateWrapper); - } - - @Override - public int upsert(DagStepDTO stepDTO) { - LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(DagStep.class) - .eq(DagStep::getDagId, stepDTO.getDagId()) - .eq(DagStep::getStepId, stepDTO.getStepId()); - if (dagStepMapper.exists(queryWrapper)) { - return update(stepDTO); - } else { - return insert(stepDTO); - } - } - - @Override - public int deleteByDag(Long dagId) { - LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate(DagStep.class) - .eq(DagStep::getDagId, dagId); - return dagStepMapper.delete(updateWrapper); - } - - @Override - public int deleteByDag(List dagIds) { - LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate(DagStep.class) - .in(DagStep::getDagId, dagIds); - return dagStepMapper.delete(updateWrapper); - } - - @Override - public int deleteSurplusSteps(Long dagId, List stepIds) { - LambdaUpdateWrapper updateWrapper = Wrappers.lambdaUpdate(DagStep.class) - .eq(DagStep::getDagId, dagId) - .notIn(CollectionUtils.isEmpty(stepIds) == false, DagStep::getStepId, stepIds); - return dagStepMapper.delete(updateWrapper); - } - - @Override - public int clone(Long sourceDagId, Long targetDagId) { - List sourceSteps = listSteps(sourceDagId); - sourceSteps.forEach(stepDTO -> { - stepDTO.setDagId(targetDagId); - stepDTO.setId(null); - stepDTO.setCreator(null); - stepDTO.setCreateTime(null); - stepDTO.setEditor(null); - stepDTO.setUpdateTime(null); - dagStepMapper.insert(DagStepConvert.INSTANCE.toDo(stepDTO)); - }); - return sourceSteps.size(); + return dagStepMapper.updateById(record); } } diff --git a/scaleph-support/scaleph-generator/src/main/java/cn/sliew/scaleph/generator/MybatisPlusGenerator.java b/scaleph-support/scaleph-generator/src/main/java/cn/sliew/scaleph/generator/MybatisPlusGenerator.java index 391bb3e0a..72d023c7a 100644 --- a/scaleph-support/scaleph-generator/src/main/java/cn/sliew/scaleph/generator/MybatisPlusGenerator.java +++ b/scaleph-support/scaleph-generator/src/main/java/cn/sliew/scaleph/generator/MybatisPlusGenerator.java @@ -54,7 +54,7 @@ public class MybatisPlusGenerator { /** * just add table names here and run the {@link #main(String[])} method. */ - private static final String[] TABLES = {"oam_component_definition", "oam_workload_definition", "oam_policy_definition", "oam_trait_definition"}; + private static final String[] TABLES = {"dag_instance", "dag_link", "dag_step"}; public static void main(String[] args) { //自动生成配置 diff --git a/scaleph-ui-react/package.json b/scaleph-ui-react/package.json index 55029a4ca..bb73f9c9f 100644 --- a/scaleph-ui-react/package.json +++ b/scaleph-ui-react/package.json @@ -1,6 +1,6 @@ { "name": "scaleph", - "version": "2.0.3", + "version": "2.0.4", "private": true, "description": "Scaleph", "scripts": { @@ -48,7 +48,7 @@ "dependencies": { "@ant-design/icons": "^4.7.0", "@ant-design/pro-components": "^2.3.47", - "@antv/xflow": "^2.0.3", + "@antv/xflow": "^2.0.4", "@antv/xflow-diff": "^1.0.0", "@antv/layout": "^0.3.2", "@antv/x6-react-components": "^2.0.8", diff --git a/scaleph-ui-react/src/pages/Metadata/DataSource/Info/StepForms/DataSourceType.tsx b/scaleph-ui-react/src/pages/Metadata/DataSource/Info/StepForms/DataSourceType.tsx index b41d71011..74678e0d8 100644 --- a/scaleph-ui-react/src/pages/Metadata/DataSource/Info/StepForms/DataSourceType.tsx +++ b/scaleph-ui-react/src/pages/Metadata/DataSource/Info/StepForms/DataSourceType.tsx @@ -23,6 +23,12 @@ const DataSourceTypeWeb: React.FC<{ categoryId?: number, onTypeSelect: () => voi }, [categoryId, searchValue]) const metas: ProListMetas = { + title: { + dataIndex: "type", + render: (dom, entity, index, action, schema) => { + return entity.type.label + } + }, content: { dataIndex: "logo", render: (dom, entity, index, action, schema) => { @@ -50,6 +56,7 @@ const DataSourceTypeWeb: React.FC<{ categoryId?: number, onTypeSelect: () => voi }} pagination={false} grid={{gutter: 8, column: 6}} + split={true} onItem={(record) => { return { onClick: () => { diff --git a/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/dnd/dnd.tsx b/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/dnd/dnd.tsx index 7d91458c9..4979e3221 100644 --- a/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/dnd/dnd.tsx +++ b/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/dnd/dnd.tsx @@ -2,13 +2,11 @@ import React, {useEffect, useState} from 'react'; import {Tree} from 'antd'; import SearchInput from './search'; import {Props} from "@/typings"; -import {WsArtifactSeaTunnel, WsDiJob} from "@/services/project/typings"; +import {WsArtifactSeaTunnel} from "@/services/project/typings"; import {WsArtifactSeaTunnelService} from "@/services/project/WsArtifactSeaTunnelService"; import styles from './dnd.less'; import {DndNode} from "../node/dnd-node"; -const {DirectoryTree} = Tree; - type ComponentTreeItem = { category: string; docString: string; @@ -66,10 +64,11 @@ const Dnd: React.FC> = ({data}) => { /> {treeItems.length && ( - treeNodeRender(node)} treeData={searchComponents.length ? searchComponents : treeItems} diff --git a/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/node/dnd-node.tsx b/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/node/dnd-node.tsx index 91fa96049..535e4b9f4 100644 --- a/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/node/dnd-node.tsx +++ b/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/node/dnd-node.tsx @@ -3,7 +3,7 @@ import {Button, Descriptions, Popover, Space, Tag, Typography} from 'antd'; import {HolderOutlined, InfoCircleOutlined, MenuOutlined} from '@ant-design/icons'; import {useIntl} from "@umijs/max"; import {useDnd} from "@antv/xflow"; -import {Props} from "@/typings"; +import {Dict, Props} from "@/typings"; import {DAG_NODE} from "./canvas-node"; import './base-node.less'; import {titleCase} from "./init-node"; @@ -49,7 +49,7 @@ export const DndNode: React.FC>> = ({data}) => { {data.health && {data.health?.label}} {data.features && - data.features.map((item) => { + data.features.map((item: Dict) => { return {item.label}; })} diff --git a/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/toolbar/index.tsx b/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/toolbar/index.tsx index e637253b7..73b6ce829 100644 --- a/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/toolbar/index.tsx +++ b/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/components/toolbar/index.tsx @@ -17,15 +17,19 @@ const CustomToolbar: React.FC = () => { const graph = useGraphInstance(); const {copy, paste} = useClipboard(); const nodes = useGraphStore((state) => state.nodes); + const edges = useGraphStore((state) => state.edges); const removeNodes = useGraphStore((state) => state.removeNodes); const removeEdges = useGraphStore((state) => state.removeEdges); useKeyboard('ctrl+c', () => onCopy()); useKeyboard('ctrl+v', () => onPaste()); - useKeyboard('backspace', () => { - const selected = nodes.filter((node) => node.selected); - const nodeIds: string[] = selected.map((node) => node.id || ''); + useKeyboard('backspace', (e: KeyboardEvent) => { + const selectedNodes = nodes.filter((node) => node.selected); + const nodeIds: string[] = selectedNodes.map((node) => node.id || ''); removeNodes(nodeIds); + const selectedEdges = edges.filter((edge) => edge.selected); + const edgeIds: string[] = selectedEdges.map((edge) => edge.id || ''); + removeEdges(edgeIds); }); useGraphEvent('node:change:data', ({node}) => { diff --git a/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/index.tsx b/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/index.tsx index 783a5201b..48fb235f1 100644 --- a/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/index.tsx +++ b/scaleph-ui-react/src/pages/Project/Workspace/DataIntegration/SeaTunnel/Dag/index.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, {useEffect} from 'react'; import {PageContainer} from '@ant-design/pro-components'; import {useLocation} from '@umijs/max'; import { diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/engine/workflow/WorkFlow.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/engine/workflow/WorkFlow.java index 02b45aaee..fd18a3158 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/engine/workflow/WorkFlow.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/engine/workflow/WorkFlow.java @@ -18,9 +18,8 @@ package cn.sliew.scaleph.workflow.engine.workflow; -import cn.sliew.scaleph.plugin.framework.lifecycle.LifeCycle; import cn.sliew.scaleph.workflow.engine.action.Action; -public interface WorkFlow extends Action, LifeCycle { +public interface WorkFlow extends Action { } diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/model/Namespace.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/model/Namespace.java deleted file mode 100644 index f812bd6df..000000000 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/model/Namespace.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.scaleph.workflow.model; - -public interface Namespace { - - String getName(); -} diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/WorkflowDefinitionService.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/WorkflowDefinitionService.java index a58edb676..1857669c4 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/WorkflowDefinitionService.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/WorkflowDefinitionService.java @@ -19,7 +19,7 @@ package cn.sliew.scaleph.workflow.service; import cn.sliew.scaleph.workflow.service.dto.WorkflowDefinitionDTO; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO2; +import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO; import cn.sliew.scaleph.workflow.service.param.WorkflowDefinitionListParam; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.graph.Graph; @@ -30,8 +30,8 @@ public interface WorkflowDefinitionService { WorkflowDefinitionDTO get(Long id); - Graph getDag(Long id); + Graph getDag(Long id); - WorkflowTaskDefinitionDTO2 getTaskDefinition(Long workflowTaskDefinitionId); + WorkflowTaskDefinitionDTO getTaskDefinition(Long workflowTaskDefinitionId); } diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/WorkflowTaskInstanceService.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/WorkflowTaskInstanceService.java index 6eaad3e6e..3280039b0 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/WorkflowTaskInstanceService.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/WorkflowTaskInstanceService.java @@ -19,7 +19,7 @@ package cn.sliew.scaleph.workflow.service; import cn.sliew.scaleph.common.dict.workflow.WorkflowTaskInstanceStage; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO2; +import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO; import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskInstanceDTO; import cn.sliew.scaleph.workflow.service.param.WorkflowTaskInstanceListParam; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -33,7 +33,7 @@ public interface WorkflowTaskInstanceService { List list(Long workflowInstanceId); - Graph getDag(Long workflowInstanceId, Graph dag); + Graph getDag(Long workflowInstanceId, Graph dag); WorkflowTaskInstanceDTO get(Long id); @@ -45,7 +45,7 @@ public interface WorkflowTaskInstanceService { void updateTaskId(Long id, String taskId); - Graph initialize(Long workflowInstanceId, Graph graph); + Graph initialize(Long workflowInstanceId, Graph graph); void deploy(Long id); diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowInstanceConvert.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowInstanceConvert.java index 2562975ca..76de58965 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowInstanceConvert.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowInstanceConvert.java @@ -27,6 +27,7 @@ import org.mapstruct.factory.Mappers; import org.springframework.beans.BeanUtils; +@Deprecated @Mapper(uses = {}, unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface WorkflowInstanceConvert extends BaseConvert { WorkflowInstanceConvert INSTANCE = Mappers.getMapper(WorkflowInstanceConvert.class); diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowInstanceVOConvert.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowInstanceVOConvert.java index 82098bc1c..f4eba4bee 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowInstanceVOConvert.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowInstanceVOConvert.java @@ -26,6 +26,7 @@ import org.mapstruct.factory.Mappers; import org.springframework.beans.BeanUtils; +@Deprecated @Mapper(uses = {}, unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface WorkflowInstanceVOConvert extends BaseConvert { WorkflowInstanceVOConvert INSTANCE = Mappers.getMapper(WorkflowInstanceVOConvert.class); diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowTaskDefinition2Convert.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowTaskDefitionConvert.java similarity index 83% rename from scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowTaskDefinition2Convert.java rename to scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowTaskDefitionConvert.java index 498da0bb5..96957d0c5 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowTaskDefinition2Convert.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowTaskDefitionConvert.java @@ -22,7 +22,7 @@ import cn.sliew.scaleph.common.convert.BaseConvert; import cn.sliew.scaleph.dag.service.dto.DagConfigStepDTO; import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionAttrs; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO2; +import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO; import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionMeta; import com.fasterxml.jackson.databind.node.ObjectNode; import org.mapstruct.Mapper; @@ -31,11 +31,11 @@ import org.springframework.beans.BeanUtils; @Mapper(uses = {}, unmappedTargetPolicy = ReportingPolicy.IGNORE) -public interface WorkflowTaskDefinition2Convert extends BaseConvert { - WorkflowTaskDefinition2Convert INSTANCE = Mappers.getMapper(WorkflowTaskDefinition2Convert.class); +public interface WorkflowTaskDefitionConvert extends BaseConvert { + WorkflowTaskDefitionConvert INSTANCE = Mappers.getMapper(WorkflowTaskDefitionConvert.class); @Override - default DagConfigStepDTO toDo(WorkflowTaskDefinitionDTO2 dto) { + default DagConfigStepDTO toDo(WorkflowTaskDefinitionDTO dto) { DagConfigStepDTO entity = new DagConfigStepDTO(); BeanUtils.copyProperties(dto, entity); ObjectNode stepMeta = (ObjectNode) JacksonUtil.toJsonNode(dto.getStepMeta()); @@ -46,8 +46,8 @@ default DagConfigStepDTO toDo(WorkflowTaskDefinitionDTO2 dto) { } @Override - default WorkflowTaskDefinitionDTO2 toDto(DagConfigStepDTO entity) { - WorkflowTaskDefinitionDTO2 dto = new WorkflowTaskDefinitionDTO2(); + default WorkflowTaskDefinitionDTO toDto(DagConfigStepDTO entity) { + WorkflowTaskDefinitionDTO dto = new WorkflowTaskDefinitionDTO(); BeanUtils.copyProperties(entity, dto); dto.setStepMeta(JacksonUtil.toObject(entity.getStepMeta(), WorkflowTaskDefinitionMeta.class)); dto.setStepAttrs(JacksonUtil.toObject(entity.getStepMeta(), WorkflowTaskDefinitionAttrs.class)); diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowTaskInstanceConvert.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowTaskInstanceConvert.java index d9b3e506c..6ebec85f0 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowTaskInstanceConvert.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/convert/WorkflowTaskInstanceConvert.java @@ -27,6 +27,7 @@ import org.mapstruct.factory.Mappers; import org.springframework.beans.BeanUtils; +@Deprecated @Mapper(uses = {}, unmappedTargetPolicy = ReportingPolicy.IGNORE) public interface WorkflowTaskInstanceConvert extends BaseConvert { WorkflowTaskInstanceConvert INSTANCE = Mappers.getMapper(WorkflowTaskInstanceConvert.class); @@ -35,9 +36,6 @@ public interface WorkflowTaskInstanceConvert extends BaseConvert { WorkflowTaskInstanceVOConvert INSTANCE = Mappers.getMapper(WorkflowTaskInstanceVOConvert.class); @@ -34,7 +35,6 @@ public interface WorkflowTaskInstanceVOConvert extends BaseConvert param; - - @Schema(description = "备注") - private String remark; } diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskDefinitionDTO2.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskDefinitionDTO.java similarity index 96% rename from scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskDefinitionDTO2.java rename to scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskDefinitionDTO.java index 2572dd48b..c5eac7e4b 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskDefinitionDTO2.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskDefinitionDTO.java @@ -23,7 +23,7 @@ import lombok.Data; @Data -public class WorkflowTaskDefinitionDTO2 extends BaseDTO { +public class WorkflowTaskDefinitionDTO extends BaseDTO { @Schema(description = "workflow definition id") private Long workflowDefinitionId; diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskDefinitionMeta.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskDefinitionMeta.java index eaa518237..bd73411f5 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskDefinitionMeta.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskDefinitionMeta.java @@ -30,4 +30,10 @@ public class WorkflowTaskDefinitionMeta { @Schema(description = "workflow task handler") private String handler; + + @Schema(description = "refered workflow definition id") + private Long referenceWorkflowDefinitionId; + + @Schema(description = "备注") + private String remark; } diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/model/Trigger.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskInstanceAttrs.java similarity index 67% rename from scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/model/Trigger.java rename to scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskInstanceAttrs.java index e582b6d79..03ae62600 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/model/Trigger.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskInstanceAttrs.java @@ -16,8 +16,19 @@ * limitations under the License. */ -package cn.sliew.scaleph.workflow.model; +package cn.sliew.scaleph.workflow.service.dto; -public interface Trigger { +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import java.util.Map; + +@Data +public class WorkflowTaskInstanceAttrs { + + @Schema(description = "workflow task input params") + private Map inputs; + + @Schema(description = "workflow task output params") + private Map outputs; } diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskInstanceDTO.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskInstanceDTO.java index 9c93fe15a..2f61e8596 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskInstanceDTO.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskInstanceDTO.java @@ -30,25 +30,9 @@ @EqualsAndHashCode public class WorkflowTaskInstanceDTO extends BaseDTO { - @Schema(description = "workflow instance") - private WorkflowInstanceDTO workflowInstanceDTO; @Schema(description = "step id") private Long stepId; - @Schema(description = "task id") - private String taskId; - - @Schema(description = "workflow task instance state") - private WorkflowTaskInstanceStage stage; - - @Schema(description = "workflow task instance start time") - private Date startTime; - - @Schema(description = "workflow task instance end time") - private Date endTime; - - @Schema(description = "workflow task instance message") - private String message; } diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/model/Scheduler.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskInstanceMeta.java similarity index 54% rename from scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/model/Scheduler.java rename to scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskInstanceMeta.java index 82704c949..de409a565 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/model/Scheduler.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/dto/WorkflowTaskInstanceMeta.java @@ -16,8 +16,29 @@ * limitations under the License. */ -package cn.sliew.scaleph.workflow.model; +package cn.sliew.scaleph.workflow.service.dto; -public interface Scheduler { +import cn.sliew.scaleph.system.model.BaseDTO; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import java.util.Date; + +@Data +public class WorkflowTaskInstanceMeta extends BaseDTO { + + @Schema(description = "task id") + private String taskId; + + @Schema(description = "workflow task instance state") + private String stage; + + @Schema(description = "workflow task instance start time") + private Date startTime; + + @Schema(description = "workflow task instance end time") + private Date endTime; + + @Schema(description = "workflow task instance message") + private String message; } diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/impl/WorkflowDefinitionServiceImpl.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/impl/WorkflowDefinitionServiceImpl.java index 0587b8fc9..f39fbf7b0 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/impl/WorkflowDefinitionServiceImpl.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/impl/WorkflowDefinitionServiceImpl.java @@ -27,9 +27,9 @@ import cn.sliew.scaleph.workflow.service.WorkflowDagService; import cn.sliew.scaleph.workflow.service.WorkflowDefinitionService; import cn.sliew.scaleph.workflow.service.convert.WorkflowDefinitionVOConvert; -import cn.sliew.scaleph.workflow.service.convert.WorkflowTaskDefinition2Convert; +import cn.sliew.scaleph.workflow.service.convert.WorkflowTaskDefitionConvert; import cn.sliew.scaleph.workflow.service.dto.WorkflowDefinitionDTO; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO2; +import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO; import cn.sliew.scaleph.workflow.service.param.WorkflowDefinitionListParam; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.google.common.graph.Graph; @@ -73,22 +73,22 @@ public WorkflowDefinitionDTO get(Long id) { } @Override - public Graph getDag(Long id) { + public Graph getDag(Long id) { WorkflowDefinitionDTO workflowDefinitionDTO = get(id); DagConfigComplexDTO dag = workflowDefinitionDTO.getDag(); return buildGraph(id, dag); } - private MutableGraph buildGraph(Long id, DagConfigComplexDTO dag) { - MutableGraph graph = GraphBuilder.directed().build(); + private MutableGraph buildGraph(Long id, DagConfigComplexDTO dag) { + MutableGraph graph = GraphBuilder.directed().build(); List steps = dag.getSteps(); List links = dag.getLinks(); if (CollectionUtils.isEmpty(steps)) { return graph; } - Map stepMap = new HashMap<>(); + Map stepMap = new HashMap<>(); for (DagConfigStepDTO step : steps) { - WorkflowTaskDefinitionDTO2 taskDefinitionDTO = WorkflowTaskDefinition2Convert.INSTANCE.toDto(step); + WorkflowTaskDefinitionDTO taskDefinitionDTO = WorkflowTaskDefitionConvert.INSTANCE.toDto(step); taskDefinitionDTO.setWorkflowDefinitionId(id); graph.addNode(taskDefinitionDTO); stepMap.put(taskDefinitionDTO.getStepId(), taskDefinitionDTO); @@ -98,8 +98,8 @@ private MutableGraph buildGraph(Long id, DagConfigCo } @Override - public WorkflowTaskDefinitionDTO2 getTaskDefinition(Long workflowTaskDefinitionId) { + public WorkflowTaskDefinitionDTO getTaskDefinition(Long workflowTaskDefinitionId) { DagConfigStepDTO step = workflowDagService.getStep(workflowTaskDefinitionId); - return WorkflowTaskDefinition2Convert.INSTANCE.toDto(step); + return WorkflowTaskDefitionConvert.INSTANCE.toDto(step); } } diff --git a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/impl/WorkflowTaskInstanceServiceImpl.java b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/impl/WorkflowTaskInstanceServiceImpl.java index ce28d754e..cb03aac6e 100644 --- a/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/impl/WorkflowTaskInstanceServiceImpl.java +++ b/scaleph-workflow/scaleph-workflow-api/src/main/java/cn/sliew/scaleph/workflow/service/impl/WorkflowTaskInstanceServiceImpl.java @@ -27,7 +27,7 @@ import cn.sliew.scaleph.workflow.service.WorkflowTaskInstanceService; import cn.sliew.scaleph.workflow.service.convert.WorkflowTaskInstanceConvert; import cn.sliew.scaleph.workflow.service.convert.WorkflowTaskInstanceVOConvert; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO2; +import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO; import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskInstanceDTO; import cn.sliew.scaleph.workflow.service.param.WorkflowTaskInstanceListParam; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -75,7 +75,7 @@ public List list(Long workflowInstanceId) { } @Override - public Graph getDag(Long workflowInstanceId, Graph dag) { + public Graph getDag(Long workflowInstanceId, Graph dag) { List workflowTaskInstanceDTOS = list(workflowInstanceId); MutableGraph graph = GraphBuilder.directed().build(); Map stepMap = new HashMap<>(); @@ -83,9 +83,9 @@ public Graph getDag(Long workflowInstanceId, Graph edge : dag.edges()) { - WorkflowTaskDefinitionDTO2 source = edge.source(); - WorkflowTaskDefinitionDTO2 target = edge.target(); + for (EndpointPair edge : dag.edges()) { + WorkflowTaskDefinitionDTO source = edge.source(); + WorkflowTaskDefinitionDTO target = edge.target(); graph.putEdge(stepMap.get(source.getId()), stepMap.get(target.getId())); } return graph; @@ -140,9 +140,9 @@ public void updateTaskId(Long id, String taskId) { } @Override - public Graph initialize(Long workflowInstanceId, Graph graph) { + public Graph initialize(Long workflowInstanceId, Graph graph) { try { - for (WorkflowTaskDefinitionDTO2 node : graph.nodes()) { + for (WorkflowTaskDefinitionDTO node : graph.nodes()) { createWorkflowTaskInstance(workflowInstanceId, node); } return getDag(workflowInstanceId, graph); @@ -152,7 +152,7 @@ public Graph initialize(Long workflowInstanceId, Graph< return null; } - private WorkflowTaskInstanceDTO createWorkflowTaskInstance(Long workflowInstanceId, WorkflowTaskDefinitionDTO2 node) { + private WorkflowTaskInstanceDTO createWorkflowTaskInstance(Long workflowInstanceId, WorkflowTaskDefinitionDTO node) { WorkflowTaskInstance record = new WorkflowTaskInstance(); record.setWorkflowInstanceId(workflowInstanceId); record.setStepId(node.getId()); diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/AbstractWorkflowTaskInstanceEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/AbstractWorkflowTaskInstanceEventListener.java index afe11d4a2..eaca5c3b4 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/AbstractWorkflowTaskInstanceEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/AbstractWorkflowTaskInstanceEventListener.java @@ -18,7 +18,8 @@ package cn.sliew.scaleph.workflow.simple.listener.taskinstance; -import cn.sliew.scaleph.workflow.service.WorkflowTaskInstanceService; +import cn.sliew.scaleph.dag.service.DagInstanceComplexService; +import cn.sliew.scaleph.dag.service.DagStepService; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowInstanceStateMachine; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowTaskInstanceStateMachine; import lombok.extern.slf4j.Slf4j; @@ -40,7 +41,9 @@ public abstract class AbstractWorkflowTaskInstanceEventListener implements Workf protected RScheduledExecutorService executorService; @Autowired - protected WorkflowTaskInstanceService workflowTaskInstanceService; + protected DagInstanceComplexService dagInstanceComplexService; + @Autowired + protected DagStepService dagStepService; @Autowired protected WorkflowInstanceStateMachine workflowInstanceStateMachine; @Autowired @@ -69,7 +72,7 @@ public void onEvent(WorkflowTaskInstanceEventDTO event) { } protected void onFailure(Long workflowTaskInstanceId, Throwable throwable) { - stateMachine.onFailure(workflowTaskInstanceService.get(workflowTaskInstanceId), throwable); + stateMachine.onFailure(dagStepService.selectOne(workflowTaskInstanceId), throwable); } protected abstract CompletableFuture handleEventAsync(WorkflowTaskInstanceEventDTO event); diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceDeployEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceDeployEventListener.java index ab72264da..4f0a23b92 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceDeployEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceDeployEventListener.java @@ -20,7 +20,12 @@ import cn.sliew.milky.common.exception.Rethrower; import cn.sliew.milky.common.filter.ActionListener; +import cn.sliew.milky.common.util.JacksonUtil; import cn.sliew.scaleph.common.util.SpringApplicationContextUtil; +import cn.sliew.scaleph.dag.service.DagConfigStepService; +import cn.sliew.scaleph.dag.service.DagStepService; +import cn.sliew.scaleph.dag.service.dto.DagConfigStepDTO; +import cn.sliew.scaleph.dag.service.dto.DagStepDTO; import cn.sliew.scaleph.queue.MessageListener; import cn.sliew.scaleph.workflow.engine.Engine; import cn.sliew.scaleph.workflow.engine.EngineBuilder; @@ -30,10 +35,7 @@ import cn.sliew.scaleph.workflow.engine.action.ActionResult; import cn.sliew.scaleph.workflow.engine.workflow.ParallelFlow; import cn.sliew.scaleph.workflow.engine.workflow.WorkFlow; -import cn.sliew.scaleph.workflow.service.WorkflowDefinitionService; -import cn.sliew.scaleph.workflow.service.WorkflowTaskInstanceService; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO2; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskInstanceDTO; +import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionMeta; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowTaskInstanceStateMachine; import lombok.extern.slf4j.Slf4j; import org.redisson.api.annotation.RInject; @@ -41,6 +43,7 @@ import org.springframework.util.ClassUtils; import java.io.Serializable; +import java.util.Date; import java.util.concurrent.CompletableFuture; @MessageListener(topic = WorkflowTaskInstanceDeployEventListener.TOPIC, consumerGroup = WorkflowTaskInstanceStateMachine.CONSUMER_GROUP) @@ -57,7 +60,7 @@ protected CompletableFuture handleEventAsync(WorkflowTaskInstanceEventDTO event) if (throwable != null) { onFailure(event.getWorkflowTaskInstanceId(), throwable); } else { - stateMachine.onSuccess(workflowTaskInstanceService.get(event.getWorkflowTaskInstanceId())); + stateMachine.onSuccess(dagStepService.selectOne(event.getWorkflowTaskInstanceId())); } }); return future; @@ -71,9 +74,9 @@ public static class DeployRunner implements Runnable, Serializable { @RInject private String taskId; @Autowired - private WorkflowDefinitionService workflowDefinitionService; + private DagConfigStepService dagConfigStepService; @Autowired - private WorkflowTaskInstanceService workflowTaskInstanceService; + private DagStepService dagStepService; public DeployRunner(WorkflowTaskInstanceEventDTO event) { this.event = event; @@ -81,29 +84,33 @@ public DeployRunner(WorkflowTaskInstanceEventDTO event) { @Override public void run() { - workflowTaskInstanceService.updateTaskId(event.getWorkflowTaskInstanceId(), taskId); - workflowTaskInstanceService.updateState(event.getWorkflowTaskInstanceId(), event.getState(), event.getNextState(), null); - WorkflowTaskInstanceDTO workflowTaskInstanceDTO = workflowTaskInstanceService.get(event.getWorkflowTaskInstanceId()); - WorkflowTaskDefinitionDTO2 taskDefinition = workflowDefinitionService.getTaskDefinition(workflowTaskInstanceDTO.getStepId()); + DagStepDTO dagStepUpdateParam = new DagStepDTO(); + dagStepUpdateParam.setId(event.getWorkflowTaskInstanceId()); + dagStepUpdateParam.setStatus(event.getNextState().getValue()); + dagStepUpdateParam.setStartTime(new Date()); + dagStepService.update(dagStepUpdateParam); + DagStepDTO stepDTO = dagStepService.selectOne(event.getWorkflowTaskInstanceId()); + DagConfigStepDTO configStepDTO = dagConfigStepService.selectOne(stepDTO.getDagConfigStep().getId()); + WorkflowTaskDefinitionMeta workflowTaskDefinitionMeta = JacksonUtil.toObject(configStepDTO.getStepMeta(), WorkflowTaskDefinitionMeta.class); try { - Class clazz = ClassUtils.forName(taskDefinition.getStepMeta().getHandler(), ClassUtils.getDefaultClassLoader()); + Class clazz = ClassUtils.forName(workflowTaskDefinitionMeta.getHandler(), ClassUtils.getDefaultClassLoader()); Action action = (Action) SpringApplicationContextUtil.getBean(clazz); WorkFlow workFlow = ParallelFlow.newParallelFlow() - .name(taskDefinition.getStepName()) + .name(configStepDTO.getStepName()) .execute(action) .build(); - ActionContext actionContext = buildActionContext(workflowTaskInstanceDTO); + ActionContext actionContext = buildActionContext(stepDTO); engine.run(workFlow, actionContext, new ActionListener() { @Override public void onResponse(ActionResult result) { - log.debug("workflow task {} run success!", taskDefinition.getStepName()); + log.debug("workflow task {} run success!", configStepDTO.getStepName()); } @Override public void onFailure(Throwable e) { - log.error("workflow task {} run failure!", taskDefinition.getStepName(), e); + log.error("workflow task {} run failure!", configStepDTO.getStepName(), e); } }); } catch (ClassNotFoundException e) { @@ -111,12 +118,11 @@ public void onFailure(Throwable e) { } } - private ActionContext buildActionContext(WorkflowTaskInstanceDTO workflowTaskInstanceDTO) { + private ActionContext buildActionContext(DagStepDTO stepDTO) { return ActionContextBuilder.newBuilder() - .withWorkflowDefinitionId(workflowTaskInstanceDTO.getWorkflowInstanceDTO().getWorkflowDefinition().getId()) - .withWorkflowInstanceId(workflowTaskInstanceDTO.getWorkflowInstanceDTO().getId()) - .withWorkflowTaskDefinitionId(workflowTaskInstanceDTO.getStepId()) - .withWorkflowTaskInstanceId(workflowTaskInstanceDTO.getId()) + .withWorkflowInstanceId(stepDTO.getDagInstanceId()) + .withWorkflowTaskDefinitionId(stepDTO.getDagConfigStep().getId()) + .withWorkflowTaskInstanceId(stepDTO.getId()) .validateAndBuild(); } } diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceFailureEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceFailureEventListener.java index 7e66482e0..69557bb7a 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceFailureEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceFailureEventListener.java @@ -18,11 +18,14 @@ package cn.sliew.scaleph.workflow.simple.listener.taskinstance; +import cn.sliew.scaleph.common.dict.workflow.WorkflowTaskInstanceStage; +import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; +import cn.sliew.scaleph.dag.service.dto.DagStepDTO; import cn.sliew.scaleph.queue.MessageListener; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskInstanceDTO; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowTaskInstanceStateMachine; import java.io.Serializable; +import java.util.Date; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -48,9 +51,15 @@ public FailureRunner(Long workflowTaskInstanceId, Throwable throwable) { @Override public void run() { - workflowTaskInstanceService.updateFailure(workflowTaskInstanceId, throwable.orElse(null)); - WorkflowTaskInstanceDTO workflowTaskInstanceDTO = workflowTaskInstanceService.get(workflowTaskInstanceId); - workflowInstanceStateMachine.onTaskChange(workflowTaskInstanceDTO.getWorkflowInstanceDTO()); + DagStepDTO dagStepUpdateParam = new DagStepDTO(); + dagStepUpdateParam.setId(workflowTaskInstanceId); + dagStepUpdateParam.setStatus(WorkflowTaskInstanceStage.FAILURE.getValue()); + dagStepUpdateParam.setEndTime(new Date()); + dagStepService.update(dagStepUpdateParam); + + DagStepDTO stepDTO = dagStepService.selectOne(workflowTaskInstanceId); + DagInstanceDTO instanceDTO = dagInstanceComplexService.selectSimpleOne(stepDTO.getDagInstanceId()); + workflowInstanceStateMachine.onTaskChange(instanceDTO); } } diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceSuccessEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceSuccessEventListener.java index 666f1fb45..4d7dc86d7 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceSuccessEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/taskinstance/WorkflowTaskInstanceSuccessEventListener.java @@ -18,11 +18,14 @@ package cn.sliew.scaleph.workflow.simple.listener.taskinstance; +import cn.sliew.scaleph.common.dict.workflow.WorkflowTaskInstanceStage; +import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; +import cn.sliew.scaleph.dag.service.dto.DagStepDTO; import cn.sliew.scaleph.queue.MessageListener; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskInstanceDTO; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowTaskInstanceStateMachine; import java.io.Serializable; +import java.util.Date; import java.util.concurrent.CompletableFuture; @MessageListener(topic = WorkflowTaskInstanceSuccessEventListener.TOPIC, consumerGroup = WorkflowTaskInstanceStateMachine.CONSUMER_GROUP) @@ -45,9 +48,15 @@ public SuccessRunner(Long workflowTaskInstanceId) { @Override public void run() { - workflowTaskInstanceService.updateSuccess(workflowTaskInstanceId); - WorkflowTaskInstanceDTO workflowTaskInstanceDTO = workflowTaskInstanceService.get(workflowTaskInstanceId); - workflowInstanceStateMachine.onTaskChange(workflowTaskInstanceDTO.getWorkflowInstanceDTO()); + DagStepDTO dagStepUpdateParam = new DagStepDTO(); + dagStepUpdateParam.setId(workflowTaskInstanceId); + dagStepUpdateParam.setStatus(WorkflowTaskInstanceStage.SUCCESS.getValue()); + dagStepUpdateParam.setEndTime(new Date()); + dagStepService.update(dagStepUpdateParam); + + DagStepDTO stepDTO = dagStepService.selectOne(workflowTaskInstanceId); + DagInstanceDTO instanceDTO = dagInstanceComplexService.selectSimpleOne(stepDTO.getDagInstanceId()); + workflowInstanceStateMachine.onTaskChange(instanceDTO); } } diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/AbstractWorkflowInstanceEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/AbstractWorkflowInstanceEventListener.java index 04d6fc152..47e4ff97b 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/AbstractWorkflowInstanceEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/AbstractWorkflowInstanceEventListener.java @@ -18,7 +18,7 @@ package cn.sliew.scaleph.workflow.simple.listener.workflowinstance; -import cn.sliew.scaleph.workflow.service.WorkflowInstanceService; +import cn.sliew.scaleph.dag.service.DagInstanceComplexService; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowInstanceStateMachine; import lombok.extern.slf4j.Slf4j; import org.redisson.api.RScheduledExecutorService; @@ -39,7 +39,7 @@ public abstract class AbstractWorkflowInstanceEventListener implements WorkflowI protected RScheduledExecutorService executorService; @Autowired - protected WorkflowInstanceService workflowInstanceService; + protected DagInstanceComplexService dagInstanceComplexService; @Autowired protected WorkflowInstanceStateMachine stateMachine; @Autowired @@ -66,7 +66,7 @@ public void onEvent(WorkflowInstanceEventDTO event) { } protected void onFailure(Long workflowInstanceId, Throwable throwable) { - stateMachine.onFailure(workflowInstanceService.get(workflowInstanceId), throwable); + stateMachine.onFailure(dagInstanceComplexService.selectSimpleOne(workflowInstanceId), throwable); } protected abstract CompletableFuture handleEventAsync(WorkflowInstanceEventDTO event); diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceDeployEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceDeployEventListener.java index 78f966e69..c074dc1c6 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceDeployEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceDeployEventListener.java @@ -18,15 +18,17 @@ package cn.sliew.scaleph.workflow.simple.listener.workflowinstance; +import cn.sliew.scaleph.dag.service.DagConfigComplexService; +import cn.sliew.scaleph.dag.service.DagInstanceComplexService; +import cn.sliew.scaleph.dag.service.DagInstanceService; +import cn.sliew.scaleph.dag.service.DagStepService; +import cn.sliew.scaleph.dag.service.dto.DagConfigStepDTO; +import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; +import cn.sliew.scaleph.dag.service.dto.DagStepDTO; import cn.sliew.scaleph.queue.MessageListener; import cn.sliew.scaleph.workflow.service.WorkflowDefinitionService; -import cn.sliew.scaleph.workflow.service.WorkflowInstanceService; -import cn.sliew.scaleph.workflow.service.WorkflowTaskInstanceService; -import cn.sliew.scaleph.workflow.service.dto.WorkflowDefinitionDTO; -import cn.sliew.scaleph.workflow.service.dto.WorkflowInstanceDTO; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO2; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskInstanceDTO; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowInstanceStateMachine; +import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowTaskInstanceStateMachine; import com.google.common.graph.Graph; import lombok.extern.slf4j.Slf4j; import org.redisson.api.annotation.RInject; @@ -63,13 +65,15 @@ public static class DeployRunner implements Runnable, Serializable { @RInject private String taskId; @Autowired - private WorkflowDefinitionService workflowDefinitionService; + private DagConfigComplexService dagConfigComplexService; @Autowired - private WorkflowInstanceService workflowInstanceService; + private DagInstanceComplexService dagInstanceComplexService; @Autowired - private WorkflowTaskInstanceService workflowTaskInstanceService; + private DagInstanceService dagInstanceService; @Autowired private WorkflowInstanceStateMachine stateMachine; + @Autowired + private WorkflowTaskInstanceStateMachine taskInstanceStateMachine; public DeployRunner(WorkflowInstanceEventDTO event) { this.event = event; @@ -77,28 +81,30 @@ public DeployRunner(WorkflowInstanceEventDTO event) { @Override public void run() { - workflowInstanceService.updateTaskId(event.getWorkflowInstanceId(), taskId); - workflowInstanceService.updateState(event.getWorkflowInstanceId(), event.getState(), event.getNextState(), null); - WorkflowInstanceDTO workflowInstanceDTO = workflowInstanceService.get(event.getWorkflowInstanceId()); - WorkflowDefinitionDTO workflowDefinitionDTO = workflowInstanceDTO.getWorkflowDefinition(); + DagInstanceDTO dagInstanceUpdateParam = new DagInstanceDTO(); + dagInstanceUpdateParam.setId(event.getWorkflowInstanceId()); + dagInstanceUpdateParam.setStatus(event.getNextState().getValue()); + dagInstanceService.update(dagInstanceUpdateParam); + + DagInstanceDTO dagInstanceDTO = dagInstanceComplexService.selectSimpleOne(event.getWorkflowInstanceId()); // 找到 root 节点,批量启动 root 节点 - Graph dag = workflowDefinitionService.getDag(workflowDefinitionDTO.getId()); + Graph dag = dagConfigComplexService.getDag(dagInstanceDTO.getDagConfig().getId()); + // 无节点,直接成功 if (dag.nodes().size() == 0) { - stateMachine.onSuccess(workflowInstanceDTO); + stateMachine.onSuccess(dagInstanceDTO); return; } - Graph workflowTaskInstanceGraph = workflowTaskInstanceService.initialize(event.getWorkflowInstanceId(), dag); + Graph dagStepGraph = dagInstanceComplexService.getDag(event.getWorkflowInstanceId(), dag); - Set nodes = workflowTaskInstanceGraph.nodes(); - for (WorkflowTaskInstanceDTO workflowTaskInstanceDTO : nodes) { + Set nodes = dagStepGraph.nodes(); + for (DagStepDTO dagStep : nodes) { // root 节点 - if (workflowTaskInstanceGraph.inDegree(workflowTaskInstanceDTO) == 0) { - workflowTaskInstanceService.deploy(workflowTaskInstanceDTO.getId()); + if (dagStepGraph.inDegree(dagStep) == 0) { + taskInstanceStateMachine.deploy(dagStep); } } - // todo 循环检测 workflowTaskInstanceDTOS 状态或接收 workflowTaskInstance 事件,判断是否成功或失败 } } } diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceFailureEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceFailureEventListener.java index f6cfdc32c..ae6be0205 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceFailureEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceFailureEventListener.java @@ -18,12 +18,15 @@ package cn.sliew.scaleph.workflow.simple.listener.workflowinstance; +import cn.sliew.scaleph.common.dict.workflow.WorkflowInstanceState; +import cn.sliew.scaleph.dag.service.DagInstanceService; +import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; import cn.sliew.scaleph.queue.MessageListener; -import cn.sliew.scaleph.workflow.service.WorkflowInstanceService; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowInstanceStateMachine; import org.springframework.beans.factory.annotation.Autowired; import java.io.Serializable; +import java.util.Date; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -33,7 +36,7 @@ public class WorkflowInstanceFailureEventListener extends AbstractWorkflowInstan public static final String TOPIC = "TOPIC_WORKFLOW_INSTANCE_PROCESS_FAILURE"; @Autowired - private WorkflowInstanceService workflowInstanceService; + private DagInstanceService dagInstanceService; @Override protected CompletableFuture handleEventAsync(WorkflowInstanceEventDTO event) { @@ -52,7 +55,11 @@ public FailureRunner(Long workflowInstanceId, Throwable throwable) { @Override public void run() { - workflowInstanceService.updateFailure(workflowInstanceId, throwable.orElse(null)); + DagInstanceDTO dagInstanceUpdateParam = new DagInstanceDTO(); + dagInstanceUpdateParam.setId(workflowInstanceId); + dagInstanceUpdateParam.setStatus(WorkflowInstanceState.FAILURE.getValue()); + dagInstanceUpdateParam.setEndTime(new Date()); + dagInstanceService.update(dagInstanceUpdateParam); } } } diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceResumeEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceResumeEventListener.java index 49b4a5de5..0aaf50324 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceResumeEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceResumeEventListener.java @@ -20,10 +20,8 @@ import cn.sliew.milky.common.util.JacksonUtil; import cn.sliew.scaleph.queue.MessageListener; -import cn.sliew.scaleph.workflow.service.WorkflowInstanceService; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowInstanceStateMachine; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; @Slf4j @MessageListener(topic = WorkflowInstanceResumeEventListener.TOPIC, consumerGroup = WorkflowInstanceStateMachine.CONSUMER_GROUP) @@ -31,9 +29,6 @@ public class WorkflowInstanceResumeEventListener implements WorkflowInstanceEven public static final String TOPIC = "TOPIC_WORKFLOW_INSTANCE_COMMAND_RESUME"; - @Autowired - private WorkflowInstanceService workflowInstanceService; - @Override public void onEvent(WorkflowInstanceEventDTO event) { log.info("on event, {}", JacksonUtil.toJsonString(event)); diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceShutdownEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceShutdownEventListener.java index c4d8d5b3e..dc977cbd3 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceShutdownEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceShutdownEventListener.java @@ -20,10 +20,8 @@ import cn.sliew.milky.common.util.JacksonUtil; import cn.sliew.scaleph.queue.MessageListener; -import cn.sliew.scaleph.workflow.service.WorkflowInstanceService; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowInstanceStateMachine; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; @Slf4j @MessageListener(topic = WorkflowInstanceShutdownEventListener.TOPIC, consumerGroup = WorkflowInstanceStateMachine.CONSUMER_GROUP) @@ -31,9 +29,6 @@ public class WorkflowInstanceShutdownEventListener implements WorkflowInstanceEv public static final String TOPIC = "TOPIC_WORKFLOW_INSTANCE_COMMAND_SHUTDOWN"; - @Autowired - private WorkflowInstanceService workflowInstanceService; - @Override public void onEvent(WorkflowInstanceEventDTO event) { log.info("on event, {}", JacksonUtil.toJsonString(event)); diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceSuccessEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceSuccessEventListener.java index 24d4ad4ae..63d06a22f 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceSuccessEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceSuccessEventListener.java @@ -18,10 +18,15 @@ package cn.sliew.scaleph.workflow.simple.listener.workflowinstance; +import cn.sliew.scaleph.common.dict.workflow.WorkflowInstanceState; +import cn.sliew.scaleph.dag.service.DagInstanceService; +import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; import cn.sliew.scaleph.queue.MessageListener; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowInstanceStateMachine; +import org.springframework.beans.factory.annotation.Autowired; import java.io.Serializable; +import java.util.Date; import java.util.concurrent.CompletableFuture; @MessageListener(topic = WorkflowInstanceSuccessEventListener.TOPIC, consumerGroup = WorkflowInstanceStateMachine.CONSUMER_GROUP) @@ -29,6 +34,9 @@ public class WorkflowInstanceSuccessEventListener extends AbstractWorkflowInstan public static final String TOPIC = "TOPIC_WORKFLOW_INSTANCE_PROCESS_SUCCESS"; + @Autowired + private DagInstanceService dagInstanceService; + @Override protected CompletableFuture handleEventAsync(WorkflowInstanceEventDTO event) { return CompletableFuture.runAsync(new SuccessRunner(event.getWorkflowInstanceId())); @@ -44,7 +52,11 @@ public SuccessRunner(Long workflowInstanceId) { @Override public void run() { - workflowInstanceService.updateSuccess(workflowInstanceId); + DagInstanceDTO dagInstanceUpdateParam = new DagInstanceDTO(); + dagInstanceUpdateParam.setId(workflowInstanceId); + dagInstanceUpdateParam.setStatus(WorkflowInstanceState.SUCCESS.getValue()); + dagInstanceUpdateParam.setEndTime(new Date()); + dagInstanceService.update(dagInstanceUpdateParam); } } } diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceSuspendEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceSuspendEventListener.java index 46c6d5232..7621460de 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceSuspendEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceSuspendEventListener.java @@ -20,20 +20,15 @@ import cn.sliew.milky.common.util.JacksonUtil; import cn.sliew.scaleph.queue.MessageListener; -import cn.sliew.scaleph.workflow.service.WorkflowInstanceService; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowInstanceStateMachine; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; @Slf4j @MessageListener(topic = WorkflowInstanceSuspendEventListener.TOPIC, consumerGroup = WorkflowInstanceStateMachine.CONSUMER_GROUP) public class WorkflowInstanceSuspendEventListener implements WorkflowInstanceEventListener { public static final String TOPIC = "TOPIC_WORKFLOW_INSTANCE_COMMAND_SUSPEND"; - - @Autowired - private WorkflowInstanceService workflowInstanceService; - + @Override public void onEvent(WorkflowInstanceEventDTO event) { log.info("on event, {}", JacksonUtil.toJsonString(event)); diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceTaskChangeEventListener.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceTaskChangeEventListener.java index 2135c7b1d..de0c45214 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceTaskChangeEventListener.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/listener/workflowinstance/WorkflowInstanceTaskChangeEventListener.java @@ -20,13 +20,13 @@ import cn.sliew.scaleph.common.dict.workflow.WorkflowInstanceState; import cn.sliew.scaleph.common.dict.workflow.WorkflowTaskInstanceStage; +import cn.sliew.scaleph.dag.service.DagConfigComplexService; +import cn.sliew.scaleph.dag.service.dto.DagConfigStepDTO; +import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; +import cn.sliew.scaleph.dag.service.dto.DagStepDTO; import cn.sliew.scaleph.queue.MessageListener; -import cn.sliew.scaleph.workflow.service.WorkflowDefinitionService; -import cn.sliew.scaleph.workflow.service.WorkflowTaskInstanceService; -import cn.sliew.scaleph.workflow.service.dto.WorkflowInstanceDTO; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskDefinitionDTO2; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskInstanceDTO; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowInstanceStateMachine; +import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowTaskInstanceStateMachine; import com.google.common.graph.Graph; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -42,9 +42,9 @@ public class WorkflowInstanceTaskChangeEventListener extends AbstractWorkflowIns public static final String TOPIC = "TOPIC_WORKFLOW_INSTANCE_PROCESS_TASK_CHANGE"; @Autowired - private WorkflowDefinitionService workflowDefinitionService; + private DagConfigComplexService dagConfigComplexService; @Autowired - private WorkflowTaskInstanceService workflowTaskInstanceService; + private WorkflowTaskInstanceStateMachine taskInstanceStateMachine; @Override protected CompletableFuture handleEventAsync(WorkflowInstanceEventDTO event) { @@ -67,21 +67,21 @@ public TaskChangeRunner(Long workflowInstanceId) { @Override public void run() { - WorkflowInstanceDTO workflowInstanceDTO = workflowInstanceService.get(workflowInstanceId); - if (workflowInstanceDTO.getState() == WorkflowInstanceState.FAILURE) { + DagInstanceDTO dagInstanceDTO = dagInstanceComplexService.selectSimpleOne(workflowInstanceId); + if (dagInstanceDTO.getStatus().equals(WorkflowInstanceState.FAILURE.getValue())) { return; } - Graph dag = workflowDefinitionService.getDag(workflowInstanceDTO.getWorkflowDefinition().getId()); - Graph workflowTaskInstanceGraph = workflowTaskInstanceService.getDag(workflowInstanceId, dag); + Graph dag = dagConfigComplexService.getDag(dagInstanceDTO.getDagConfig().getId()); + Graph stepDag = dagInstanceComplexService.getDag(workflowInstanceId, dag); // 检测所有任务的状态,如果有一个失败,则失败 boolean isAnyFailure = false; String anyFailureMessage = null; - for (WorkflowTaskInstanceDTO workflowTaskInstanceDTO : workflowTaskInstanceGraph.nodes()) { - if (workflowTaskInstanceDTO.getStage() == WorkflowTaskInstanceStage.FAILURE) { + for (DagStepDTO dagStepDTO : stepDag.nodes()) { + if (dagStepDTO.getStatus().equals(WorkflowTaskInstanceStage.FAILURE.getValue())) { isAnyFailure = true; - anyFailureMessage = workflowTaskInstanceDTO.getMessage(); +// anyFailureMessage = dagStepDTO.getMessage(); break; } } @@ -92,38 +92,38 @@ public void run() { // 检测所有任务,如果都执行成功,则成功。在检测过程中,尝试启动所有后置节点 int successTaskCount = 0; - for (WorkflowTaskInstanceDTO workflowTaskInstanceDTO : workflowTaskInstanceGraph.nodes()) { - if (workflowTaskInstanceDTO.getStage() == WorkflowTaskInstanceStage.SUCCESS) { + for (DagStepDTO dagStepDTO : stepDag.nodes()) { + if (dagStepDTO.getStatus().equals(WorkflowTaskInstanceStage.SUCCESS.getValue())) { successTaskCount++; // 如果节点成功,尝试启动后继节点 - Set successors = workflowTaskInstanceGraph.successors(workflowTaskInstanceDTO); - successors.stream().forEach(taskInstanceDTO -> tryDeploySuccessor(workflowTaskInstanceGraph, taskInstanceDTO)); + Set successors = stepDag.successors(dagStepDTO); + successors.stream().forEach(successor -> tryDeploySuccessor(stepDag, successor)); } } if (successTaskCount == dag.nodes().size()) { - stateMachine.onSuccess(workflowInstanceService.get(workflowInstanceId)); + stateMachine.onSuccess(dagInstanceComplexService.selectSimpleOne(workflowInstanceId)); } } - private void tryDeploySuccessor(Graph workflowTaskInstanceGraph, WorkflowTaskInstanceDTO workflowTaskInstanceDTO) { + private void tryDeploySuccessor(Graph stepDag, DagStepDTO dagStepDTO) { // 已经执行过 - if (workflowTaskInstanceDTO.getStage() != WorkflowTaskInstanceStage.PENDING) { + if (dagStepDTO.getStatus().equals(WorkflowTaskInstanceStage.PENDING.getValue()) == false) { return; } // 判断前驱节点是否全部成功 - Set predecessors = workflowTaskInstanceGraph.predecessors(workflowTaskInstanceDTO); - for (WorkflowTaskInstanceDTO predecessor : predecessors) { + Set predecessors = stepDag.predecessors(dagStepDTO); + for (DagStepDTO predecessor : predecessors) { // 前驱节点未执行 - if (predecessor.getStage() == WorkflowTaskInstanceStage.PENDING) { + if (predecessor.getStatus().equals(WorkflowTaskInstanceStage.PENDING.getValue())) { return; } // 前驱节点未成功 - if (predecessor.getStage() != WorkflowTaskInstanceStage.SUCCESS) { + if (predecessor.getStatus().equals(WorkflowTaskInstanceStage.SUCCESS.getValue()) == false) { return; } } - workflowTaskInstanceService.deploy(workflowTaskInstanceDTO.getId()); + taskInstanceStateMachine.deploy(dagStepDTO); } } } diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/manager/SimpleWorkflowInstanceManager.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/manager/SimpleWorkflowInstanceManager.java index 3bc8ce38a..f7539f256 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/manager/SimpleWorkflowInstanceManager.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/manager/SimpleWorkflowInstanceManager.java @@ -18,9 +18,9 @@ package cn.sliew.scaleph.workflow.simple.manager; +import cn.sliew.scaleph.dag.service.DagInstanceService; +import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; import cn.sliew.scaleph.workflow.manager.WorkflowInstanceManager; -import cn.sliew.scaleph.workflow.service.WorkflowInstanceService; -import cn.sliew.scaleph.workflow.service.dto.WorkflowInstanceDTO; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowInstanceStateMachine; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -29,7 +29,7 @@ public class SimpleWorkflowInstanceManager implements WorkflowInstanceManager { @Autowired - private WorkflowInstanceService workflowInstanceService; + private DagInstanceService dagInstanceService; @Autowired private WorkflowInstanceStateMachine stateMachine; @@ -53,7 +53,7 @@ public void resume(Long id) { stateMachine.resume(get(id)); } - private WorkflowInstanceDTO get(Long id) { - return workflowInstanceService.get(id); + private DagInstanceDTO get(Long id) { + return dagInstanceService.selectOne(id); } } diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/manager/SimpleWorkflowTaskInstanceManager.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/manager/SimpleWorkflowTaskInstanceManager.java index 7f30b6533..765efff53 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/manager/SimpleWorkflowTaskInstanceManager.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/manager/SimpleWorkflowTaskInstanceManager.java @@ -18,9 +18,9 @@ package cn.sliew.scaleph.workflow.simple.manager; +import cn.sliew.scaleph.dag.service.DagStepService; +import cn.sliew.scaleph.dag.service.dto.DagStepDTO; import cn.sliew.scaleph.workflow.manager.WorkflowTaskInstanceManager; -import cn.sliew.scaleph.workflow.service.WorkflowTaskInstanceService; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskInstanceDTO; import cn.sliew.scaleph.workflow.simple.statemachine.WorkflowTaskInstanceStateMachine; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -29,7 +29,7 @@ public class SimpleWorkflowTaskInstanceManager implements WorkflowTaskInstanceManager { @Autowired - private WorkflowTaskInstanceService workflowTaskInstanceService; + private DagStepService dagStepService; @Autowired private WorkflowTaskInstanceStateMachine stateMachine; @@ -53,7 +53,7 @@ public void resume(Long id) { stateMachine.resume(get(id)); } - private WorkflowTaskInstanceDTO get(Long id) { - return workflowTaskInstanceService.get(id); + private DagStepDTO get(Long id) { + return dagStepService.selectOne(id); } } diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/statemachine/WorkflowInstanceStateMachine.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/statemachine/WorkflowInstanceStateMachine.java index c20a0e720..2622fd8d2 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/statemachine/WorkflowInstanceStateMachine.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/statemachine/WorkflowInstanceStateMachine.java @@ -21,6 +21,7 @@ import cn.sliew.milky.common.util.JacksonUtil; import cn.sliew.scaleph.common.dict.workflow.WorkflowInstanceEvent; import cn.sliew.scaleph.common.dict.workflow.WorkflowInstanceState; +import cn.sliew.scaleph.dag.service.dto.DagInstanceDTO; import cn.sliew.scaleph.queue.Message; import cn.sliew.scaleph.queue.Queue; import cn.sliew.scaleph.queue.QueueFactory; @@ -136,31 +137,38 @@ private String getTopic(WorkflowInstanceEvent event) { } } - public void deploy(WorkflowInstanceDTO workflowInstanceDTO) { - stateMachine.fireEvent(workflowInstanceDTO.getState(), WorkflowInstanceEvent.COMMAND_DEPLOY, Pair.of(workflowInstanceDTO.getId(), null)); + public void deploy(DagInstanceDTO dagInstanceDTO) { + WorkflowInstanceState workflowInstanceState = WorkflowInstanceState.of(dagInstanceDTO.getStatus()); + stateMachine.fireEvent(workflowInstanceState, WorkflowInstanceEvent.COMMAND_DEPLOY, Pair.of(dagInstanceDTO.getId(), null)); } - public void shutdown(WorkflowInstanceDTO workflowInstanceDTO) { - stateMachine.fireEvent(workflowInstanceDTO.getState(), WorkflowInstanceEvent.COMMAND_SHUTDOWN, Pair.of(workflowInstanceDTO.getId(), null)); + public void shutdown(DagInstanceDTO dagInstanceDTO) { + WorkflowInstanceState workflowInstanceState = WorkflowInstanceState.of(dagInstanceDTO.getStatus()); + stateMachine.fireEvent(workflowInstanceState, WorkflowInstanceEvent.COMMAND_SHUTDOWN, Pair.of(dagInstanceDTO.getId(), null)); } - public void suspend(WorkflowInstanceDTO workflowInstanceDTO) { - stateMachine.fireEvent(workflowInstanceDTO.getState(), WorkflowInstanceEvent.COMMAND_SUSPEND, Pair.of(workflowInstanceDTO.getId(), null)); + public void suspend(DagInstanceDTO dagInstanceDTO) { + WorkflowInstanceState workflowInstanceState = WorkflowInstanceState.of(dagInstanceDTO.getStatus()); + stateMachine.fireEvent(workflowInstanceState, WorkflowInstanceEvent.COMMAND_SUSPEND, Pair.of(dagInstanceDTO.getId(), null)); } - public void resume(WorkflowInstanceDTO workflowInstanceDTO) { - stateMachine.fireEvent(workflowInstanceDTO.getState(), WorkflowInstanceEvent.COMMAND_RESUME, Pair.of(workflowInstanceDTO.getId(), null)); + public void resume(DagInstanceDTO dagInstanceDTO) { + WorkflowInstanceState workflowInstanceState = WorkflowInstanceState.of(dagInstanceDTO.getStatus()); + stateMachine.fireEvent(workflowInstanceState, WorkflowInstanceEvent.COMMAND_RESUME, Pair.of(dagInstanceDTO.getId(), null)); } - public void onTaskChange(WorkflowInstanceDTO workflowInstanceDTO) { - stateMachine.fireEvent(workflowInstanceDTO.getState(), WorkflowInstanceEvent.PROCESS_TASK_CHANGE, Pair.of(workflowInstanceDTO.getId(), null)); + public void onTaskChange(DagInstanceDTO dagInstanceDTO) { + WorkflowInstanceState workflowInstanceState = WorkflowInstanceState.of(dagInstanceDTO.getStatus()); + stateMachine.fireEvent(workflowInstanceState, WorkflowInstanceEvent.PROCESS_TASK_CHANGE, Pair.of(dagInstanceDTO.getId(), null)); } - public void onSuccess(WorkflowInstanceDTO workflowInstanceDTO) { - stateMachine.fireEvent(workflowInstanceDTO.getState(), WorkflowInstanceEvent.PROCESS_SUCCESS, Pair.of(workflowInstanceDTO.getId(), null)); + public void onSuccess(DagInstanceDTO dagInstanceDTO) { + WorkflowInstanceState workflowInstanceState = WorkflowInstanceState.of(dagInstanceDTO.getStatus()); + stateMachine.fireEvent(workflowInstanceState, WorkflowInstanceEvent.PROCESS_SUCCESS, Pair.of(dagInstanceDTO.getId(), null)); } - public void onFailure(WorkflowInstanceDTO workflowInstanceDTO, Throwable throwable) { - stateMachine.fireEvent(workflowInstanceDTO.getState(), WorkflowInstanceEvent.PROCESS_FAILURE, Pair.of(workflowInstanceDTO.getId(), throwable)); + public void onFailure(DagInstanceDTO dagInstanceDTO, Throwable throwable) { + WorkflowInstanceState workflowInstanceState = WorkflowInstanceState.of(dagInstanceDTO.getStatus()); + stateMachine.fireEvent(workflowInstanceState, WorkflowInstanceEvent.PROCESS_FAILURE, Pair.of(dagInstanceDTO.getId(), throwable)); } } diff --git a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/statemachine/WorkflowTaskInstanceStateMachine.java b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/statemachine/WorkflowTaskInstanceStateMachine.java index 5576808de..50b1f7383 100644 --- a/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/statemachine/WorkflowTaskInstanceStateMachine.java +++ b/scaleph-workflow/scaleph-workflow-simple/src/main/java/cn/sliew/scaleph/workflow/simple/statemachine/WorkflowTaskInstanceStateMachine.java @@ -21,6 +21,7 @@ import cn.sliew.milky.common.util.JacksonUtil; import cn.sliew.scaleph.common.dict.workflow.WorkflowTaskInstanceEvent; import cn.sliew.scaleph.common.dict.workflow.WorkflowTaskInstanceStage; +import cn.sliew.scaleph.dag.service.dto.DagStepDTO; import cn.sliew.scaleph.queue.Message; import cn.sliew.scaleph.queue.Queue; import cn.sliew.scaleph.queue.QueueFactory; @@ -29,7 +30,6 @@ import cn.sliew.scaleph.workflow.simple.listener.taskinstance.WorkflowTaskInstanceEventDTO; import cn.sliew.scaleph.workflow.simple.listener.taskinstance.WorkflowTaskInstanceFailureEventListener; import cn.sliew.scaleph.workflow.simple.listener.taskinstance.WorkflowTaskInstanceSuccessEventListener; -import cn.sliew.scaleph.workflow.service.dto.WorkflowTaskInstanceDTO; import com.alibaba.cola.statemachine.Action; import com.alibaba.cola.statemachine.StateMachine; import com.alibaba.cola.statemachine.builder.StateMachineBuilder; @@ -122,27 +122,33 @@ private String getTopic(WorkflowTaskInstanceEvent event) { } } - public void deploy(WorkflowTaskInstanceDTO workflowTaskInstanceDTO) { - stateMachine.fireEvent(workflowTaskInstanceDTO.getStage(), WorkflowTaskInstanceEvent.COMMAND_DEPLOY, Pair.of(workflowTaskInstanceDTO.getId(), null)); + public void deploy(DagStepDTO dagStepDTO) { + WorkflowTaskInstanceStage stage = WorkflowTaskInstanceStage.of(dagStepDTO.getStatus()); + stateMachine.fireEvent(stage, WorkflowTaskInstanceEvent.COMMAND_DEPLOY, Pair.of(dagStepDTO.getId(), null)); } - public void shutdown(WorkflowTaskInstanceDTO workflowTaskInstanceDTO) { - stateMachine.fireEvent(workflowTaskInstanceDTO.getStage(), WorkflowTaskInstanceEvent.COMMAND_SHUTDOWN, Pair.of(workflowTaskInstanceDTO.getId(), null)); + public void shutdown(DagStepDTO dagStepDTO) { + WorkflowTaskInstanceStage stage = WorkflowTaskInstanceStage.of(dagStepDTO.getStatus()); + stateMachine.fireEvent(stage, WorkflowTaskInstanceEvent.COMMAND_SHUTDOWN, Pair.of(dagStepDTO.getId(), null)); } - public void suspend(WorkflowTaskInstanceDTO workflowTaskInstanceDTO) { - stateMachine.fireEvent(workflowTaskInstanceDTO.getStage(), WorkflowTaskInstanceEvent.COMMAND_SUSPEND, Pair.of(workflowTaskInstanceDTO.getId(), null)); + public void suspend(DagStepDTO dagStepDTO) { + WorkflowTaskInstanceStage stage = WorkflowTaskInstanceStage.of(dagStepDTO.getStatus()); + stateMachine.fireEvent(stage, WorkflowTaskInstanceEvent.COMMAND_SUSPEND, Pair.of(dagStepDTO.getId(), null)); } - public void resume(WorkflowTaskInstanceDTO workflowTaskInstanceDTO) { - stateMachine.fireEvent(workflowTaskInstanceDTO.getStage(), WorkflowTaskInstanceEvent.COMMAND_RESUME, Pair.of(workflowTaskInstanceDTO.getId(), null)); + public void resume(DagStepDTO dagStepDTO) { + WorkflowTaskInstanceStage stage = WorkflowTaskInstanceStage.of(dagStepDTO.getStatus()); + stateMachine.fireEvent(stage, WorkflowTaskInstanceEvent.COMMAND_RESUME, Pair.of(dagStepDTO.getId(), null)); } - public void onSuccess(WorkflowTaskInstanceDTO workflowTaskInstanceDTO) { - stateMachine.fireEvent(workflowTaskInstanceDTO.getStage(), WorkflowTaskInstanceEvent.PROCESS_SUCCESS, Pair.of(workflowTaskInstanceDTO.getId(), null)); + public void onSuccess(DagStepDTO dagStepDTO) { + WorkflowTaskInstanceStage stage = WorkflowTaskInstanceStage.of(dagStepDTO.getStatus()); + stateMachine.fireEvent(stage, WorkflowTaskInstanceEvent.PROCESS_SUCCESS, Pair.of(dagStepDTO.getId(), null)); } - public void onFailure(WorkflowTaskInstanceDTO workflowTaskInstanceDTO, Throwable throwable) { - stateMachine.fireEvent(workflowTaskInstanceDTO.getStage(), WorkflowTaskInstanceEvent.PROCESS_FAILURE, Pair.of(workflowTaskInstanceDTO.getId(), throwable)); + public void onFailure(DagStepDTO dagStepDTO, Throwable throwable) { + WorkflowTaskInstanceStage stage = WorkflowTaskInstanceStage.of(dagStepDTO.getStatus()); + stateMachine.fireEvent(stage, WorkflowTaskInstanceEvent.PROCESS_FAILURE, Pair.of(dagStepDTO.getId(), throwable)); } } diff --git a/tools/docker/build/scaleph-gravitino/Dockerfile b/tools/docker/build/scaleph-gravitino/Dockerfile new file mode 100644 index 000000000..5c2327ba9 --- /dev/null +++ b/tools/docker/build/scaleph-gravitino/Dockerfile @@ -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. + +ARG GRAVITINO_VERSION=0.5.0 +FROM maven:3.8-eclipse-temurin-11 as build + +ENV INSTALL_HOME=/opt/install +RUN mkdir -p ${INSTALL_HOME} + +## install mysql jdbc driver +ENV JDBC_MYSQL_LIBS=${INSTALL_HOME}/catalogs/jdbc-mysql/libs +RUN mkdir -p ${JDBC_MYSQL_LIBS} +RUN --mount=type=cache,target=/root/.m2 mvn dependency:get -DgroupId=mysql -DartifactId=mysql-connector-java -Dversion=8.0.28 -Dtransitive=false -Ddest=${JDBC_MYSQL_LIBS} + +## install postgresql jdbc driver +ENV JDBC_POSTGRESQL_LIBS=${INSTALL_HOME}/catalogs/jdbc-postgresql/libs +RUN mkdir -p ${JDBC_POSTGRESQL_LIBS} +RUN --mount=type=cache,target=/root/.m2 mvn dependency:get -DgroupId=org.postgresql -DartifactId=postgresql -Dversion=42.3.3 -Dtransitive=false -Ddest=${JDBC_POSTGRESQL_LIBS} + +FROM datastrato/gravitino:${GRAVITINO_VERSION} as release +ENV INSTALL_HOME=/opt/install +ENV JDBC_MYSQL_LIBS=${INSTALL_HOME}/catalogs/jdbc-mysql/libs +ENV JDBC_POSTGRESQL_LIBS=${INSTALL_HOME}/catalogs/jdbc-postgresql/libs + +COPY --from=build ${JDBC_MYSQL_LIBS}/*.jar root/gravitino/catalogs/jdbc-mysql/libs +COPY --from=build ${JDBC_POSTGRESQL_LIBS}/*.jar root/gravitino/catalogs/jdbc-postgresql/libs \ No newline at end of file diff --git a/tools/docker/local/README.md b/tools/docker/local/README.md index a5100b5da..83cb6a694 100644 --- a/tools/docker/local/README.md +++ b/tools/docker/local/README.md @@ -1,4 +1,6 @@ # 使用注意 ## gravitino -如果是 `mysql` 或 `postgresql`,需要添加对应的驱动实现类,位置位于 `${gravitino_home}/catalogs/jdbc-mysql/libs` \ No newline at end of file +如果是 `mysql` 或 `postgresql`,需要添加对应的驱动实现类,位置位于 `${gravitino_home}/catalogs/jdbc-mysql/libs`。在 docker 容器中挂载 mysql 驱动时,只需添加:`/path/to/mysql.jar:/root/gravitino/catalogs/jdbc-mysql/libs/mysql.jar`。 + +注意:gravitino 0.5.0 版本对于 mysql 驱动只支持 5.x,不支持 8.x。 \ No newline at end of file diff --git a/tools/docker/mysql/init.d/scaleph-dag-mysql.sql b/tools/docker/mysql/init.d/scaleph-dag-mysql.sql index 13ae4f581..5d1e85582 100644 --- a/tools/docker/mysql/init.d/scaleph-dag-mysql.sql +++ b/tools/docker/mysql/init.d/scaleph-dag-mysql.sql @@ -28,11 +28,13 @@ VALUES (2, 'SeaTunnel', 'fake', 'ewykdb10bd1e437346369e027a437473d483', NULL, NU INSERT INTO `dag_config`(`id`, `type`, `name`, `config_id`, `dag_meta`, `dag_attrs`, `remark`, `creator`, `editor`) VALUES (3, 'Flink-CDC', 'flink-cdc-example', 'nlly3ab39bb296a34c5888dd6509ffe588e4', NULL, NULL, NULL, 'sys', 'sys'); INSERT INTO `dag_config`(`id`, `type`, `name`, `config_id`, `dag_meta`, `dag_attrs`, `remark`, `creator`, `editor`) -VALUES (4, 'WorkFlow', 'FlinkSessionClusterStatusSyncJob', 'rnsp52fdd5edd77044a9acc0c2f24c42d760', NULL, NULL, NULL, 'sys', 'sys'); +VALUES (4, 'WorkFlow', 'FlinkSessionClusterStatusSyncJob', 'rnsp52fdd5edd77044a9acc0c2f24c42d760', NULL, NULL, NULL, + 'sys', 'sys'); INSERT INTO `dag_config`(`id`, `type`, `name`, `config_id`, `dag_meta`, `dag_attrs`, `remark`, `creator`, `editor`) VALUES (5, 'WorkFlow', 'FlinkJobStatusSyncJob', 'kvqfebc60efa8def410ebfe30f70fd8f1768', NULL, NULL, NULL, 'sys', 'sys'); INSERT INTO `dag_config`(`id`, `type`, `name`, `config_id`, `dag_meta`, `dag_attrs`, `remark`, `creator`, `editor`) -VALUES (6, 'WorkFlow', 'DorisOperatorInstanceStatusSyncJob', 'kepa00f4fdb5e8794cbb931067244caf5ef2', NULL, NULL, NULL, 'sys', 'sys'); +VALUES (6, 'WorkFlow', 'DorisOperatorInstanceStatusSyncJob', 'kepa00f4fdb5e8794cbb931067244caf5ef2', NULL, NULL, NULL, + 'sys', 'sys'); INSERT INTO `dag_config`(`id`, `type`, `name`, `config_id`, `dag_meta`, `dag_attrs`, `remark`, `creator`, `editor`) VALUES (7, 'WorkFlow', 'Demo', 'fssxbe099903bf174c11bf64b0d486383784', NULL, NULL, NULL, 'sys', 'sys'); @@ -182,50 +184,58 @@ VALUES (6, 7, '027db10b-9150-403d-9d11-e4a36c99e1db', NULL, '2c2cb6c8-794b-4cc1- drop table if exists dag_instance; create table dag_instance ( - id bigint not null auto_increment comment '自增主键', - dag_meta varchar(128) comment 'DAG元信息', - dag_attrs mediumtext comment 'DAG属性', - creator varchar(32) comment '创建人', - create_time timestamp default current_timestamp comment '创建时间', - editor varchar(32) comment '修改人', - update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', - primary key (id) + id bigint not null auto_increment comment '自增主键', + dag_config_id bigint not null comment 'DAG配置id', + instance_id varchar(36) not null comment 'instance id', + inputs text comment '输入参数', + outputs text comment '输出参数', + status varchar(8) not null comment '状态', + start_time timestamp not null comment '启动时间', + end_time timestamp comment '结束时间', + creator varchar(32) comment '创建人', + create_time timestamp default current_timestamp comment '创建时间', + editor varchar(32) comment '修改人', + update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', + primary key (id), + key idx_dag_config_id (`dag_config_id`) ) engine = innodb comment 'DAG 实例'; drop table if exists dag_step; create table dag_step ( - id bigint not null auto_increment comment '自增主键', - dag_id bigint not null comment 'DAG id', - step_id varchar(36) not null comment '步骤id', - step_name varchar(128) comment '步骤名称', - position_x int not null comment 'x坐标', - position_y int not null comment 'y坐标', - step_meta varchar(128) comment '步骤元信息', - step_attrs mediumtext comment '步骤属性', - creator varchar(32) comment '创建人', - create_time timestamp default current_timestamp comment '创建时间', - editor varchar(32) comment '修改人', - update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', + id bigint not null auto_increment comment '自增主键', + dag_instance_id bigint not null comment 'DAG id', + dag_config_step_id bigint not null comment '步骤id', + instance_id varchar(36) not null comment 'instance id', + inputs text comment '输入参数', + outputs text comment '输出参数', + status varchar(8) not null comment '状态', + start_time timestamp not null comment '启动时间', + end_time timestamp comment '结束时间', + creator varchar(32) comment '创建人', + create_time timestamp default current_timestamp comment '创建时间', + editor varchar(32) comment '修改人', + update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', primary key (id), - unique key uniq_step (dag_id, step_id) + unique key uniq_step (dag_instance_id, dag_config_step_id) ) engine = innodb comment 'DAG 步骤'; drop table if exists dag_link; create table dag_link ( - id bigint not null auto_increment comment '自增主键', - dag_id bigint not null comment 'DAG id', - link_id varchar(36) not null comment '连线id', - link_name varchar(128) comment '连线名称', - from_step_id varchar(36) not null comment '源步骤id', - to_step_id varchar(36) not null comment '目标步骤id', - link_meta varchar(128) comment '连线元信息', - link_attrs mediumtext comment '连线属性', - creator varchar(32) comment '创建人', - create_time timestamp default current_timestamp comment '创建时间', - editor varchar(32) comment '修改人', - update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', + id bigint not null auto_increment comment '自增主键', + dag_instance_id bigint not null comment 'DAG id', + dag_config_link_id bigint not null comment '连线id', + instance_id varchar(36) not null comment 'instance id', + inputs text comment '输入参数', + outputs text comment '输出参数', + status varchar(8) comment '状态', + start_time timestamp comment '启动时间', + end_time timestamp comment '结束时间', + creator varchar(32) comment '创建人', + create_time timestamp default current_timestamp comment '创建时间', + editor varchar(32) comment '修改人', + update_time timestamp default current_timestamp on update current_timestamp comment '修改时间', primary key (id), - unique key uniq_link (dag_id, link_id) + unique key uniq_link (dag_instance_id, dag_config_link_id) ) engine = innodb comment 'DAG 连线'; \ No newline at end of file