Browse Source

[Feature] [ALERT-9406]add new properties to alert class (#9408)

* add new properties to Alert.java and do minor changes to comments

* fix Integer to int

* fix Integer to int

* fix sql files

* fix not null properties to default null
3.0.0/version-upgrade
Tq 3 years ago committed by GitHub
parent
commit
e2759a8f42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/AlertGroupControllerTest.java
  2. 2
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/AlertStatus.java
  3. 11
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/AlertType.java
  4. 4
      dolphinscheduler-common/src/main/java/org/apache/dolphinscheduler/common/enums/WarningType.java
  5. 58
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java
  6. 4
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql
  7. 4
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_mysql.sql
  8. 4
      dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql

7
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.enums.Status;
import org.apache.dolphinscheduler.api.utils.Result; 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.common.utils.JSONUtils;
import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
@ -75,7 +74,7 @@ public class AlertGroupControllerTest extends AbstractControllerTest {
public void test010CreateAlertGroup() throws Exception { public void test010CreateAlertGroup() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("groupName", defaultTestAlertGroupName); paramsMap.add("groupName", defaultTestAlertGroupName);
paramsMap.add("groupType", AlertType.EMAIL.toString()); paramsMap.add("groupType", "email");
paramsMap.add("description", "cxc junit 测试告警描述"); paramsMap.add("description", "cxc junit 测试告警描述");
paramsMap.add("alertInstanceIds", ""); paramsMap.add("alertInstanceIds", "");
MvcResult mvcResult = mockMvc.perform(post("/alert-groups") MvcResult mvcResult = mockMvc.perform(post("/alert-groups")
@ -110,7 +109,7 @@ public class AlertGroupControllerTest extends AbstractControllerTest {
createEntity(); createEntity();
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("pageNo", "1"); paramsMap.add("pageNo", "1");
paramsMap.add("searchVal", AlertType.EMAIL.toString()); paramsMap.add("searchVal", "email");
paramsMap.add("pageSize", "1"); paramsMap.add("pageSize", "1");
MvcResult mvcResult = mockMvc.perform(get("/alert-groups") MvcResult mvcResult = mockMvc.perform(get("/alert-groups")
.header("sessionId", sessionId) .header("sessionId", sessionId)
@ -144,7 +143,7 @@ public class AlertGroupControllerTest extends AbstractControllerTest {
int entityId = createEntity(); int entityId = createEntity();
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>(); MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("groupName", defaultTestAlertGroupName); paramsMap.add("groupName", defaultTestAlertGroupName);
paramsMap.add("groupType", AlertType.EMAIL.toString()); paramsMap.add("groupType", "email");
paramsMap.add("description", "update alter group"); paramsMap.add("description", "update alter group");
paramsMap.add("alertInstanceIds", ""); paramsMap.add("alertInstanceIds", "");
MvcResult mvcResult = mockMvc.perform(put("/alert-groups/" + entityId) MvcResult mvcResult = mockMvc.perform(put("/alert-groups/" + entityId)

2
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; import com.baomidou.mybatisplus.annotation.EnumValue;
/** /**
* alert status * alert sending(execution) status
*/ */
public enum AlertStatus { public enum AlertStatus {
/** /**

11
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; import com.baomidou.mybatisplus.annotation.EnumValue;
/** /**
* warning message notification method * describe the reason why alert generates
*/ */
public enum AlertType { 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"), PROCESS_INSTANCE_FAILURE(0, "process instance failure"),
SMS(1, "SMS"); 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) { AlertType(int code, String descp) {
this.code = code; this.code = code;

4
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; 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 { public enum WarningType {
/** /**
* 0 do not send warning; * 0 do not send warning;
* 1 send if process success; * 1 send if process success;
* 2 send if process failed; * 2 send if process failed;
* 3 send if process ending; * 3 send if process ends, whatever the result;
*/ */
NONE(0, "none"), NONE(0, "none"),
SUCCESS(1, "success"), SUCCESS(1, "success"),

58
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java

@ -65,6 +65,7 @@ public class Alert {
*/ */
@TableField(value = "log") @TableField(value = "log")
private String log; private String log;
/** /**
* alertgroup_id * alertgroup_id
*/ */
@ -81,6 +82,31 @@ public class Alert {
*/ */
@TableField("update_time") @TableField("update_time")
private Date updateTime; 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) @TableField(exist = false)
private Map<String, Object> info = new HashMap<>(); private Map<String, Object> info = new HashMap<>();
@ -167,6 +193,38 @@ public class Alert {
this.warningType = warningType; 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 @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {

4
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_h2.sql

@ -279,6 +279,10 @@ CREATE TABLE t_ds_alert
alertgroup_id int(11) DEFAULT NULL, alertgroup_id int(11) DEFAULT NULL,
create_time datetime DEFAULT NULL, create_time datetime DEFAULT NULL,
update_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) PRIMARY KEY (id)
); );

4
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', `alertgroup_id` int(11) DEFAULT NULL COMMENT 'alert group id',
`create_time` datetime DEFAULT NULL COMMENT 'create time', `create_time` datetime DEFAULT NULL COMMENT 'create time',
`update_time` datetime DEFAULT NULL COMMENT 'update 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`), PRIMARY KEY (`id`),
KEY `idx_status` (`alert_status`) USING BTREE KEY `idx_status` (`alert_status`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;

4
dolphinscheduler-dao/src/main/resources/sql/dolphinscheduler_postgresql.sql

@ -215,6 +215,10 @@ CREATE TABLE t_ds_alert (
alertgroup_id int DEFAULT NULL , alertgroup_id int DEFAULT NULL ,
create_time timestamp DEFAULT NULL , create_time timestamp DEFAULT NULL ,
update_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) PRIMARY KEY (id)
) ; ) ;

Loading…
Cancel
Save