[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 nullgit-as-svn/v1/dev
parent
dce3c132ca
commit
e2759a8f42
|
|
@ -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<String, String> 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<String, String> 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<String, String> 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)
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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"),
|
||||
|
|
|
|||
|
|
@ -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<String, Object> 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) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
) ;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue