Browse Source

fix in the process alarm message, projectid is 0 (#7298)

3.0.0/version-upgrade
Kerwin 3 years ago committed by GitHub
parent
commit
3fadfca085
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java
  2. 3
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/ProcessAlertManager.java

33
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java

@ -27,6 +27,8 @@ import org.apache.dolphinscheduler.dao.entity.ProcessAlertContent;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.ServerAlertContent;
import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
import org.apache.dolphinscheduler.dao.mapper.AlertMapper;
import org.apache.dolphinscheduler.dao.mapper.AlertPluginInstanceMapper;
@ -119,8 +121,13 @@ public class AlertDao {
Alert alert = new Alert();
List<ProcessAlertContent> processAlertContentList = new ArrayList<>(1);
ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder()
.projectId(processDefinition.getId())
.projectName(processDefinition.getProjectName())
.owner(processDefinition.getUserName())
.processId(processInstance.getId())
.processName(processInstance.getName())
.processStartTime(processInstance.getStartTime())
.processHost(processInstance.getHost())
.event(AlertEvent.TIME_OUT)
.warningLevel(AlertWarnLevel.MIDDLE)
.build();
@ -141,28 +148,30 @@ public class AlertDao {
/**
* task timeout warn
*
* @param alertGroupId alertGroupId
* @param processInstanceId processInstanceId
* @param processInstanceName processInstanceName
* @param taskId taskId
* @param taskName taskName
* @param processInstance processInstanceId
* @param taskInstance taskInstance
* @param taskDefinition taskDefinition
*/
public void sendTaskTimeoutAlert(int alertGroupId, int processInstanceId,
String processInstanceName, int taskId, String taskName) {
public void sendTaskTimeoutAlert(ProcessInstance processInstance, TaskInstance taskInstance, TaskDefinition taskDefinition) {
Alert alert = new Alert();
List<ProcessAlertContent> processAlertContentList = new ArrayList<>(1);
ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder()
.processId(processInstanceId)
.processName(processInstanceName)
.taskId(taskId)
.taskName(taskName)
.projectName(taskDefinition.getProjectName())
.owner(taskDefinition.getUserName())
.processId(processInstance.getId())
.processName(processInstance.getName())
.taskId(taskInstance.getId())
.taskName(taskInstance.getName())
.taskType(taskInstance.getTaskType())
.taskStartTime(taskInstance.getStartTime())
.taskHost(taskInstance.getHost())
.event(AlertEvent.TIME_OUT)
.warningLevel(AlertWarnLevel.MIDDLE)
.build();
processAlertContentList.add(processAlertContent);
String content = JSONUtils.toJsonString(processAlertContentList);
alert.setTitle("Task Timeout Warn");
saveTaskTimeoutAlert(alert, content, alertGroupId);
saveTaskTimeoutAlert(alert, content, processInstance.getWarningGroupId());
}
/**

3
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/alert/ProcessAlertManager.java

@ -266,7 +266,6 @@ public class ProcessAlertManager {
}
public void sendTaskTimeoutAlert(ProcessInstance processInstance, TaskInstance taskInstance, TaskDefinition taskDefinition) {
alertDao.sendTaskTimeoutAlert(processInstance.getWarningGroupId(), processInstance.getId(),processInstance.getName(),
taskInstance.getId(), taskInstance.getName());
alertDao.sendTaskTimeoutAlert(processInstance, taskInstance, taskDefinition);
}
}

Loading…
Cancel
Save