diff --git a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertGroupControllerTest.java b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertGroupControllerTest.java index 11987ce606..6b38bfaf1a 100644 --- a/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertGroupControllerTest.java +++ b/dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertGroupControllerTest.java @@ -26,7 +26,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.utils.Result; -import org.apache.dolphinscheduler.common.enums.AlertType; import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; @@ -75,7 +74,7 @@ public class AlertGroupControllerTest extends AbstractControllerTest { public void test010CreateAlertGroup() throws Exception { MultiValueMap paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("groupName", defaultTestAlertGroupName); - paramsMap.add("groupType", AlertType.EMAIL.toString()); + paramsMap.add("groupType", "email"); paramsMap.add("description", "cxc junit 测试告警描述"); paramsMap.add("alertInstanceIds", ""); MvcResult mvcResult = mockMvc.perform(post("/alert-groups") @@ -110,7 +109,7 @@ public class AlertGroupControllerTest extends AbstractControllerTest { createEntity(); MultiValueMap paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("pageNo", "1"); - paramsMap.add("searchVal", AlertType.EMAIL.toString()); + paramsMap.add("searchVal", "email"); paramsMap.add("pageSize", "1"); MvcResult mvcResult = mockMvc.perform(get("/alert-groups") .header("sessionId", sessionId) @@ -144,7 +143,7 @@ public class AlertGroupControllerTest extends AbstractControllerTest { int entityId = createEntity(); MultiValueMap paramsMap = new LinkedMultiValueMap<>(); paramsMap.add("groupName", defaultTestAlertGroupName); - paramsMap.add("groupType", AlertType.EMAIL.toString()); + paramsMap.add("groupType", "email"); paramsMap.add("description", "update alter group"); paramsMap.add("alertInstanceIds", ""); MvcResult mvcResult = mockMvc.perform(put("/alert-groups/" + entityId) diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/AlertStatus.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/AlertStatus.java index 2ee288274e..14ed47ea2c 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/AlertStatus.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/AlertStatus.java @@ -20,7 +20,7 @@ package org.apache.dolphinscheduler.common.enums; import com.baomidou.mybatisplus.annotation.EnumValue; /** - * alert status + * alert sending(execution) status */ public enum AlertStatus { /** diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/AlertType.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/AlertType.java index fb16608906..50ab51fe3e 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/AlertType.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/AlertType.java @@ -20,14 +20,17 @@ package org.apache.dolphinscheduler.common.enums; import com.baomidou.mybatisplus.annotation.EnumValue; /** - * warning message notification method + * describe the reason why alert generates */ public enum AlertType { /** - * 0 email; 1 SMS + * 0 process instance failure; 1 process instance success, 2 fault tolerance warning, 3 task failure, 4 task success */ - EMAIL(0, "email"), - SMS(1, "SMS"); + PROCESS_INSTANCE_FAILURE(0, "process instance failure"), + PROCESS_INSTANCE_SUCCESS(1, "process instance success"), + FAULT_TOLERANCE_WARNING(2, "fault tolerance warning"), + TASK_FAILURE(3, "task failure"), + TASK_SUCCESS(4, "task success"); AlertType(int code, String descp) { this.code = code; diff --git a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/WarningType.java b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/WarningType.java index d3feebadf4..65f31cc911 100644 --- a/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/WarningType.java +++ b/dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/WarningType.java @@ -26,14 +26,14 @@ import com.baomidou.mybatisplus.annotation.EnumValue; import com.google.common.base.Functions; /** - * types for whether to send warning when process ending; + * types for whether to send warning when process ends; */ public enum WarningType { /** * 0 do not send warning; * 1 send if process success; * 2 send if process failed; - * 3 send if process ending; + * 3 send if process ends, whatever the result; */ NONE(0, "none"), SUCCESS(1, "success"), diff --git a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java index 7b59f499b4..c8a54cf651 100644 --- a/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java +++ b/dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java @@ -65,6 +65,7 @@ public class Alert { */ @TableField(value = "log") private String log; + /** * alertgroup_id */ @@ -81,6 +82,31 @@ public class Alert { */ @TableField("update_time") private Date updateTime; + + /** + * project_code + */ + @TableField("project_code") + private Long projectCode; + + /** + * process_definition_code + */ + @TableField("process_definition_code") + private Long processDefinitionCode; + + /** + * process_instance_id + */ + @TableField("process_instance_id") + private int processInstanceId; + + /** + * alert_type + */ + @TableField("alert_type") + private int alertType; + @TableField(exist = false) private Map info = new HashMap<>(); @@ -167,6 +193,38 @@ public class Alert { this.warningType = warningType; } + public Long getProjectCode() { + return projectCode; + } + + public void setProjectCode(Long projectCode) { + this.projectCode = projectCode; + } + + public Long getProcessDefinitionCode() { + return processDefinitionCode; + } + + public void setProcessDefinitionCode(Long processDefinitionCode) { + this.processDefinitionCode = processDefinitionCode; + } + + public int getProcessInstanceId() { + return processInstanceId; + } + + public void setProcessInstanceId(int processInstanceId) { + this.processInstanceId = processInstanceId; + } + + public int getAlertType() { + return alertType; + } + + public void setAlertType(int alertType) { + this.alertType = alertType; + } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql index 11f29eb2f2..7da05b3610 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql @@ -279,6 +279,10 @@ CREATE TABLE t_ds_alert alertgroup_id int(11) DEFAULT NULL, create_time datetime DEFAULT NULL, update_time datetime DEFAULT NULL, + project_code bigint(20) DEFAULT NULL, + process_definition_code bigint(20) DEFAULT NULL, + process_instance_id int(11) DEFAULT NULL, + alert_type int(11) DEFAULT NULL, PRIMARY KEY (id) ); diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql index 43ffc345be..ca0c563039 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql @@ -286,6 +286,10 @@ CREATE TABLE `t_ds_alert` ( `alertgroup_id` int(11) DEFAULT NULL COMMENT 'alert group id', `create_time` datetime DEFAULT NULL COMMENT 'create time', `update_time` datetime DEFAULT NULL COMMENT 'update time', + `project_code` bigint(20) DEFAULT NULL COMMENT 'project_code', + `process_definition_code` bigint(20) DEFAULT NULL COMMENT 'process_definition_code', + `process_instance_id` int(11) DEFAULT NULL COMMENT 'process_instance_id', + `alert_type` int(11) DEFAULT NULL COMMENT 'alert_type', PRIMARY KEY (`id`), KEY `idx_status` (`alert_status`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; diff --git a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql index 7b371d2397..61119fb0b3 100644 --- a/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql +++ b/dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql @@ -215,6 +215,10 @@ CREATE TABLE t_ds_alert ( alertgroup_id int DEFAULT NULL , create_time timestamp DEFAULT NULL , update_time timestamp DEFAULT NULL , + project_code bigint DEFAULT NULL, + process_definition_code bigint DEFAULT NULL, + process_instance_id int DEFAULT NULL , + alert_type int DEFAULT NULL , PRIMARY KEY (id) ) ;