Browse Source

add workflow id, name for email content (#2071)

* add tenantService UT

* fix spell

* #464 email content

* modify mysql1.2.2 ddl
pull/2/head
qiaozhanwei 5 years ago committed by GitHub
parent
commit
b8014d91cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java
  2. 2
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/ZookeeperMonitorUtilsTest.java
  3. 6
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java
  4. 4
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThread.java
  5. 4
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java
  6. 2
      sql/upgrade/1.2.2_schema/mysql/dolphinscheduler_ddl.sql
  7. 2
      sql/upgrade/1.2.2_schema/postgresql/dolphinscheduler_ddl.sql

8
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/TenantServiceTest.java

@ -175,6 +175,14 @@ public class TenantServiceTest {
logger.info(result.toString()); logger.info(result.toString());
List<Tenant> tenantList = (List<Tenant>) result.get(Constants.DATA_LIST); List<Tenant> tenantList = (List<Tenant>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(tenantList)); Assert.assertTrue(CollectionUtils.isNotEmpty(tenantList));
Mockito.when( tenantMapper.queryByTenantCode("1")).thenReturn(getList());
Map<String, Object> successRes = tenantService.queryTenantList("1");
Assert.assertEquals(Status.SUCCESS,successRes.get(Constants.STATUS));
Mockito.when( tenantMapper.queryByTenantCode("1")).thenReturn(null);
Map<String, Object> tenantNotExistRes = tenantService.queryTenantList("1");
Assert.assertEquals(Status.TENANT_NOT_EXIST,tenantNotExistRes.get(Constants.STATUS));
} }
@Test @Test

2
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/utils/ZookeeperMonitorUtilsTest.java

@ -28,7 +28,7 @@ public class ZookeeperMonitorUtilsTest {
@Test @Test
public void testGetMasterLsit(){ public void testGetMasterList(){
ZookeeperMonitor zookeeperMonitor = new ZookeeperMonitor(); ZookeeperMonitor zookeeperMonitor = new ZookeeperMonitor();

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

@ -144,9 +144,11 @@ public class AlertDao extends AbstractBaseDao {
* @param taskId taskId * @param taskId taskId
* @param taskName taskName * @param taskName taskName
*/ */
public void sendTaskTimeoutAlert(int alertgroupId,String receivers,String receiversCc,int taskId,String taskName){ public void sendTaskTimeoutAlert(int alertgroupId,String receivers,String receiversCc, int processInstanceId,
String processInstanceName, int taskId,String taskName){
Alert alert = new Alert(); Alert alert = new Alert();
String content = String.format("[{'id':'%d','name':'%s','event':'timeout','warnLevel':'middle'}]",taskId,taskName); String content = String.format("[{'process instance id':'%d','task name':'%s','task id':'%d','task name':'%s'," +
"'event':'timeout','warnLevel':'middle'}]", processInstanceId, processInstanceName, taskId, taskName);
alert.setTitle("Task Timeout Warn"); alert.setTitle("Task Timeout Warn");
alert.setShowType(ShowType.TABLE); alert.setShowType(ShowType.TABLE);
alert.setContent(content); alert.setContent(content);

4
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThread.java

@ -128,7 +128,9 @@ public class MasterTaskExecThread extends MasterBaseTaskExecThread {
// process define // process define
ProcessDefinition processDefine = processService.findProcessDefineById(processInstance.getProcessDefinitionId()); ProcessDefinition processDefine = processService.findProcessDefineById(processInstance.getProcessDefinitionId());
// send warn mail // send warn mail
alertDao.sendTaskTimeoutAlert(processInstance.getWarningGroupId(),processDefine.getReceivers(),processDefine.getReceiversCc(),taskInstance.getId(),taskInstance.getName()); alertDao.sendTaskTimeoutAlert(processInstance.getWarningGroupId(),processDefine.getReceivers(),
processDefine.getReceiversCc(), processInstance.getId(), processInstance.getName(),
taskInstance.getId(),taskInstance.getName());
checkTimeout = false; checkTimeout = false;
} }
} }

4
dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java

@ -133,6 +133,8 @@ public class AlertManager {
continue; continue;
} }
LinkedHashMap<String, String> failedTaskMap = new LinkedHashMap(); LinkedHashMap<String, String> failedTaskMap = new LinkedHashMap();
failedTaskMap.put("process instance id", String.valueOf(processInstance.getId()));
failedTaskMap.put("process instance name", processInstance.getName());
failedTaskMap.put("task id", String.valueOf(task.getId())); failedTaskMap.put("task id", String.valueOf(task.getId()));
failedTaskMap.put("task name", task.getName()); failedTaskMap.put("task name", task.getName());
failedTaskMap.put("task type", task.getTaskType()); failedTaskMap.put("task type", task.getTaskType());
@ -193,7 +195,7 @@ public class AlertManager {
logger.info("add alert to db , alert : {}", alert.toString()); logger.info("add alert to db , alert : {}", alert.toString());
}catch (Exception e){ }catch (Exception e){
logger.error("send alert failed! " + e); logger.error("send alert failed:{} ", e.getMessage());
} }
} }

2
sql/upgrade/1.2.2_schema/mysql/dolphinscheduler_ddl.sql

@ -36,7 +36,7 @@ delimiter ;
CALL uc_dolphin_T_t_ds_process_definition_A_modify_by; CALL uc_dolphin_T_t_ds_process_definition_A_modify_by;
DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_A_modify_by; DROP PROCEDURE uc_dolphin_T_t_ds_process_definition_A_modify_by;
-- uc_dolphin_T_t_ds_process_definition_A_modify_by -- uc_dolphin_T_t_ds_task_instance_A_executor_id
drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_executor_id; drop PROCEDURE if EXISTS uc_dolphin_T_t_ds_task_instance_A_executor_id;
delimiter d// delimiter d//
CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_executor_id() CREATE PROCEDURE uc_dolphin_T_t_ds_task_instance_A_executor_id()

2
sql/upgrade/1.2.2_schema/postgresql/dolphinscheduler_ddl.sql

@ -32,7 +32,7 @@ delimiter ;
SELECT uc_dolphin_T_t_ds_process_definition_A_modify_by(); SELECT uc_dolphin_T_t_ds_process_definition_A_modify_by();
DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_definition_A_modify_by(); DROP FUNCTION IF EXISTS uc_dolphin_T_t_ds_process_definition_A_modify_by();
-- uc_dolphin_T_t_ds_process_definition_A_modify_by -- uc_dolphin_T_t_ds_task_instance_A_executor_id
delimiter d// delimiter d//
CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_executor_id() RETURNS void AS $$ CREATE OR REPLACE FUNCTION uc_dolphin_T_t_ds_task_instance_A_executor_id() RETURNS void AS $$
BEGIN BEGIN

Loading…
Cancel
Save