Browse Source

[Feature-#3828][server] Delete recipients and CCs in the process defi… (#4303)

* [Feature-#3828][server] Delete recipients and CCs in the process definition and select the associated alert group instead

* The specific alarm instance associated with the alert group
* The process definition only associates the alert group, and does not care about the specific alarm instance.

this closes #3828

* remove test cc

* remove test cc

* fix test error

* add sql upgrade script
delete alert column(show_type、alert_type、re、cc)

* code style

* update test
Note the statement to delete the column, and provide related instructions

* delete AlertGroup field(alert_type)

* fix ut error

* fix ut error

* fix ut error

* code style

* delete api-doc receiverCC

* delete UserAlertGroupMapper

* delete UserAlertGroup

* delete UserAlertGroupApi

* alert group add coulmn user_id

* alter user_id to create_user_id

* userinfo remove alert group info
pull/3/MERGE
Kirs 4 years ago committed by GitHub
parent
commit
14785f4e39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java
  2. 59
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertGroupController.java
  3. 76
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ExecutorController.java
  4. 70
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java
  5. 47
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java
  6. 3
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java
  7. 7
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java
  8. 38
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UserAlertGroupService.java
  9. 22
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java
  10. 16
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java
  11. 3
      dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionVersionServiceImpl.java
  12. 28
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ExecutorControllerTest.java
  13. 69
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java
  14. 38
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java
  15. 3
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionVersionServiceTest.java
  16. 53
      dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UserAlertGroupServiceTest.java
  17. 61
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/AlertDao.java
  18. 85
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/Alert.java
  19. 58
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/AlertGroup.java
  20. 93
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java
  21. 64
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionVersion.java
  22. 142
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/UserAlertGroup.java
  23. 8
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.java
  24. 45
      dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/UserAlertGroupMapper.java
  25. 8
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.xml
  26. 8
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml
  27. 31
      dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UserAlertGroupMapper.xml
  28. 7
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/AlertDaoTest.java
  29. 123
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapperTest.java
  30. 5
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertMapperTest.java
  31. 2
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertPluginInstanceMapperTest.java
  32. 4
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java
  33. 4
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionVersionMapperTest.java
  34. 196
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserAlertGroupMapperTest.java
  35. 88
      dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserMapperTest.java
  36. 15
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/master/runner/MasterTaskExecThread.java
  37. 12
      dolphinscheduler-server/src/main/java/org/apache/dolphinscheduler/server/utils/AlertManager.java
  38. 7
      dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/registry/DependencyConfig.java
  39. 8
      dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskCallbackServiceTestConfig.java
  40. 112
      dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java
  41. 1
      pom.xml
  42. 47
      sql/dolphinscheduler-postgre.sql
  43. 52
      sql/dolphinscheduler_mysql.sql
  44. 26
      sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_ddl.sql
  45. 24
      sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_ddl.sql

3
dolphinscheduler-alert/src/test/java/org/apache/dolphinscheduler/alert/plugin/EmailAlertPluginTest.java

@ -22,7 +22,6 @@ import org.apache.dolphinscheduler.alert.runner.AlertSender;
import org.apache.dolphinscheduler.alert.utils.Constants; import org.apache.dolphinscheduler.alert.utils.Constants;
import org.apache.dolphinscheduler.alert.utils.PropertyUtils; import org.apache.dolphinscheduler.alert.utils.PropertyUtils;
import org.apache.dolphinscheduler.common.enums.AlertStatus; import org.apache.dolphinscheduler.common.enums.AlertStatus;
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.AlertDao; import org.apache.dolphinscheduler.dao.AlertDao;
import org.apache.dolphinscheduler.dao.DaoFactory; import org.apache.dolphinscheduler.dao.DaoFactory;
@ -70,8 +69,6 @@ public class EmailAlertPluginTest {
AlertGroup alertGroup = new AlertGroup(); AlertGroup alertGroup = new AlertGroup();
alertGroup.setDescription("test alert group 1"); alertGroup.setDescription("test alert group 1");
alertGroup.setGroupName("testalertg1"); alertGroup.setGroupName("testalertg1");
//TODO AlertType is neet delete from AlertGroup
alertGroup.setGroupType(AlertType.EMAIL);
alertDao.getAlertGroupMapper().insert(alertGroup); alertDao.getAlertGroupMapper().insert(alertGroup);
//add alert //add alert

59
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/AlertGroupController.java

@ -14,8 +14,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.api.controller; package org.apache.dolphinscheduler.api.controller;
import static org.apache.dolphinscheduler.api.enums.Status.CREATE_ALERT_GROUP_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.DELETE_ALERT_GROUP_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.LIST_PAGING_ALERT_GROUP_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.QUERY_ALL_ALERTGROUP_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.UPDATE_ALERT_GROUP_ERROR;
import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.AlertGroupService; import org.apache.dolphinscheduler.api.service.AlertGroupService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
@ -23,22 +31,27 @@ import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.AlertType; import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.utils.ParameterUtils; import org.apache.dolphinscheduler.common.utils.ParameterUtils;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import java.util.HashMap;
import io.swagger.annotations.ApiImplicitParams; import java.util.Map;
import io.swagger.annotations.ApiOperation;
import org.apache.dolphinscheduler.api.enums.Status;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.GetMapping;
import springfox.documentation.annotations.ApiIgnore; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import java.util.HashMap; import org.springframework.web.bind.annotation.RequestMapping;
import java.util.Map; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import static org.apache.dolphinscheduler.api.enums.Status.*; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;
/** /**
* alert group controller * alert group controller
@ -215,28 +228,4 @@ public class AlertGroupController extends BaseController {
} }
return result; return result;
} }
/**
* grant user
*
* @param loginUser login user
* @param userIds user ids in the group
* @param alertgroupId alert group id
* @return grant result code
*/
@ApiOperation(value = "grantUser", notes = "GRANT_ALERT_GROUP_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "ALERT_GROUP_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "userIds", value = "USER_IDS", required = true, dataType = "String")
})
@PostMapping(value = "/grant-user")
@ResponseStatus(HttpStatus.OK)
@ApiException(ALERT_GROUP_GRANT_USER_ERROR)
public Result grantUser(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "alertgroupId") int alertgroupId,
@RequestParam(value = "userIds") String userIds) {
logger.info("login user {}, grant user, alertGroupId: {},userIds : {}", loginUser.getUserName(), alertgroupId, userIds);
Map<String, Object> result = alertGroupService.grantUser(loginUser, alertgroupId, userIds);
return returnDataList(result);
}
} }

76
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ExecutorController.java

@ -14,30 +14,48 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.api.controller; package org.apache.dolphinscheduler.api.controller;
import static org.apache.dolphinscheduler.api.enums.Status.CHECK_PROCESS_DEFINITION_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.EXECUTE_PROCESS_INSTANCE_ERROR;
import static org.apache.dolphinscheduler.api.enums.Status.START_PROCESS_INSTANCE_ERROR;
import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.enums.ExecuteType;
import org.apache.dolphinscheduler.api.exceptions.ApiException; import org.apache.dolphinscheduler.api.exceptions.ApiException;
import org.apache.dolphinscheduler.api.service.ExecutorService; import org.apache.dolphinscheduler.api.service.ExecutorService;
import org.apache.dolphinscheduler.api.utils.Result; import org.apache.dolphinscheduler.api.utils.Result;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.Priority;
import org.apache.dolphinscheduler.common.enums.RunMode;
import org.apache.dolphinscheduler.common.enums.TaskDependType;
import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import io.swagger.annotations.*;
import org.apache.dolphinscheduler.common.enums.*; import java.text.ParseException;
import java.util.Map;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import java.text.ParseException;
import java.util.Map;
import static org.apache.dolphinscheduler.api.enums.Status.*;
/** /**
* execute process controller * execute process controller
*/ */
@ -64,8 +82,6 @@ public class ExecutorController extends BaseController {
* @param execType execute type * @param execType execute type
* @param warningType warning type * @param warningType warning type
* @param warningGroupId warning group id * @param warningGroupId warning group id
* @param receivers receivers
* @param receiversCc receivers cc
* @param runMode run mode * @param runMode run mode
* @param processInstancePriority process instance priority * @param processInstancePriority process instance priority
* @param workerGroup worker group * @param workerGroup worker group
@ -82,8 +98,6 @@ public class ExecutorController extends BaseController {
@ApiImplicitParam(name = "execType", value = "COMMAND_TYPE", dataType = "CommandType"), @ApiImplicitParam(name = "execType", value = "COMMAND_TYPE", dataType = "CommandType"),
@ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", required = true, dataType = "WarningType"), @ApiImplicitParam(name = "warningType", value = "WARNING_TYPE", required = true, dataType = "WarningType"),
@ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", required = true, dataType = "Int", example = "100"), @ApiImplicitParam(name = "warningGroupId", value = "WARNING_GROUP_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "receivers", value = "RECEIVERS", dataType = "String"),
@ApiImplicitParam(name = "receiversCc", value = "RECEIVERS_CC", dataType = "String"),
@ApiImplicitParam(name = "runMode", value = "RUN_MODE", dataType = "RunMode"), @ApiImplicitParam(name = "runMode", value = "RUN_MODE", dataType = "RunMode"),
@ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", required = true, dataType = "Priority"), @ApiImplicitParam(name = "processInstancePriority", value = "PROCESS_INSTANCE_PRIORITY", required = true, dataType = "Priority"),
@ApiImplicitParam(name = "workerGroup", value = "WORKER_GROUP", dataType = "String", example = "default"), @ApiImplicitParam(name = "workerGroup", value = "WORKER_GROUP", dataType = "String", example = "default"),
@ -102,17 +116,15 @@ public class ExecutorController extends BaseController {
@RequestParam(value = "execType", required = false) CommandType execType, @RequestParam(value = "execType", required = false) CommandType execType,
@RequestParam(value = "warningType", required = true) WarningType warningType, @RequestParam(value = "warningType", required = true) WarningType warningType,
@RequestParam(value = "warningGroupId", required = false) int warningGroupId, @RequestParam(value = "warningGroupId", required = false) int warningGroupId,
@RequestParam(value = "receivers", required = false) String receivers,
@RequestParam(value = "receiversCc", required = false) String receiversCc,
@RequestParam(value = "runMode", required = false) RunMode runMode, @RequestParam(value = "runMode", required = false) RunMode runMode,
@RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority, @RequestParam(value = "processInstancePriority", required = false) Priority processInstancePriority,
@RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup, @RequestParam(value = "workerGroup", required = false, defaultValue = "default") String workerGroup,
@RequestParam(value = "timeout", required = false) Integer timeout) throws ParseException { @RequestParam(value = "timeout", required = false) Integer timeout) throws ParseException {
logger.info("login user {}, start process instance, project name: {}, process definition id: {}, schedule time: {}, " logger.info("login user {}, start process instance, project name: {}, process definition id: {}, schedule time: {}, "
+ "failure policy: {}, node name: {}, node dep: {}, notify type: {}, " + "failure policy: {}, node name: {}, node dep: {}, notify type: {}, "
+ "notify group id: {},receivers:{},receiversCc:{}, run mode: {},process instance priority:{}, workerGroup: {}, timeout: {}", + "notify group id: {}, run mode: {},process instance priority:{}, workerGroup: {}, timeout: {}",
loginUser.getUserName(), projectName, processDefinitionId, scheduleTime, loginUser.getUserName(), projectName, processDefinitionId, scheduleTime,
failureStrategy, startNodeList, taskDependType, warningType, workerGroup, receivers, receiversCc, runMode, processInstancePriority, failureStrategy, startNodeList, taskDependType, warningType, workerGroup, runMode, processInstancePriority,
workerGroup, timeout); workerGroup, timeout);
if (timeout == null) { if (timeout == null) {
@ -121,7 +133,7 @@ public class ExecutorController extends BaseController {
Map<String, Object> result = execService.execProcessInstance(loginUser, projectName, processDefinitionId, scheduleTime, execType, failureStrategy, Map<String, Object> result = execService.execProcessInstance(loginUser, projectName, processDefinitionId, scheduleTime, execType, failureStrategy,
startNodeList, taskDependType, warningType, startNodeList, taskDependType, warningType,
warningGroupId, receivers, receiversCc, runMode, processInstancePriority, workerGroup, timeout); warningGroupId, runMode, processInstancePriority, workerGroup, timeout);
return returnDataList(result); return returnDataList(result);
} }
@ -174,32 +186,4 @@ public class ExecutorController extends BaseController {
Map<String, Object> result = execService.startCheckByProcessDefinedId(processDefinitionId); Map<String, Object> result = execService.startCheckByProcessDefinedId(processDefinitionId);
return returnDataList(result); return returnDataList(result);
} }
/**
* query recipients and copyers by process definition ID
*
* @param loginUser login user
* @param processDefinitionId process definition id
* @param processInstanceId process instance id
* @return receivers cc list
*/
@ApiIgnore
@ApiOperation(value = "getReceiverCc", notes = "GET_RECEIVER_CC_NOTES")
@ApiImplicitParams({
@ApiImplicitParam(name = "processDefinitionId", value = "PROCESS_DEFINITION_ID", required = true, dataType = "Int", example = "100"),
@ApiImplicitParam(name = "processInstanceId", value = "PROCESS_INSTANCE_ID", required = true, dataType = "Int", example = "100")
})
@GetMapping(value = "/get-receiver-cc")
@ResponseStatus(HttpStatus.OK)
@ApiException(QUERY_RECIPIENTS_AND_COPYERS_BY_PROCESS_DEFINITION_ERROR)
public Result getReceiverCc(@ApiIgnore @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "processDefinitionId", required = false) Integer processDefinitionId,
@RequestParam(value = "processInstanceId", required = false) Integer processInstanceId) {
logger.info("login user {}, get process definition receiver and cc", loginUser.getUserName());
Map<String, Object> result = execService.getReceiverCc(processDefinitionId, processInstanceId);
return returnDataList(result);
}
} }

70
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/AlertGroupService.java

@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.api.service; package org.apache.dolphinscheduler.api.service;
import java.util.*;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
@ -25,16 +25,22 @@ import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils; import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.entity.UserAlertGroup;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/** /**
* alert group service * alert group service
*/ */
@ -46,8 +52,6 @@ public class AlertGroupService extends BaseService{
@Autowired @Autowired
private AlertGroupMapper alertGroupMapper; private AlertGroupMapper alertGroupMapper;
@Autowired
private UserAlertGroupService userAlertGroupService;
/** /**
* query alert group list * query alert group list
* *
@ -111,10 +115,10 @@ public class AlertGroupService extends BaseService{
Date now = new Date(); Date now = new Date();
alertGroup.setGroupName(groupName); alertGroup.setGroupName(groupName);
alertGroup.setGroupType(groupType);
alertGroup.setDescription(desc); alertGroup.setDescription(desc);
alertGroup.setCreateTime(now); alertGroup.setCreateTime(now);
alertGroup.setUpdateTime(now); alertGroup.setUpdateTime(now);
alertGroup.setCreateUserId(loginUser.getId());
// insert // insert
int insert = alertGroupMapper.insert(alertGroup); int insert = alertGroupMapper.insert(alertGroup);
@ -144,7 +148,6 @@ public class AlertGroupService extends BaseService{
return result; return result;
} }
AlertGroup alertGroup = alertGroupMapper.selectById(id); AlertGroup alertGroup = alertGroupMapper.selectById(id);
if (alertGroup == null) { if (alertGroup == null) {
@ -158,12 +161,9 @@ public class AlertGroupService extends BaseService{
if (StringUtils.isNotEmpty(groupName)) { if (StringUtils.isNotEmpty(groupName)) {
alertGroup.setGroupName(groupName); alertGroup.setGroupName(groupName);
} }
if (groupType != null) {
alertGroup.setGroupType(groupType);
}
alertGroup.setDescription(desc); alertGroup.setDescription(desc);
alertGroup.setUpdateTime(now); alertGroup.setUpdateTime(now);
alertGroup.setCreateUserId(loginUser.getId());
// updateProcessInstance // updateProcessInstance
alertGroupMapper.updateById(alertGroup); alertGroupMapper.updateById(alertGroup);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
@ -192,57 +192,11 @@ public class AlertGroupService extends BaseService{
putMsg(result, Status.ALERT_GROUP_NOT_EXIST); putMsg(result, Status.ALERT_GROUP_NOT_EXIST);
return result; return result;
} }
userAlertGroupService.deleteByAlertGroupId(id);
alertGroupMapper.deleteById(id); alertGroupMapper.deleteById(id);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
return result; return result;
} }
/**
* grant user
*
* @param loginUser login user
* @param alertgroupId alert group id
* @param userIds user id list
* @return grant result code
*/
public Map<String, Object> grantUser(User loginUser, int alertgroupId, String userIds) {
Map<String, Object> result = new HashMap<>();
result.put(Constants.STATUS, false);
//only admin can operate
if (checkAdmin(loginUser, result)){
return result;
}
userAlertGroupService.deleteByAlertGroupId(alertgroupId);
if (StringUtils.isEmpty(userIds)) {
putMsg(result, Status.SUCCESS);
return result;
}
String[] userIdsArr = userIds.split(",");
Date now = new Date();
List<UserAlertGroup> alertGroups = new ArrayList<>(userIds.length());
for (String userId : userIdsArr) {
UserAlertGroup userAlertGroup = new UserAlertGroup();
userAlertGroup.setAlertgroupId(alertgroupId);
userAlertGroup.setUserId(Integer.parseInt(userId));
userAlertGroup.setCreateTime(now);
userAlertGroup.setUpdateTime(now);
alertGroups.add(userAlertGroup);
}
if (CollectionUtils.isNotEmpty(alertGroups)) {
userAlertGroupService.saveBatch(alertGroups);
}
putMsg(result, Status.SUCCESS);
return result;
}
/** /**
* verify group name exists * verify group name exists
* *

47
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ExecutorService.java

@ -83,8 +83,6 @@ public class ExecutorService extends BaseService{
* @param taskDependType node dependency type * @param taskDependType node dependency type
* @param warningType warning type * @param warningType warning type
* @param warningGroupId notify group id * @param warningGroupId notify group id
* @param receivers receivers
* @param receiversCc receivers cc
* @param processInstancePriority process instance priority * @param processInstancePriority process instance priority
* @param workerGroup worker group name * @param workerGroup worker group name
* @param runMode run mode * @param runMode run mode
@ -96,7 +94,7 @@ public class ExecutorService extends BaseService{
int processDefinitionId, String cronTime, CommandType commandType, int processDefinitionId, String cronTime, CommandType commandType,
FailureStrategy failureStrategy, String startNodeList, FailureStrategy failureStrategy, String startNodeList,
TaskDependType taskDependType, WarningType warningType, int warningGroupId, TaskDependType taskDependType, WarningType warningType, int warningGroupId,
String receivers, String receiversCc, RunMode runMode, RunMode runMode,
Priority processInstancePriority, String workerGroup, Integer timeout) throws ParseException { Priority processInstancePriority, String workerGroup, Integer timeout) throws ParseException {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
// timeout is invalid // timeout is invalid
@ -137,11 +135,7 @@ public class ExecutorService extends BaseService{
taskDependType, failureStrategy, startNodeList, cronTime, warningType, loginUser.getId(), taskDependType, failureStrategy, startNodeList, cronTime, warningType, loginUser.getId(),
warningGroupId, runMode,processInstancePriority, workerGroup); warningGroupId, runMode,processInstancePriority, workerGroup);
if(create > 0 ){ if(create > 0 ){
/** processDefinition.setWarningGroupId(warningGroupId);
* according to the process definition ID updateProcessInstance and CC recipient
*/
processDefinition.setReceivers(receivers);
processDefinition.setReceiversCc(receiversCc);
processDefinitionMapper.updateById(processDefinition); processDefinitionMapper.updateById(processDefinition);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
} else { } else {
@ -424,43 +418,6 @@ public class ExecutorService extends BaseService{
return result; return result;
} }
/**
* query recipients and copyers by process definition id or processInstanceId
*
* @param processDefineId process definition id
* @param processInstanceId process instance id
* @return receivers cc list
*/
public Map<String, Object> getReceiverCc(Integer processDefineId,Integer processInstanceId) {
Map<String, Object> result = new HashMap<>();
logger.info("processInstanceId {}",processInstanceId);
if(processDefineId == null && processInstanceId == null){
throw new RuntimeException("You must set values for parameters processDefineId or processInstanceId");
}
if(processDefineId == null && processInstanceId != null) {
ProcessInstance processInstance = processInstanceMapper.selectById(processInstanceId);
if (processInstance == null) {
throw new RuntimeException("processInstanceId is not exists");
}
processDefineId = processInstance.getProcessDefinitionId();
}
ProcessDefinition processDefinition = processDefinitionMapper.selectById(processDefineId);
if (processDefinition == null){
throw new RuntimeException(String.format("processDefineId %d is not exists",processDefineId));
}
String receivers = processDefinition.getReceivers();
String receiversCc = processDefinition.getReceiversCc();
Map<String,String> dataMap = new HashMap<>();
dataMap.put(Constants.RECEIVERS,receivers);
dataMap.put(Constants.RECEIVERS_CC,receiversCc);
result.put(Constants.DATA_LIST, dataMap);
putMsg(result, Status.SUCCESS);
return result;
}
/** /**
* create command * create command
* @param commandType commandType * @param commandType commandType

3
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessInstanceService.java

@ -187,8 +187,7 @@ public class ProcessInstanceService extends BaseService {
ProcessInstance processInstance = processService.findProcessInstanceDetailById(processId); ProcessInstance processInstance = processService.findProcessInstanceDetailById(processId);
ProcessDefinition processDefinition = processService.findProcessDefineById(processInstance.getProcessDefinitionId()); ProcessDefinition processDefinition = processService.findProcessDefineById(processInstance.getProcessDefinitionId());
processInstance.setReceivers(processDefinition.getReceivers()); processInstance.setWarningGroupId(processDefinition.getWarningGroupId());
processInstance.setReceiversCc(processDefinition.getReceiversCc());
result.put(DATA_LIST, processInstance); result.put(DATA_LIST, processInstance);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);

7
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/SchedulerService.java

@ -161,8 +161,7 @@ public class SchedulerService extends BaseService {
/** /**
* updateProcessInstance receivers and cc by process definition id * updateProcessInstance receivers and cc by process definition id
*/ */
processDefinition.setReceivers(receivers); processDefinition.setWarningGroupId(warningGroupId);
processDefinition.setReceiversCc(receiversCc);
processDefinitionMapper.updateById(processDefinition); processDefinitionMapper.updateById(processDefinition);
// return scheduler object with ID // return scheduler object with ID
@ -275,8 +274,8 @@ public class SchedulerService extends BaseService {
/** /**
* updateProcessInstance recipients and cc by process definition ID * updateProcessInstance recipients and cc by process definition ID
*/ */
processDefinition.setReceivers(receivers); processDefinition.setWarningGroupId(warningGroupId);
processDefinition.setReceiversCc(receiversCc);
processDefinitionMapper.updateById(processDefinition); processDefinitionMapper.updateById(processDefinition);
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);

38
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UserAlertGroupService.java

@ -1,38 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.dolphinscheduler.dao.entity.UserAlertGroup;
import org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
*
*/
@Service
public class UserAlertGroupService extends ServiceImpl<UserAlertGroupMapper, UserAlertGroup> {
@Autowired
private UserAlertGroupMapper userAlertGroupMapper;
boolean deleteByAlertGroupId(Integer groupId) {
return userAlertGroupMapper.deleteByAlertgroupId(groupId) >= 1;
}
}

22
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/UsersService.java

@ -14,10 +14,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.api.service; package org.apache.dolphinscheduler.api.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent; import org.apache.dolphinscheduler.api.dto.resources.ResourceComponent;
import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor; import org.apache.dolphinscheduler.api.dto.resources.visitor.ResourceTreeVisitor;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
@ -33,6 +35,7 @@ import org.apache.dolphinscheduler.common.utils.*;
import org.apache.dolphinscheduler.dao.entity.*; import org.apache.dolphinscheduler.dao.entity.*;
import org.apache.dolphinscheduler.dao.mapper.*; import org.apache.dolphinscheduler.dao.mapper.*;
import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils; import org.apache.dolphinscheduler.dao.utils.ResourceProcessDefinitionUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -173,6 +176,7 @@ public class UsersService extends BaseService {
/** /**
* query user by id * query user by id
*
* @param id id * @param id id
* @return user info * @return user info
*/ */
@ -182,6 +186,7 @@ public class UsersService extends BaseService {
/** /**
* query user * query user
*
* @param name name * @param name name
* @return user info * @return user info
*/ */
@ -203,6 +208,7 @@ public class UsersService extends BaseService {
/** /**
* get user id by user name * get user id by user name
*
* @param name user name * @param name user name
* @return if name empty 0, user not exists -1, user exist user id * @return if name empty 0, user not exists -1, user exist user id
*/ */
@ -676,23 +682,11 @@ public class UsersService extends BaseService {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
User user = null; User user;
if (loginUser.getUserType() == UserType.ADMIN_USER) { if (loginUser.getUserType() == UserType.ADMIN_USER) {
user = loginUser; user = loginUser;
} else { } else {
user = userMapper.queryDetailsById(loginUser.getId()); user = userMapper.queryDetailsById(loginUser.getId());
List<AlertGroup> alertGroups = alertGroupMapper.queryByUserId(loginUser.getId());
StringBuilder sb = new StringBuilder();
if (alertGroups != null && alertGroups.size() > 0) {
for (int i = 0; i < alertGroups.size() - 1; i++) {
sb.append(alertGroups.get(i).getGroupName() + ",");
}
sb.append(alertGroups.get(alertGroups.size() - 1));
user.setAlertGroup(sb.toString());
}
} }
result.put(Constants.DATA_LIST, user); result.put(Constants.DATA_LIST, user);
@ -848,7 +842,6 @@ public class UsersService extends BaseService {
} }
/** /**
*
* @param userName * @param userName
* @param password * @param password
* @param email * @param email
@ -877,6 +870,7 @@ public class UsersService extends BaseService {
/** /**
* copy resource files * copy resource files
*
* @param resourceComponent resource component * @param resourceComponent resource component
* @param srcBasePath src base path * @param srcBasePath src base path
* @param dstBasePath dst base path * @param dstBasePath dst base path

16
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionServiceImpl.java

@ -158,7 +158,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
* @param locations locations for nodes * @param locations locations for nodes
* @param connects connects for nodes * @param connects connects for nodes
* @return create result code * @return create result code
* @throws JsonProcessingException JsonProcessingException
*/ */
public Map<String, Object> createProcessDefinition(User loginUser, public Map<String, Object> createProcessDefinition(User loginUser,
String projectName, String projectName,
@ -166,7 +165,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
String processDefinitionJson, String processDefinitionJson,
String desc, String desc,
String locations, String locations,
String connects) throws JsonProcessingException { String connects) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
Project project = projectMapper.queryByName(projectName); Project project = projectMapper.queryByName(projectName);
@ -836,7 +835,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
String processDefinitionName, String processDefinitionName,
String importProcessParam) { String importProcessParam) {
Map<String, Object> createProcessResult = null; Map<String, Object> createProcessResult = null;
try {
createProcessResult = createProcessDefinition(loginUser createProcessResult = createProcessDefinition(loginUser
, currentProjectName, , currentProjectName,
processDefinitionName + "_import_" + DateUtils.getCurrentTimeStamp(), processDefinitionName + "_import_" + DateUtils.getCurrentTimeStamp(),
@ -845,10 +843,6 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
processMeta.getProcessDefinitionLocations(), processMeta.getProcessDefinitionLocations(),
processMeta.getProcessDefinitionConnects()); processMeta.getProcessDefinitionConnects());
putMsg(result, Status.SUCCESS); putMsg(result, Status.SUCCESS);
} catch (JsonProcessingException e) {
logger.error("import process meta json data: {}", e.getMessage(), e);
putMsg(result, Status.IMPORT_PROCESS_DEFINE_ERROR);
}
return createProcessResult; return createProcessResult;
} }
@ -1056,8 +1050,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
processDefine.setCreateTime(now); processDefine.setCreateTime(now);
processDefine.setUpdateTime(now); processDefine.setUpdateTime(now);
processDefine.setFlag(subProcess.getFlag()); processDefine.setFlag(subProcess.getFlag());
processDefine.setReceivers(subProcess.getReceivers()); processDefine.setWarningGroupId(subProcess.getWarningGroupId());
processDefine.setReceiversCc(subProcess.getReceiversCc());
processDefineMapper.insert(processDefine); processDefineMapper.insert(processDefine);
logger.info("create sub process, project: {}, process name: {}", targetProject.getName(), processDefine.getName()); logger.info("create sub process, project: {}, process name: {}", targetProject.getName(), processDefine.getName());
@ -1330,7 +1323,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
} }
runningNodeMap.remove(nodeName); runningNodeMap.remove(nodeName);
} }
if (waitingRunningNodeMap == null || waitingRunningNodeMap.size() == 0) { if (waitingRunningNodeMap.size() == 0) {
break; break;
} else { } else {
runningNodeMap.putAll(waitingRunningNodeMap); runningNodeMap.putAll(waitingRunningNodeMap);
@ -1580,8 +1573,7 @@ public class ProcessDefinitionServiceImpl extends BaseService implements
processDefinition.setTimeout(processDefinitionVersion.getTimeout()); processDefinition.setTimeout(processDefinitionVersion.getTimeout());
processDefinition.setGlobalParams(processDefinitionVersion.getGlobalParams()); processDefinition.setGlobalParams(processDefinitionVersion.getGlobalParams());
processDefinition.setUpdateTime(new Date()); processDefinition.setUpdateTime(new Date());
processDefinition.setReceivers(processDefinitionVersion.getReceivers()); processDefinition.setWarningGroupId(processDefinitionVersion.getWarningGroupId());
processDefinition.setReceiversCc(processDefinitionVersion.getReceiversCc());
processDefinition.setResourceIds(processDefinitionVersion.getResourceIds()); processDefinition.setResourceIds(processDefinitionVersion.getResourceIds());
if (processDefineMapper.updateById(processDefinition) > 0) { if (processDefineMapper.updateById(processDefinition) > 0) {

3
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/ProcessDefinitionVersionServiceImpl.java

@ -76,8 +76,7 @@ public class ProcessDefinitionVersionServiceImpl extends BaseService implements
.timeout(processDefinition.getTimeout()) .timeout(processDefinition.getTimeout())
.globalParams(processDefinition.getGlobalParams()) .globalParams(processDefinition.getGlobalParams())
.createTime(processDefinition.getUpdateTime()) .createTime(processDefinition.getUpdateTime())
.receivers(processDefinition.getReceivers()) .warningGroupId(processDefinition.getWarningGroupId())
.receiversCc(processDefinition.getReceiversCc())
.resourceIds(processDefinition.getResourceIds()) .resourceIds(processDefinition.getResourceIds())
.build(); .build();

28
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ExecutorControllerTest.java

@ -14,14 +14,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.api.controller; package org.apache.dolphinscheduler.api.controller;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.apache.dolphinscheduler.api.enums.ExecuteType; import org.apache.dolphinscheduler.api.enums.ExecuteType;
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.FailureStrategy; import org.apache.dolphinscheduler.common.enums.FailureStrategy;
import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.*; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
@ -32,11 +38,6 @@ import org.springframework.test.web.servlet.MvcResult;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
/** /**
* executor controller test * executor controller test
*/ */
@ -91,7 +92,6 @@ public class ExecutorControllerTest extends AbstractControllerTest{
logger.info(mvcResult.getResponse().getContentAsString()); logger.info(mvcResult.getResponse().getContentAsString());
} }
@Test @Test
public void testStartCheckProcessDefinition() throws Exception { public void testStartCheckProcessDefinition() throws Exception {
@ -106,18 +106,4 @@ public class ExecutorControllerTest extends AbstractControllerTest{
logger.info(mvcResult.getResponse().getContentAsString()); logger.info(mvcResult.getResponse().getContentAsString());
} }
@Test
public void testGetReceiverCc() throws Exception {
MultiValueMap<String, String> paramsMap = new LinkedMultiValueMap<>();
paramsMap.add("processInstanceId","13");
MvcResult mvcResult = mockMvc.perform(get("/projects/{projectName}/executors/get-receiver-cc","cxc_1113")
.header(SESSION_ID, sessionId)
.params(paramsMap))
.andExpect(status().isOk())
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
.andReturn();
Result result = JSONUtils.parseObject(mvcResult.getResponse().getContentAsString(), Result.class);
Assert.assertEquals(Status.SUCCESS.getCode(),result.getCode().intValue());
logger.info(mvcResult.getResponse().getContentAsString());
}
} }

69
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/AlertGroupServiceTest.java

@ -14,14 +14,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.api.service; package org.apache.dolphinscheduler.api.service;
import com.baomidou.mybatisplus.core.metadata.IPage; import static org.mockito.ArgumentMatchers.any;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import static org.mockito.ArgumentMatchers.eq;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.dolphinscheduler.api.enums.Status; import org.apache.dolphinscheduler.api.enums.Status;
import org.apache.dolphinscheduler.api.utils.PageInfo; import org.apache.dolphinscheduler.api.utils.PageInfo;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
@ -31,15 +29,15 @@ import org.apache.dolphinscheduler.common.utils.CollectionUtils;
import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.User; import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
import org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper;
import org.junit.After; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Assert; import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import static org.mockito.ArgumentMatchers.*;
import org.mockito.InjectMocks; import org.mockito.InjectMocks;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
@ -47,6 +45,9 @@ import org.mockito.junit.MockitoJUnitRunner;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class AlertGroupServiceTest { public class AlertGroupServiceTest {
@ -56,25 +57,9 @@ public class AlertGroupServiceTest {
private AlertGroupService alertGroupService; private AlertGroupService alertGroupService;
@Mock @Mock
private AlertGroupMapper alertGroupMapper; private AlertGroupMapper alertGroupMapper;
@Mock
private UserAlertGroupMapper userAlertGroupMapper;
@Mock
UserAlertGroupService userAlertGroupService;
private String groupName = "AlertGroupServiceTest"; private String groupName = "AlertGroupServiceTest";
@Before
public void setUp() {
}
@After
public void after(){
}
@Test @Test
public void testQueryAlertGroup() { public void testQueryAlertGroup() {
@ -84,6 +69,7 @@ public class AlertGroupServiceTest {
List<AlertGroup> alertGroups = (List<AlertGroup>) result.get(Constants.DATA_LIST); List<AlertGroup> alertGroups = (List<AlertGroup>) result.get(Constants.DATA_LIST);
Assert.assertTrue(CollectionUtils.isNotEmpty(alertGroups)); Assert.assertTrue(CollectionUtils.isNotEmpty(alertGroups));
} }
@Test @Test
public void testListPaging() { public void testListPaging() {
IPage<AlertGroup> page = new Page<>(1, 10); IPage<AlertGroup> page = new Page<>(1, 10);
@ -103,10 +89,10 @@ public class AlertGroupServiceTest {
Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists())); Assert.assertTrue(CollectionUtils.isNotEmpty(pageInfo.getLists()));
} }
@Test @Test
public void testCreateAlertgroup() { public void testCreateAlertgroup() {
Mockito.when(alertGroupMapper.insert(any(AlertGroup.class))).thenReturn(2); Mockito.when(alertGroupMapper.insert(any(AlertGroup.class))).thenReturn(2);
User user = new User(); User user = new User();
//no operate //no operate
@ -119,6 +105,7 @@ public class AlertGroupServiceTest {
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} }
@Test @Test
public void testUpdateAlertgroup() { public void testUpdateAlertgroup() {
@ -139,6 +126,7 @@ public class AlertGroupServiceTest {
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} }
@Test @Test
public void testDelAlertgroupById() { public void testDelAlertgroupById() {
@ -158,24 +146,6 @@ public class AlertGroupServiceTest {
logger.info(result.toString()); logger.info(result.toString());
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
}
@Test
public void testGrantUser() {
Integer groupId = 1;
ArgumentCaptor<Integer> groupArgument = ArgumentCaptor.forClass(Integer.class);
Mockito.when(userAlertGroupService.deleteByAlertGroupId(anyInt())).thenReturn(true);
Map<String, Object> result = alertGroupService.grantUser(getLoginUser(), groupId, "123,321");
Mockito.verify(userAlertGroupService).deleteByAlertGroupId(groupArgument.capture());
logger.info(result.toString());
assertEquals(groupArgument.getValue(), groupId);
assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
} }
@Test @Test
@ -190,9 +160,9 @@ public class AlertGroupServiceTest {
Assert.assertTrue(result); Assert.assertTrue(result);
} }
/** /**
* create admin user * create admin user
*
* @return * @return
*/ */
private User getLoginUser() { private User getLoginUser() {
@ -205,6 +175,7 @@ public class AlertGroupServiceTest {
/** /**
* get list * get list
*
* @return * @return
*/ */
private List<AlertGroup> getList() { private List<AlertGroup> getList() {
@ -215,13 +186,13 @@ public class AlertGroupServiceTest {
/** /**
* get entity * get entity
*
* @return * @return
*/ */
private AlertGroup getEntity() { private AlertGroup getEntity() {
AlertGroup alertGroup = new AlertGroup(); AlertGroup alertGroup = new AlertGroup();
alertGroup.setId(1); alertGroup.setId(1);
alertGroup.setGroupName(groupName); alertGroup.setGroupName(groupName);
alertGroup.setGroupType(AlertType.EMAIL);
return alertGroup; return alertGroup;
} }

38
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ExecutorService2Test.java

@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.api.service; package org.apache.dolphinscheduler.api.service;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
@ -126,18 +127,17 @@ public class ExecutorService2Test {
*/ */
@Test @Test
public void testNoComplement() throws ParseException { public void testNoComplement() throws ParseException {
try {
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList()); Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList());
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName,
processDefinitionId, cronTime, CommandType.START_PROCESS, processDefinitionId, cronTime, CommandType.START_PROCESS,
null, null, null, null,
null, null, 0, null, null, 0,
"", "", RunMode.RUN_MODE_SERIAL, RunMode.RUN_MODE_SERIAL,
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110); Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
verify(processService, times(1)).createCommand(any(Command.class)); verify(processService, times(1)).createCommand(any(Command.class));
} catch (Exception e) {
}
} }
/** /**
@ -145,18 +145,16 @@ public class ExecutorService2Test {
*/ */
@Test @Test
public void testDateError() throws ParseException { public void testDateError() throws ParseException {
try {
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList()); Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList());
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName,
processDefinitionId, "2020-01-31 23:00:00,2020-01-01 00:00:00", CommandType.COMPLEMENT_DATA, processDefinitionId, "2020-01-31 23:00:00,2020-01-01 00:00:00", CommandType.COMPLEMENT_DATA,
null, null, null, null,
null, null, 0, null, null, 0,
"", "", RunMode.RUN_MODE_SERIAL, RunMode.RUN_MODE_SERIAL,
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110); Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110);
Assert.assertEquals(Status.START_PROCESS_INSTANCE_ERROR, result.get(Constants.STATUS)); Assert.assertEquals(Status.START_PROCESS_INSTANCE_ERROR, result.get(Constants.STATUS));
verify(processService, times(0)).createCommand(any(Command.class)); verify(processService, times(0)).createCommand(any(Command.class));
} catch (Exception e) {
}
} }
/** /**
@ -164,18 +162,16 @@ public class ExecutorService2Test {
*/ */
@Test @Test
public void testSerial() throws ParseException { public void testSerial() throws ParseException {
try {
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList()); Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList());
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName,
processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA, processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA,
null, null, null, null,
null, null, 0, null, null, 0,
"", "", RunMode.RUN_MODE_SERIAL, RunMode.RUN_MODE_SERIAL,
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110); Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
verify(processService, times(1)).createCommand(any(Command.class)); verify(processService, times(1)).createCommand(any(Command.class));
} catch (Exception e) {
}
} }
/** /**
@ -183,18 +179,17 @@ public class ExecutorService2Test {
*/ */
@Test @Test
public void testParallelWithOutSchedule() throws ParseException { public void testParallelWithOutSchedule() throws ParseException {
try {
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList()); Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(zeroSchedulerList());
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName,
processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA, processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA,
null, null, null, null,
null, null, 0, null, null, 0,
"", "", RunMode.RUN_MODE_PARALLEL, RunMode.RUN_MODE_PARALLEL,
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110); Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
verify(processService, times(31)).createCommand(any(Command.class)); verify(processService, times(31)).createCommand(any(Command.class));
} catch (Exception e) {
}
} }
/** /**
@ -202,30 +197,27 @@ public class ExecutorService2Test {
*/ */
@Test @Test
public void testParallelWithSchedule() throws ParseException { public void testParallelWithSchedule() throws ParseException {
try {
Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(oneSchedulerList()); Mockito.when(processService.queryReleaseSchedulerListByProcessDefinitionId(processDefinitionId)).thenReturn(oneSchedulerList());
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName,
processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA, processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA,
null, null, null, null,
null, null, 0, null, null, 0,
"", "", RunMode.RUN_MODE_PARALLEL, RunMode.RUN_MODE_PARALLEL,
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110); Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110);
Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS)); Assert.assertEquals(Status.SUCCESS, result.get(Constants.STATUS));
verify(processService, times(15)).createCommand(any(Command.class)); verify(processService, times(15)).createCommand(any(Command.class));
} catch (Exception e) {
}
} }
@Test @Test
public void testNoMsterServers() throws ParseException { public void testNoMasterServers() throws ParseException {
Mockito.when(monitorService.getServerListFromZK(true)).thenReturn(new ArrayList<Server>()); Mockito.when(monitorService.getServerListFromZK(true)).thenReturn(new ArrayList<Server>());
Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName, Map<String, Object> result = executorService.execProcessInstance(loginUser, projectName,
processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA, processDefinitionId, cronTime, CommandType.COMPLEMENT_DATA,
null, null, null, null,
null, null, 0, null, null, 0,
"", "", RunMode.RUN_MODE_PARALLEL, RunMode.RUN_MODE_PARALLEL,
Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110); Priority.LOW, Constants.DEFAULT_WORKER_GROUP, 110);
Assert.assertEquals(result.get(Constants.STATUS), Status.MASTER_NOT_EXISTS); Assert.assertEquals(result.get(Constants.STATUS), Status.MASTER_NOT_EXISTS);

3
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionVersionServiceTest.java

@ -226,8 +226,7 @@ public class ProcessDefinitionVersionServiceTest {
.timeout(processDefinition.getTimeout()) .timeout(processDefinition.getTimeout())
.globalParams(processDefinition.getGlobalParams()) .globalParams(processDefinition.getGlobalParams())
.createTime(processDefinition.getUpdateTime()) .createTime(processDefinition.getUpdateTime())
.receivers(processDefinition.getReceivers()) .warningGroupId(processDefinition.getWarningGroupId())
.receiversCc(processDefinition.getReceiversCc())
.resourceIds(processDefinition.getResourceIds()) .resourceIds(processDefinition.getResourceIds())
.build(); .build();
} }

53
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/UserAlertGroupServiceTest.java

@ -1,53 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.api.service;
import org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnitRunner;
/**
*
*/
@RunWith(MockitoJUnitRunner.class)
public class UserAlertGroupServiceTest {
@InjectMocks
UserAlertGroupService userAlertGroupService;
@Mock
UserAlertGroupMapper userAlertGroupMapper;
@Test
public void deleteByAlertGroupId() {
Integer groupId = 1;
userAlertGroupService.deleteByAlertGroupId(groupId);
ArgumentCaptor<Integer> argumentCaptor = ArgumentCaptor.forClass(Integer.class);
Mockito.verify(userAlertGroupMapper).deleteByAlertgroupId(argumentCaptor.capture());
assertEquals(argumentCaptor.getValue(), groupId);
}
}

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

@ -19,10 +19,8 @@ package org.apache.dolphinscheduler.dao;
import org.apache.dolphinscheduler.common.enums.AlertEvent; import org.apache.dolphinscheduler.common.enums.AlertEvent;
import org.apache.dolphinscheduler.common.enums.AlertStatus; import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.enums.AlertWarnLevel; import org.apache.dolphinscheduler.common.enums.AlertWarnLevel;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.common.utils.StringUtils;
import org.apache.dolphinscheduler.dao.datasource.ConnectionFactory; import org.apache.dolphinscheduler.dao.datasource.ConnectionFactory;
import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.dao.entity.Alert;
import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance;
@ -30,11 +28,9 @@ import org.apache.dolphinscheduler.dao.entity.ProcessAlertContent;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.ServerAlertContent; import org.apache.dolphinscheduler.dao.entity.ServerAlertContent;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper; import org.apache.dolphinscheduler.dao.mapper.AlertGroupMapper;
import org.apache.dolphinscheduler.dao.mapper.AlertMapper; import org.apache.dolphinscheduler.dao.mapper.AlertMapper;
import org.apache.dolphinscheduler.dao.mapper.AlertPluginInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.AlertPluginInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -53,9 +49,6 @@ public class AlertDao extends AbstractBaseDao {
@Autowired @Autowired
private AlertMapper alertMapper; private AlertMapper alertMapper;
@Autowired
private UserAlertGroupMapper userAlertGroupMapper;
@Autowired @Autowired
private AlertPluginInstanceMapper alertPluginInstanceMapper; private AlertPluginInstanceMapper alertPluginInstanceMapper;
@ -65,7 +58,6 @@ public class AlertDao extends AbstractBaseDao {
@Override @Override
protected void init() { protected void init() {
alertMapper = ConnectionFactory.getInstance().getMapper(AlertMapper.class); alertMapper = ConnectionFactory.getInstance().getMapper(AlertMapper.class);
userAlertGroupMapper = ConnectionFactory.getInstance().getMapper(UserAlertGroupMapper.class);
alertPluginInstanceMapper = ConnectionFactory.getInstance().getMapper(AlertPluginInstanceMapper.class); alertPluginInstanceMapper = ConnectionFactory.getInstance().getMapper(AlertPluginInstanceMapper.class);
alertGroupMapper = ConnectionFactory.getInstance().getMapper(AlertGroupMapper.class); alertGroupMapper = ConnectionFactory.getInstance().getMapper(AlertGroupMapper.class);
} }
@ -96,25 +88,14 @@ public class AlertDao extends AbstractBaseDao {
return alertMapper.updateById(alert); return alertMapper.updateById(alert);
} }
/**
* query user list by alert group id
*
* @param alerGroupId alerGroupId
* @return user list
*/
public List<User> queryUserByAlertGroupId(int alerGroupId) {
return userAlertGroupMapper.listUserByAlertgroupId(alerGroupId);
}
/** /**
* MasterServer or WorkerServer stoped * MasterServer or WorkerServer stoped
* *
* @param alertgroupId alertgroupId * @param alertGroupId alertGroupId
* @param host host * @param host host
* @param serverType serverType * @param serverType serverType
*/ */
public void sendServerStopedAlert(int alertgroupId, String host, String serverType) { public void sendServerStopedAlert(int alertGroupId, String host, String serverType) {
Alert alert = new Alert(); Alert alert = new Alert();
List<ServerAlertContent> serverAlertContents = new ArrayList<>(1); List<ServerAlertContent> serverAlertContents = new ArrayList<>(1);
ServerAlertContent serverStopAlertContent = ServerAlertContent.newBuilder(). ServerAlertContent serverStopAlertContent = ServerAlertContent.newBuilder().
@ -123,7 +104,7 @@ public class AlertDao extends AbstractBaseDao {
serverAlertContents.add(serverStopAlertContent); serverAlertContents.add(serverStopAlertContent);
String content = JSONUtils.toJsonString(serverAlertContents); String content = JSONUtils.toJsonString(serverAlertContents);
alert.setTitle("Fault tolerance warning"); alert.setTitle("Fault tolerance warning");
saveTaskTimeoutAlert(alert, content, alertgroupId, null, null); saveTaskTimeoutAlert(alert, content, alertGroupId);
} }
/** /**
@ -133,9 +114,7 @@ public class AlertDao extends AbstractBaseDao {
* @param processDefinition processDefinition * @param processDefinition processDefinition
*/ */
public void sendProcessTimeoutAlert(ProcessInstance processInstance, ProcessDefinition processDefinition) { public void sendProcessTimeoutAlert(ProcessInstance processInstance, ProcessDefinition processDefinition) {
int alertgroupId = processInstance.getWarningGroupId(); int alertGroupId = processInstance.getWarningGroupId();
String receivers = processDefinition.getReceivers();
String receiversCc = processDefinition.getReceiversCc();
Alert alert = new Alert(); Alert alert = new Alert();
List<ProcessAlertContent> processAlertContentList = new ArrayList<>(1); List<ProcessAlertContent> processAlertContentList = new ArrayList<>(1);
ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder() ProcessAlertContent processAlertContent = ProcessAlertContent.newBuilder()
@ -147,20 +126,12 @@ public class AlertDao extends AbstractBaseDao {
processAlertContentList.add(processAlertContent); processAlertContentList.add(processAlertContent);
String content = JSONUtils.toJsonString(processAlertContentList); String content = JSONUtils.toJsonString(processAlertContentList);
alert.setTitle("Process Timeout Warn"); alert.setTitle("Process Timeout Warn");
saveTaskTimeoutAlert(alert, content, alertgroupId, receivers, receiversCc); saveTaskTimeoutAlert(alert, content, alertGroupId);
} }
private void saveTaskTimeoutAlert(Alert alert, String content, int alertgroupId, String receivers, String receiversCc) { private void saveTaskTimeoutAlert(Alert alert, String content, int alertGroupId) {
//alert.setShowType(ShowType.TABLE); alert.setAlertGroupId(alertGroupId);
alert.setContent(content); alert.setContent(content);
alert.setAlertType(AlertType.EMAIL);
alert.setAlertGroupId(alertgroupId);
if (StringUtils.isNotEmpty(receivers)) {
alert.setReceivers(receivers);
}
if (StringUtils.isNotEmpty(receiversCc)) {
alert.setReceiversCc(receiversCc);
}
alert.setCreateTime(new Date()); alert.setCreateTime(new Date());
alert.setUpdateTime(new Date()); alert.setUpdateTime(new Date());
alertMapper.insert(alert); alertMapper.insert(alert);
@ -169,15 +140,13 @@ public class AlertDao extends AbstractBaseDao {
/** /**
* task timeout warn * task timeout warn
* *
* @param alertgroupId alertgroupId * @param alertGroupId alertGroupId
* @param receivers receivers
* @param receiversCc receiversCc
* @param processInstanceId processInstanceId * @param processInstanceId processInstanceId
* @param processInstanceName processInstanceName * @param processInstanceName processInstanceName
* @param taskId taskId * @param taskId taskId
* @param taskName taskName * @param taskName taskName
*/ */
public void sendTaskTimeoutAlert(int alertgroupId, String receivers, String receiversCc, int processInstanceId, public void sendTaskTimeoutAlert(int alertGroupId, int processInstanceId,
String processInstanceName, int taskId, String taskName) { String processInstanceName, int taskId, String taskName) {
Alert alert = new Alert(); Alert alert = new Alert();
List<ProcessAlertContent> processAlertContentList = new ArrayList<>(1); List<ProcessAlertContent> processAlertContentList = new ArrayList<>(1);
@ -192,7 +161,7 @@ public class AlertDao extends AbstractBaseDao {
processAlertContentList.add(processAlertContent); processAlertContentList.add(processAlertContent);
String content = JSONUtils.toJsonString(processAlertContentList); String content = JSONUtils.toJsonString(processAlertContentList);
alert.setTitle("Task Timeout Warn"); alert.setTitle("Task Timeout Warn");
saveTaskTimeoutAlert(alert, content, alertgroupId, receivers, receiversCc); saveTaskTimeoutAlert(alert, content, alertGroupId);
} }
/** /**
@ -204,16 +173,6 @@ public class AlertDao extends AbstractBaseDao {
return alertMapper.listAlertByStatus(AlertStatus.WAIT_EXECUTION); return alertMapper.listAlertByStatus(AlertStatus.WAIT_EXECUTION);
} }
/**
* list user information by alert group id
*
* @param alertgroupId alertgroupId
* @return user list
*/
public List<User> listUserByAlertgroupId(int alertgroupId) {
return userAlertGroupMapper.listUserByAlertgroupId(alertgroupId);
}
/** /**
* for test * for test
* *

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

@ -18,7 +18,6 @@
package org.apache.dolphinscheduler.dao.entity; package org.apache.dolphinscheduler.dao.entity;
import org.apache.dolphinscheduler.common.enums.AlertStatus; import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.enums.AlertType;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
@ -41,23 +40,13 @@ public class Alert {
*/ */
@TableField(value = "title") @TableField(value = "title")
private String title; private String title;
/**
* show_type
*/
//TODO ShowType should be delete from Alert, Because showType is move to the plugin params
@TableField(value = "show_type")
private String showType;
/** /**
* content * content
*/ */
@TableField(value = "content") @TableField(value = "content")
private String content; private String content;
/**
* alert_type
*/
//TODO alertType should be delete from Alert, because alert type is decide by the AlertPlugin instance
@TableField(value = "alert_type")
private AlertType alertType;
/** /**
* alert_status * alert_status
*/ */
@ -73,18 +62,7 @@ public class Alert {
*/ */
@TableField("alertgroup_id") @TableField("alertgroup_id")
private int alertGroupId; private int alertGroupId;
/**
* receivers
*/
//TODO receivers should be delete from Alert, because only email alert need receivers . And receivers is move to Email Alert Plugin params.
@TableField("receivers")
private String receivers;
/**
* receivers_cc
*/
//TODO receivers_cc should be delete from Alert, because only email alert need receivers_cc . And receivers_cc is move to Email Alert Plugin params.
@TableField("receivers_cc")
private String receiversCc;
/** /**
* create_time * create_time
*/ */
@ -117,14 +95,6 @@ public class Alert {
this.title = title; this.title = title;
} }
// public String getShowType() {
// return showType;
// }
//
// public void setShowType(String showType) {
// this.showType = showType;
// }
public String getContent() { public String getContent() {
return content; return content;
} }
@ -133,14 +103,6 @@ public class Alert {
this.content = content; this.content = content;
} }
public AlertType getAlertType() {
return alertType;
}
public void setAlertType(AlertType alertType) {
this.alertType = alertType;
}
public AlertStatus getAlertStatus() { public AlertStatus getAlertStatus() {
return alertStatus; return alertStatus;
} }
@ -165,22 +127,6 @@ public class Alert {
this.alertGroupId = alertGroupId; this.alertGroupId = alertGroupId;
} }
public String getReceivers() {
return receivers;
}
public void setReceivers(String receivers) {
this.receivers = receivers;
}
public String getReceiversCc() {
return receiversCc;
}
public void setReceiversCc(String receiversCc) {
this.receiversCc = receiversCc;
}
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
@ -225,27 +171,15 @@ public class Alert {
if (!title.equals(alert.title)) { if (!title.equals(alert.title)) {
return false; return false;
} }
if (showType != alert.showType) {
return false;
}
if (!content.equals(alert.content)) { if (!content.equals(alert.content)) {
return false; return false;
} }
if (alertType != alert.alertType) {
return false;
}
if (alertStatus != alert.alertStatus) { if (alertStatus != alert.alertStatus) {
return false; return false;
} }
if (!log.equals(alert.log)) { if (!log.equals(alert.log)) {
return false; return false;
} }
if (!receivers.equals(alert.receivers)) {
return false;
}
if (!receiversCc.equals(alert.receiversCc)) {
return false;
}
if (!createTime.equals(alert.createTime)) { if (!createTime.equals(alert.createTime)) {
return false; return false;
} }
@ -257,14 +191,10 @@ public class Alert {
public int hashCode() { public int hashCode() {
int result = id; int result = id;
result = 31 * result + title.hashCode(); result = 31 * result + title.hashCode();
result = 31 * result + showType.hashCode();
result = 31 * result + content.hashCode(); result = 31 * result + content.hashCode();
result = 31 * result + alertType.hashCode();
result = 31 * result + alertStatus.hashCode(); result = 31 * result + alertStatus.hashCode();
result = 31 * result + log.hashCode(); result = 31 * result + log.hashCode();
result = 31 * result + alertGroupId; result = 31 * result + alertGroupId;
result = 31 * result + receivers.hashCode();
result = 31 * result + receiversCc.hashCode();
result = 31 * result + createTime.hashCode(); result = 31 * result + createTime.hashCode();
result = 31 * result + updateTime.hashCode(); result = 31 * result + updateTime.hashCode();
result = 31 * result + info.hashCode(); result = 31 * result + info.hashCode();
@ -278,13 +208,9 @@ public class Alert {
+ id + id
+ ", title='" + ", title='"
+ title + '\'' + title + '\''
+ ", showType="
+ showType
+ ", content='" + ", content='"
+ content + content
+ '\'' + '\''
+ ", alertType="
+ alertType
+ ", alertStatus=" + ", alertStatus="
+ alertStatus + alertStatus
+ ", log='" + ", log='"
@ -292,11 +218,6 @@ public class Alert {
+ '\'' + '\''
+ ", alertGroupId=" + ", alertGroupId="
+ alertGroupId + alertGroupId
+ ", receivers='"
+ receivers
+ '\''
+ ", receiversCc='"
+ receiversCc
+ '\'' + '\''
+ ", createTime=" + ", createTime="
+ createTime + createTime

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

@ -14,16 +14,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.dao.entity; package org.apache.dolphinscheduler.dao.entity;
import com.baomidou.mybatisplus.annotation.TableField; import java.util.Date;
import org.apache.dolphinscheduler.common.enums.AlertType;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import java.util.Date;
@TableName("t_ds_alertgroup") @TableName("t_ds_alertgroup")
public class AlertGroup { public class AlertGroup {
/** /**
@ -36,11 +36,7 @@ public class AlertGroup {
*/ */
@TableField(value = "group_name") @TableField(value = "group_name")
private String groupName; private String groupName;
/**
* group_type
*/
@TableField(value = "group_type")
private AlertType groupType;
/** /**
* description * description
*/ */
@ -57,6 +53,12 @@ public class AlertGroup {
@TableField(value = "update_time") @TableField(value = "update_time")
private Date updateTime; private Date updateTime;
/**
* create_user_id
*/
@TableField(value = "create_user_id")
private int createUserId;
public int getId() { public int getId() {
return id; return id;
} }
@ -73,14 +75,6 @@ public class AlertGroup {
this.groupName = groupName; this.groupName = groupName;
} }
public AlertType getGroupType() {
return groupType;
}
public void setGroupType(AlertType groupType) {
this.groupType = groupType;
}
public Date getCreateTime() { public Date getCreateTime() {
return createTime; return createTime;
} }
@ -105,6 +99,14 @@ public class AlertGroup {
this.description = description; this.description = description;
} }
public int getCreateUserId() {
return createUserId;
}
public void setCreateUserId(int createUserId) {
this.createUserId = createUserId;
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {
if (this == o) { if (this == o) {
@ -119,10 +121,10 @@ public class AlertGroup {
if (id != that.id) { if (id != that.id) {
return false; return false;
} }
if (groupName != null ? !groupName.equals(that.groupName) : that.groupName != null) { if (createUserId != that.createUserId) {
return false; return false;
} }
if (groupType != that.groupType) { if (groupName != null ? !groupName.equals(that.groupName) : that.groupName != null) {
return false; return false;
} }
if (description != null ? !description.equals(that.description) : that.description != null) { if (description != null ? !description.equals(that.description) : that.description != null) {
@ -135,8 +137,8 @@ public class AlertGroup {
@Override @Override
public int hashCode() { public int hashCode() {
int result = id; int result = id;
result = 31 * result + createUserId;
result = 31 * result + (groupName != null ? groupName.hashCode() : 0); result = 31 * result + (groupName != null ? groupName.hashCode() : 0);
result = 31 * result + (groupType != null ? groupType.hashCode() : 0);
result = 31 * result + (description != null ? description.hashCode() : 0); result = 31 * result + (description != null ? description.hashCode() : 0);
result = 31 * result + (createTime != null ? createTime.hashCode() : 0); result = 31 * result + (createTime != null ? createTime.hashCode() : 0);
result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0); result = 31 * result + (updateTime != null ? updateTime.hashCode() : 0);
@ -145,13 +147,13 @@ public class AlertGroup {
@Override @Override
public String toString() { public String toString() {
return "AlertGroup{" + return "AlertGroup{"
"id=" + id + + "id=" + id
", groupName='" + groupName + '\'' + + "createUserId=" + createUserId
", groupType=" + groupType + + ", groupName='" + groupName + '\''
", description='" + description + '\'' + + ", description='" + description + '\''
", createTime=" + createTime + + ", createTime=" + createTime
", updateTime=" + updateTime + + ", updateTime=" + updateTime
'}'; + '}';
} }
} }

93
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinition.java

@ -139,16 +139,6 @@ public class ProcessDefinition {
*/ */
private String connects; private String connects;
/**
* receivers
*/
private String receivers;
/**
* receivers cc
*/
private String receiversCc;
/** /**
* schedule release state : online/offline * schedule release state : online/offline
*/ */
@ -175,6 +165,11 @@ public class ProcessDefinition {
*/ */
private String resourceIds; private String resourceIds;
/**
* warningGroupId
*/
@TableField(exist = false)
private int warningGroupId;
public String getName() { public String getName() {
return name; return name;
@ -272,7 +267,6 @@ public class ProcessDefinition {
this.projectName = projectName; this.projectName = projectName;
} }
public String getGlobalParams() { public String getGlobalParams() {
return globalParams; return globalParams;
} }
@ -324,22 +318,6 @@ public class ProcessDefinition {
this.connects = connects; this.connects = connects;
} }
public String getReceivers() {
return receivers;
}
public void setReceivers(String receivers) {
this.receivers = receivers;
}
public String getReceiversCc() {
return receiversCc;
}
public void setReceiversCc(String receiversCc) {
this.receiversCc = receiversCc;
}
public ReleaseState getScheduleReleaseState() { public ReleaseState getScheduleReleaseState() {
return scheduleReleaseState; return scheduleReleaseState;
} }
@ -388,35 +366,42 @@ public class ProcessDefinition {
this.modifyBy = modifyBy; this.modifyBy = modifyBy;
} }
public int getWarningGroupId() {
return warningGroupId;
}
public void setWarningGroupId(int warningGroupId) {
this.warningGroupId = warningGroupId;
}
@Override @Override
public String toString() { public String toString() {
return "ProcessDefinition{" + return "ProcessDefinition{"
"id=" + id + + "id=" + id
", name='" + name + '\'' + + ", name='" + name + '\''
", version=" + version + + ", version=" + version
", releaseState=" + releaseState + + ", releaseState=" + releaseState
", projectId=" + projectId + + ", projectId=" + projectId
", processDefinitionJson='" + processDefinitionJson + '\'' + + ", processDefinitionJson='" + processDefinitionJson + '\''
", description='" + description + '\'' + + ", description='" + description + '\''
", globalParams='" + globalParams + '\'' + + ", globalParams='" + globalParams + '\''
", globalParamList=" + globalParamList + + ", globalParamList=" + globalParamList
", globalParamMap=" + globalParamMap + + ", globalParamMap=" + globalParamMap
", createTime=" + createTime + + ", createTime=" + createTime
", updateTime=" + updateTime + + ", updateTime=" + updateTime
", flag=" + flag + + ", flag=" + flag
", userId=" + userId + + ", userId=" + userId
", userName='" + userName + '\'' + + ", userName='" + userName + '\''
", projectName='" + projectName + '\'' + + ", projectName='" + projectName + '\''
", locations='" + locations + '\'' + + ", locations='" + locations + '\''
", connects='" + connects + '\'' + + ", connects='" + connects + '\''
", receivers='" + receivers + '\'' + + ", scheduleReleaseState=" + scheduleReleaseState
", receiversCc='" + receiversCc + '\'' + + ", timeout=" + timeout
", scheduleReleaseState=" + scheduleReleaseState + + ", warningGroupId=" + warningGroupId
", timeout=" + timeout + + ", tenantId=" + tenantId
", tenantId=" + tenantId + + ", modifyBy='" + modifyBy + '\''
", modifyBy='" + modifyBy + '\'' + + ", resourceIds='" + resourceIds + '\''
", resourceIds='" + resourceIds + '\'' + + '}';
'}';
} }
} }

64
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/ProcessDefinitionVersion.java

@ -20,6 +20,7 @@ package org.apache.dolphinscheduler.dao.entity;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
@ -57,16 +58,6 @@ public class ProcessDefinitionVersion {
*/ */
private String description; private String description;
/**
* receivers
*/
private String receivers;
/**
* receivers cc
*/
private String receiversCc;
/** /**
* process warning time out. unit: minute * process warning time out. unit: minute
*/ */
@ -98,6 +89,13 @@ public class ProcessDefinitionVersion {
*/ */
private String connects; private String connects;
/**
* warningGroupId
*/
@TableField(exist = false)
private int warningGroupId;
public String getGlobalParams() { public String getGlobalParams() {
return globalParams; return globalParams;
} }
@ -170,22 +168,6 @@ public class ProcessDefinitionVersion {
this.connects = connects; this.connects = connects;
} }
public String getReceivers() {
return receivers;
}
public void setReceivers(String receivers) {
this.receivers = receivers;
}
public String getReceiversCc() {
return receiversCc;
}
public void setReceiversCc(String receiversCc) {
this.receiversCc = receiversCc;
}
public int getTimeout() { public int getTimeout() {
return timeout; return timeout;
} }
@ -202,6 +184,14 @@ public class ProcessDefinitionVersion {
this.resourceIds = resourceIds; this.resourceIds = resourceIds;
} }
public int getWarningGroupId() {
return warningGroupId;
}
public void setWarningGroupId(int warningGroupId) {
this.warningGroupId = warningGroupId;
}
@Override @Override
public String toString() { public String toString() {
return "ProcessDefinitionVersion{" return "ProcessDefinitionVersion{"
@ -214,9 +204,8 @@ public class ProcessDefinitionVersion {
+ ", createTime=" + createTime + ", createTime=" + createTime
+ ", locations='" + locations + '\'' + ", locations='" + locations + '\''
+ ", connects='" + connects + '\'' + ", connects='" + connects + '\''
+ ", receivers='" + receivers + '\''
+ ", receiversCc='" + receiversCc + '\''
+ ", timeout=" + timeout + ", timeout=" + timeout
+ ", warningGroupId=" + warningGroupId
+ ", resourceIds='" + resourceIds + '\'' + ", resourceIds='" + resourceIds + '\''
+ '}'; + '}';
} }
@ -235,9 +224,8 @@ public class ProcessDefinitionVersion {
private Date createTime; private Date createTime;
private String locations; private String locations;
private String connects; private String connects;
private String receivers;
private String receiversCc;
private int timeout; private int timeout;
private int warningGroupId;
private String resourceIds; private String resourceIds;
private Builder() { private Builder() {
@ -288,18 +276,13 @@ public class ProcessDefinitionVersion {
return this; return this;
} }
public Builder receivers(String receivers) { public Builder timeout(int timeout) {
this.receivers = receivers; this.timeout = timeout;
return this;
}
public Builder receiversCc(String receiversCc) {
this.receiversCc = receiversCc;
return this; return this;
} }
public Builder timeout(int timeout) { public Builder warningGroupId(int warningGroupId) {
this.timeout = timeout; this.warningGroupId = warningGroupId;
return this; return this;
} }
@ -319,9 +302,8 @@ public class ProcessDefinitionVersion {
processDefinitionVersion.setCreateTime(createTime); processDefinitionVersion.setCreateTime(createTime);
processDefinitionVersion.setLocations(locations); processDefinitionVersion.setLocations(locations);
processDefinitionVersion.setConnects(connects); processDefinitionVersion.setConnects(connects);
processDefinitionVersion.setReceivers(receivers);
processDefinitionVersion.setReceiversCc(receiversCc);
processDefinitionVersion.setTimeout(timeout); processDefinitionVersion.setTimeout(timeout);
processDefinitionVersion.setWarningGroupId(warningGroupId);
processDefinitionVersion.setResourceIds(resourceIds); processDefinitionVersion.setResourceIds(resourceIds);
return processDefinitionVersion; return processDefinitionVersion;
} }

142
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/entity/UserAlertGroup.java

@ -1,142 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
* user alert group
*/
@TableName("t_ds_relation_user_alertgroup")
public class UserAlertGroup {
/**
* id
*/
@TableId(value="id", type=IdType.AUTO)
private int id;
/**
* id
*/
@TableField("alertgroup_id")
private int alertgroupId;
/**
* alert group name
*/
@TableField(exist = false)
private String alertgroupName;
/**
* user id
*/
private int userId;
/**
* user name
*/
@TableField(exist = false)
private String userName;
/**
* create time
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date createTime;
/**
* update time
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
private Date updateTime;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getAlertgroupId() {
return alertgroupId;
}
public void setAlertgroupId(int alertgroupId) {
this.alertgroupId = alertgroupId;
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public String getAlertgroupName() {
return alertgroupName;
}
public void setAlertgroupName(String alertgroupName) {
this.alertgroupName = alertgroupName;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
@Override
public String toString() {
return "UserAlertGroup{" +
"id=" + id +
", alertgroupId=" + alertgroupId +
", alertgroupName='" + alertgroupName + '\'' +
", userId=" + userId +
", userName='" + userName + '\'' +
", createTime=" + createTime +
", updateTime=" + updateTime +
'}';
}
}

8
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.java

@ -55,14 +55,6 @@ public interface AlertGroupMapper extends BaseMapper<AlertGroup> {
*/ */
List<AlertGroup> queryByUserId(@Param("userId") int userId); List<AlertGroup> queryByUserId(@Param("userId") int userId);
/**
* query by alert type
* @param alertType alertType
* @return alertgroup list
*/
List<AlertGroup> queryByAlertType(@Param("alertType") AlertType alertType);
/** /**
* query all group list * query all group list
* @return alertgroup list * @return alertgroup list

45
dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/UserAlertGroupMapper.java

@ -1,45 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.entity.UserAlertGroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* user alertgroup relation mapper interface
*/
public interface UserAlertGroupMapper extends BaseMapper<UserAlertGroup> {
/**
* delete user alertgroup relation by alertgroupId
* @param alertgroupId alertgroupId
* @return delete result
*/
int deleteByAlertgroupId(@Param("alertgroupId") int alertgroupId);
/**
* list user by alertgroupId
* @param alertgroupId alertgroupId
* @return user list
*/
List<User> listUserByAlertgroupId(@Param("alertgroupId") int alertgroupId);
}

8
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.xml

@ -31,14 +31,10 @@
where group_name=#{groupName} where group_name=#{groupName}
</select> </select>
<select id="queryByUserId" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup"> <select id="queryByUserId" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select * from t_ds_alertgroup t
left join t_ds_relation_user_alertgroup r on t.id=r.alertgroup_id
where r.user_id=#{userId}
</select>
<select id="queryByAlertType" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select * from t_ds_alertgroup select * from t_ds_alertgroup
where group_type=#{alertType} where create_user_id = #{userId}
</select> </select>
<select id="queryAllGroupList" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup"> <select id="queryAllGroupList" resultType="org.apache.dolphinscheduler.dao.entity.AlertGroup">
select * select *
from t_ds_alertgroup from t_ds_alertgroup

8
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapper.xml

@ -29,11 +29,13 @@
and pd.name = #{processDefinitionName} and pd.name = #{processDefinitionName}
</select> </select>
<select id="queryDefineListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition"> <select id="queryDefineListPaging" resultType="org.apache.dolphinscheduler.dao.entity.ProcessDefinition">
SELECT td.id, td.name, td.version, td.release_state, td.project_id, td.user_id, td.description, td.global_params, SELECT td.id, td.name, td.version, td.release_state, td.project_id, td.user_id, td.description,
td.flag, td.receivers, td.receivers_cc, td.timeout, td.tenant_id, td.modify_by, td.update_time, td.create_time, td.global_params,
td.flag, td.warning_group_id, td.timeout, td.tenant_id, td.modify_by, td.update_time, td.create_time,
sc.schedule_release_state, tu.user_name sc.schedule_release_state, tu.user_name
FROM t_ds_process_definition td FROM t_ds_process_definition td
left join (select process_definition_id,release_state as schedule_release_state from t_ds_schedules group by process_definition_id,release_state) sc on sc.process_definition_id = td.id left join (select process_definition_id,release_state as schedule_release_state from t_ds_schedules group by
process_definition_id,release_state) sc on sc.process_definition_id = td.id
left join t_ds_user tu on td.user_id = tu.id left join t_ds_user tu on td.user_id = tu.id
where td.project_id = #{projectId} where td.project_id = #{projectId}
<if test=" searchVal != null and searchVal != ''"> <if test=" searchVal != null and searchVal != ''">

31
dolphinscheduler-dao/src/main/resources/org/apache/dolphinscheduler/dao/mapper/UserAlertGroupMapper.xml

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper">
<delete id="deleteByAlertgroupId">
delete from t_ds_relation_user_alertgroup
where alertgroup_id = #{alertgroupId}
</delete>
<select id="listUserByAlertgroupId" resultType="org.apache.dolphinscheduler.dao.entity.User">
SELECT u.*
FROM t_ds_relation_user_alertgroup g_u
JOIN t_ds_user u on g_u.user_id = u.id
WHERE g_u.alertgroup_id = #{alertgroupId}
</select>
</mapper>

7
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/AlertDaoTest.java

@ -18,7 +18,6 @@
package org.apache.dolphinscheduler.dao; package org.apache.dolphinscheduler.dao;
import org.apache.dolphinscheduler.common.enums.AlertStatus; import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.dao.entity.Alert;
import java.util.List; import java.util.List;
@ -33,10 +32,8 @@ public class AlertDaoTest {
AlertDao alertDao = DaoFactory.getDaoInstance(AlertDao.class); AlertDao alertDao = DaoFactory.getDaoInstance(AlertDao.class);
Alert alert = new Alert(); Alert alert = new Alert();
alert.setTitle("Mysql Exception"); alert.setTitle("Mysql Exception");
//alert.setShowType(ShowType.TEXT); alert.setContent("[\"alarm time:2018-02-05\", \"service name:MYSQL_ALTER\", \"alarm name:MYSQL_ALTER_DUMP\", "
alert.setContent("[\"alarm time:2018-02-05\", \"service name:MYSQL_ALTER\", \"alarm name:MYSQL_ALTER_DUMP\", " + + "\"get the alarm exception.!,interface error,exception information:timed out\", \"request address:http://blog.csdn.net/dreamInTheWorld/article/details/78539286\"]");
"\"get the alarm exception.!,interface error,exception information:timed out\", \"request address:http://blog.csdn.net/dreamInTheWorld/article/details/78539286\"]");
alert.setAlertType(AlertType.EMAIL);
alert.setAlertGroupId(1); alert.setAlertGroupId(1);
alert.setAlertStatus(AlertStatus.WAIT_EXECUTION); alert.setAlertStatus(AlertStatus.WAIT_EXECUTION);
alertDao.addAlert(alert); alertDao.addAlert(alert);

123
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapperTest.java

@ -14,35 +14,33 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.dao.mapper; package org.apache.dolphinscheduler.dao.mapper;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.entity.AccessToken;
import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.UserAlertGroup;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import static org.hamcrest.Matchers.*; import com.baomidou.mybatisplus.core.metadata.IPage;
import static org.junit.Assert.*; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/** /**
* AlertGroup mapper test * AlertGroup mapper test
@ -53,14 +51,9 @@ import static org.junit.Assert.*;
@Rollback(true) @Rollback(true)
public class AlertGroupMapperTest { public class AlertGroupMapperTest {
@Autowired @Autowired
AlertGroupMapper alertGroupMapper; AlertGroupMapper alertGroupMapper;
@Autowired
UserAlertGroupMapper userAlertGroupMapper;
/** /**
* test insert * test insert
*/ */
@ -116,7 +109,6 @@ public class AlertGroupMapperTest {
} }
} }
} }
/** /**
@ -127,7 +119,6 @@ public class AlertGroupMapperTest {
AlertGroup alertGroup = createAlertGroup(); AlertGroup alertGroup = createAlertGroup();
alertGroup.setGroupName("modify GroupName"); alertGroup.setGroupName("modify GroupName");
alertGroup.setGroupType(AlertType.SMS);
alertGroup.setDescription("modify GroupName"); alertGroup.setDescription("modify GroupName");
alertGroup.setUpdateTime(DateUtils.getCurrentDate()); alertGroup.setUpdateTime(DateUtils.getCurrentDate());
@ -139,7 +130,6 @@ public class AlertGroupMapperTest {
} }
/** /**
* test delete * test delete
*/ */
@ -156,7 +146,6 @@ public class AlertGroupMapperTest {
} }
/** /**
* test query by groupname * test query by groupname
*/ */
@ -169,40 +158,7 @@ public class AlertGroupMapperTest {
List<AlertGroup> alertGroupList = alertGroupMapper.queryByGroupName("testGroup"); List<AlertGroup> alertGroupList = alertGroupMapper.queryByGroupName("testGroup");
compareAlertGroups(alertGroupMap, alertGroupList);
}
/**
* test query by userId
*/
@Test
public void testQueryByUserId() {
Integer count = 4;
Integer userId = 1;
Map<Integer, AlertGroup> alertGroupMap =
createAlertGroups(count, userId);
List<AlertGroup> alertGroupList =
alertGroupMapper.queryByUserId(userId);
compareAlertGroups(alertGroupMap, alertGroupList); compareAlertGroups(alertGroupMap, alertGroupList);
}
/**
* test query by alert type
*/
@Test
public void testQueryByAlertType() {
Integer count = 4;
Map<Integer, AlertGroup> alertGroupMap = createAlertGroups(count);
List<AlertGroup> alertGroupList = alertGroupMapper.queryByAlertType(AlertType.EMAIL);
compareAlertGroups(alertGroupMap,alertGroupList);
} }
/** /**
@ -219,9 +175,9 @@ public class AlertGroupMapperTest {
} }
/** /**
* compare AlertGruops * compare AlertGruops
*
* @param alertGroupMap alertGroupMap * @param alertGroupMap alertGroupMap
* @param alertGroupList alertGroupList * @param alertGroupList alertGroupList
*/ */
@ -237,15 +193,16 @@ public class AlertGroupMapperTest {
} }
} }
} }
/** /**
* insert * insert
*
* @return AlertGroup * @return AlertGroup
*/ */
private AlertGroup createAlertGroup(String groupName) { private AlertGroup createAlertGroup(String groupName) {
AlertGroup alertGroup = new AlertGroup(); AlertGroup alertGroup = new AlertGroup();
alertGroup.setGroupName(groupName); alertGroup.setGroupName(groupName);
alertGroup.setDescription("alert group 1"); alertGroup.setDescription("alert group 1");
alertGroup.setGroupType(AlertType.EMAIL);
alertGroup.setCreateTime(DateUtils.getCurrentDate()); alertGroup.setCreateTime(DateUtils.getCurrentDate());
alertGroup.setUpdateTime(DateUtils.getCurrentDate()); alertGroup.setUpdateTime(DateUtils.getCurrentDate());
@ -257,13 +214,13 @@ public class AlertGroupMapperTest {
/** /**
* insert * insert
*
* @return AlertGroup * @return AlertGroup
*/ */
private AlertGroup createAlertGroup() { private AlertGroup createAlertGroup() {
AlertGroup alertGroup = new AlertGroup(); AlertGroup alertGroup = new AlertGroup();
alertGroup.setGroupName("testGroup"); alertGroup.setGroupName("testGroup");
alertGroup.setDescription("testGroup"); alertGroup.setDescription("testGroup");
alertGroup.setGroupType(AlertType.EMAIL);
alertGroup.setCreateTime(DateUtils.getCurrentDate()); alertGroup.setCreateTime(DateUtils.getCurrentDate());
alertGroup.setUpdateTime(DateUtils.getCurrentDate()); alertGroup.setUpdateTime(DateUtils.getCurrentDate());
@ -275,6 +232,7 @@ public class AlertGroupMapperTest {
/** /**
* create AlertGroups * create AlertGroups
*
* @param count create AlertGroup count * @param count create AlertGroup count
* @param groupName groupName * @param groupName groupName
* @return AlertGroup map * @return AlertGroup map
@ -292,9 +250,9 @@ public class AlertGroupMapperTest {
return alertGroupMap; return alertGroupMap;
} }
/** /**
* create AlertGroups * create AlertGroups
*
* @param count create AlertGroup count * @param count create AlertGroup count
* @return AlertGroup map * @return AlertGroup map
*/ */
@ -311,45 +269,4 @@ public class AlertGroupMapperTest {
return alertGroupMap; return alertGroupMap;
} }
/**
* create AlertGroups
* @param count create AlertGroup count
* @return AlertGroup map
*/
private Map<Integer,AlertGroup> createAlertGroups(
Integer count,Integer userId){
Map<Integer,AlertGroup> alertGroupMap = new HashMap<>();
AlertGroup alertGroup = null;
for (int i = 0 ; i < count; i++){
alertGroup = createAlertGroup();
createUserAlertGroup(userId,alertGroup.getId());
alertGroupMap.put(alertGroup.getId(),alertGroup);
}
return alertGroupMap;
}
/**
* create AlertGroup
* @param userId userId
* @param alertgroupId alertgroupId
* @return UserAlertGroup
*/
private UserAlertGroup createUserAlertGroup(
Integer userId,Integer alertgroupId){
UserAlertGroup userAlertGroup = new UserAlertGroup();
userAlertGroup.setAlertgroupId(alertgroupId);
userAlertGroup.setUserId(userId);
userAlertGroup.setCreateTime(DateUtils.getCurrentDate());
userAlertGroup.setUpdateTime(DateUtils.getCurrentDate());
userAlertGroupMapper.insert(userAlertGroup);
return userAlertGroup;
}
} }

5
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertMapperTest.java

@ -23,7 +23,6 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import org.apache.dolphinscheduler.common.enums.AlertStatus; import org.apache.dolphinscheduler.common.enums.AlertStatus;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.entity.Alert; import org.apache.dolphinscheduler.dao.entity.Alert;
@ -162,14 +161,10 @@ public class AlertMapperTest {
*/ */
private Alert createAlert(AlertStatus alertStatus) { private Alert createAlert(AlertStatus alertStatus) {
Alert alert = new Alert(); Alert alert = new Alert();
//alert.setShowType(ShowType.TABLE);
alert.setTitle("test alert"); alert.setTitle("test alert");
alert.setContent("[{'type':'WORKER','host':'192.168.xx.xx','event':'server down','warning level':'serious'}]"); alert.setContent("[{'type':'WORKER','host':'192.168.xx.xx','event':'server down','warning level':'serious'}]");
alert.setAlertType(AlertType.EMAIL);
alert.setAlertStatus(alertStatus); alert.setAlertStatus(alertStatus);
alert.setLog("success"); alert.setLog("success");
alert.setReceivers("aa@aa.com");
alert.setReceiversCc("bb@aa.com");
alert.setCreateTime(DateUtils.getCurrentDate()); alert.setCreateTime(DateUtils.getCurrentDate());
alert.setUpdateTime(DateUtils.getCurrentDate()); alert.setUpdateTime(DateUtils.getCurrentDate());

2
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/AlertPluginInstanceMapperTest.java

@ -17,7 +17,6 @@
package org.apache.dolphinscheduler.dao.mapper; package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.entity.AlertGroup; import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance; import org.apache.dolphinscheduler.dao.entity.AlertPluginInstance;
@ -106,7 +105,6 @@ public class AlertPluginInstanceMapperTest {
AlertGroup alertGroup = new AlertGroup(); AlertGroup alertGroup = new AlertGroup();
alertGroup.setGroupName(groupName); alertGroup.setGroupName(groupName);
alertGroup.setDescription("alert group 1"); alertGroup.setDescription("alert group 1");
alertGroup.setGroupType(AlertType.EMAIL);
alertGroup.setCreateTime(DateUtils.getCurrentDate()); alertGroup.setCreateTime(DateUtils.getCurrentDate());
alertGroup.setUpdateTime(DateUtils.getCurrentDate()); alertGroup.setUpdateTime(DateUtils.getCurrentDate());

4
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionMapperTest.java

@ -77,8 +77,6 @@ public class ProcessDefinitionMapperTest {
processDefinition.setUserId(101); processDefinition.setUserId(101);
processDefinition.setUpdateTime(new Date()); processDefinition.setUpdateTime(new Date());
processDefinition.setCreateTime(new Date()); processDefinition.setCreateTime(new Date());
// processDefinition.setGlobalParams("[{\"prop\":\"selenium_global_parameters_1\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"selenium_global_parameters_value_1\"}]");
processDefinitionMapper.insert(processDefinition); processDefinitionMapper.insert(processDefinition);
return processDefinition; return processDefinition;
} }
@ -170,8 +168,6 @@ public class ProcessDefinitionMapperTest {
processDefinition.setCreateTime(new Date()); processDefinition.setCreateTime(new Date());
processDefinition.setTenantId(tenant.getId()); processDefinition.setTenantId(tenant.getId());
processDefinition.setUserId(user.getId()); processDefinition.setUserId(user.getId());
// processDefinition.setGlobalParams("[{\"prop\":\"selenium_global_parameters_1\",\"direct\":\"IN\",\"type\":\"VARCHAR\",\"value\":\"selenium_global_parameters_value_1\"}]");
//
processDefinitionMapper.insert(processDefinition); processDefinitionMapper.insert(processDefinition);
ProcessDefinition processDefinition1 = processDefinitionMapper.queryByDefineName(project.getId(), "def 1"); ProcessDefinition processDefinition1 = processDefinitionMapper.queryByDefineName(project.getId(), "def 1");

4
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/ProcessDefinitionVersionMapperTest.java

@ -76,8 +76,6 @@ public class ProcessDefinitionVersionMapperTest {
processDefinitionVersion.setCreateTime(new Date()); processDefinitionVersion.setCreateTime(new Date());
processDefinitionVersion.setLocations(StringUtils.EMPTY); processDefinitionVersion.setLocations(StringUtils.EMPTY);
processDefinitionVersion.setConnects(StringUtils.EMPTY); processDefinitionVersion.setConnects(StringUtils.EMPTY);
processDefinitionVersion.setReceivers(StringUtils.EMPTY);
processDefinitionVersion.setReceiversCc(StringUtils.EMPTY);
processDefinitionVersion.setTimeout(10); processDefinitionVersion.setTimeout(10);
processDefinitionVersion.setResourceIds("1,2"); processDefinitionVersion.setResourceIds("1,2");
processDefinitionVersionMapper.insert(processDefinitionVersion); processDefinitionVersionMapper.insert(processDefinitionVersion);
@ -101,8 +99,6 @@ public class ProcessDefinitionVersionMapperTest {
processDefinitionVersion.setCreateTime(new Date()); processDefinitionVersion.setCreateTime(new Date());
processDefinitionVersion.setLocations(StringUtils.EMPTY); processDefinitionVersion.setLocations(StringUtils.EMPTY);
processDefinitionVersion.setConnects(StringUtils.EMPTY); processDefinitionVersion.setConnects(StringUtils.EMPTY);
processDefinitionVersion.setReceivers(StringUtils.EMPTY);
processDefinitionVersion.setReceiversCc(StringUtils.EMPTY);
processDefinitionVersion.setTimeout(10); processDefinitionVersion.setTimeout(10);
processDefinitionVersion.setResourceIds("1,2"); processDefinitionVersion.setResourceIds("1,2");
processDefinitionVersionMapper.insert(processDefinitionVersion); processDefinitionVersionMapper.insert(processDefinitionVersion);

196
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserAlertGroupMapperTest.java

@ -1,196 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.User;
import org.apache.dolphinscheduler.dao.entity.UserAlertGroup;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
@RunWith(SpringRunner.class)
@SpringBootTest
@Transactional
@Rollback(true)
public class UserAlertGroupMapperTest {
@Autowired
private UserMapper userMapper;
@Autowired
AlertGroupMapper alertGroupMapper;
@Autowired
private UserAlertGroupMapper userAlertGroupMapper;
/**
* insert one UserAlertGroup
* @param user user
* @param alertGroup alertGroup
* @return UserAlertGroup
*/
private UserAlertGroup insertOne(User user,AlertGroup alertGroup){
UserAlertGroup userAlertGroup = new UserAlertGroup();
userAlertGroup.setAlertgroupName(alertGroup.getGroupName());
userAlertGroup.setAlertgroupId(alertGroup.getId());
userAlertGroup.setUserId(user.getId());
userAlertGroup.setCreateTime(new Date());
userAlertGroup.setUpdateTime(new Date());
userAlertGroupMapper.insert(userAlertGroup);
return userAlertGroup;
}
/**
* insert one UserAlertGroup
* @return UserAlertGroup
*/
private UserAlertGroup insertOne(){
UserAlertGroup userAlertGroup = new UserAlertGroup();
userAlertGroup.setAlertgroupName("dolphin_alert_group");
userAlertGroup.setAlertgroupId(10);
userAlertGroup.setUserId(4);
userAlertGroup.setCreateTime(new Date());
userAlertGroup.setUpdateTime(new Date());
userAlertGroupMapper.insert(userAlertGroup);
return userAlertGroup;
}
/**
* insert one user
* @return User
*/
private User insertOneUser(){
User user = new User();
user.setUserName("user1");
user.setUserPassword("1");
user.setEmail("xx@123.com");
user.setUserType(UserType.GENERAL_USER);
user.setCreateTime(new Date());
user.setTenantId(1);
user.setQueue("dolphin");
user.setUpdateTime(new Date());
userMapper.insert(user);
return user;
}
/**
* insert one AlertGroup
* @return AlertGroup
*/
private AlertGroup insertOneAlertGroup(){
//insertOne
AlertGroup alertGroup = new AlertGroup();
alertGroup.setGroupName("alert group 1");
alertGroup.setDescription("alert test1");
alertGroup.setGroupType(AlertType.EMAIL);
alertGroup.setCreateTime(new Date());
alertGroup.setUpdateTime(new Date());
alertGroupMapper.insert(alertGroup);
return alertGroup;
}
/**
* test update
*/
@Test
public void testUpdate(){
//insertOneUser
User user = insertOneUser();
//insertOneAlertGroup
AlertGroup alertGroup = insertOneAlertGroup();
//insertOne
UserAlertGroup userAlertGroup = insertOne();
//update
userAlertGroup.setUserId(user.getId());
userAlertGroup.setAlertgroupId(alertGroup.getId());
userAlertGroup.setUpdateTime(new Date());
int update = userAlertGroupMapper.updateById(userAlertGroup);
Assert.assertEquals(update, 1);
}
/**
* test delete
*/
@Test
public void testDelete(){
//insertOne
UserAlertGroup userAlertGroup = insertOne();
//delete
int delete = userAlertGroupMapper.deleteById(userAlertGroup.getId());
Assert.assertEquals(delete, 1);
}
/**
* test query
*/
@Test
public void testQuery() {
//insertOne
UserAlertGroup userAlertGroup = insertOne();
//query
List<UserAlertGroup> userAlertGroupList = userAlertGroupMapper.selectList(null);
Assert.assertNotEquals(userAlertGroupList.size(), 0);
}
/**
* test delete by alertgroupId
*/
@Test
public void testDeleteByAlertgroupId() {
//insertOneUser
User user = insertOneUser();
//insertOneAlertGroup
AlertGroup alertGroup = insertOneAlertGroup();
//insertOne
UserAlertGroup userAlertGroup = insertOne(user,alertGroup);
int delete = userAlertGroupMapper.deleteByAlertgroupId(alertGroup.getId());
Assert.assertEquals(delete, 1);
}
/**
* test list user by alertgroupId
*/
@Test
public void testListUserByAlertgroupId() {
//insertOneUser
User user = insertOneUser();
//insertOneAlertGroup
AlertGroup alertGroup = insertOneAlertGroup();
//insertOne
UserAlertGroup userAlertGroup = insertOne(user,alertGroup);
List<User> userList = userAlertGroupMapper.listUserByAlertgroupId(alertGroup.getId());
Assert.assertNotEquals(userList.size(), 0);
}
}

88
dolphinscheduler-dao/src/test/java/org/apache/dolphinscheduler/dao/mapper/UserMapperTest.java

@ -14,14 +14,20 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.dao.mapper; package org.apache.dolphinscheduler.dao.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.enums.UserType; import org.apache.dolphinscheduler.common.enums.UserType;
import org.apache.dolphinscheduler.common.utils.DateUtils; import org.apache.dolphinscheduler.common.utils.DateUtils;
import org.apache.dolphinscheduler.dao.entity.*; import org.apache.dolphinscheduler.dao.entity.AccessToken;
import org.apache.dolphinscheduler.dao.entity.AlertGroup;
import org.apache.dolphinscheduler.dao.entity.Queue;
import org.apache.dolphinscheduler.dao.entity.Tenant;
import org.apache.dolphinscheduler.dao.entity.User;
import java.util.Date;
import java.util.List;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
@ -31,8 +37,8 @@ import org.springframework.test.annotation.Rollback;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.Date; import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@SpringBootTest @SpringBootTest
@ -45,9 +51,6 @@ public class UserMapperTest {
@Autowired @Autowired
AlertGroupMapper alertGroupMapper; AlertGroupMapper alertGroupMapper;
@Autowired
private UserAlertGroupMapper userAlertGroupMapper;
@Autowired @Autowired
AccessTokenMapper accessTokenMapper; AccessTokenMapper accessTokenMapper;
@ -59,6 +62,7 @@ public class UserMapperTest {
/** /**
* insert one user * insert one user
*
* @return User * @return User
*/ */
private User insertOne() { private User insertOne() {
@ -76,6 +80,7 @@ public class UserMapperTest {
/** /**
* insert one user * insert one user
*
* @param tenant tenant * @param tenant tenant
* @return User * @return User
*/ */
@ -94,6 +99,7 @@ public class UserMapperTest {
/** /**
* insert one user * insert one user
*
* @param queue queue * @param queue queue
* @param tenant tenant * @param tenant tenant
* @return User * @return User
@ -114,6 +120,7 @@ public class UserMapperTest {
/** /**
* insert one AlertGroup * insert one AlertGroup
*
* @return AlertGroup * @return AlertGroup
*/ */
private AlertGroup insertOneAlertGroup() { private AlertGroup insertOneAlertGroup() {
@ -121,7 +128,6 @@ public class UserMapperTest {
AlertGroup alertGroup = new AlertGroup(); AlertGroup alertGroup = new AlertGroup();
alertGroup.setGroupName("alert group 1"); alertGroup.setGroupName("alert group 1");
alertGroup.setDescription("alert test1"); alertGroup.setDescription("alert test1");
alertGroup.setGroupType(AlertType.EMAIL);
alertGroup.setCreateTime(new Date()); alertGroup.setCreateTime(new Date());
alertGroup.setUpdateTime(new Date()); alertGroup.setUpdateTime(new Date());
@ -129,25 +135,9 @@ public class UserMapperTest {
return alertGroup; return alertGroup;
} }
/**
* insert one UserAlertGroup
* @param user user
* @param alertGroup alertGroup
* @return UserAlertGroup
*/
private UserAlertGroup insertOneUserAlertGroup(User user,AlertGroup alertGroup){
UserAlertGroup userAlertGroup = new UserAlertGroup();
userAlertGroup.setAlertgroupName(alertGroup.getGroupName());
userAlertGroup.setAlertgroupId(alertGroup.getId());
userAlertGroup.setUserId(user.getId());
userAlertGroup.setCreateTime(new Date());
userAlertGroup.setUpdateTime(new Date());
userAlertGroupMapper.insert(userAlertGroup);
return userAlertGroup;
}
/** /**
* insert one AccessToken * insert one AccessToken
*
* @param user user * @param user user
* @return AccessToken * @return AccessToken
*/ */
@ -165,6 +155,7 @@ public class UserMapperTest {
/** /**
* insert one Tenant * insert one Tenant
*
* @return Tenant * @return Tenant
*/ */
private Tenant insertOneTenant() { private Tenant insertOneTenant() {
@ -181,6 +172,7 @@ public class UserMapperTest {
/** /**
* insert one Tenant * insert one Tenant
*
* @return Tenant * @return Tenant
*/ */
private Tenant insertOneTenant(Queue queue) { private Tenant insertOneTenant(Queue queue) {
@ -198,6 +190,7 @@ public class UserMapperTest {
/** /**
* insert one Queue * insert one Queue
*
* @return Queue * @return Queue
*/ */
private Queue insertOneQueue() { private Queue insertOneQueue() {
@ -261,30 +254,6 @@ public class UserMapperTest {
Assert.assertNotEquals(userList.size(), 0); Assert.assertNotEquals(userList.size(), 0);
} }
// /**
// * test query by username
// */
// @Test
// public void testQueryByUserNameAccurately() {
// //insertOne
// User user = insertOne();
// //queryByUserNameAccurately
// User queryUser = userMapper.queryByUserNameAccurately(user.getUserName());
// Assert.assertEquals(queryUser.getUserName(), user.getUserName());
// }
// /**
// * test query by username and password
// */
// @Test
// public void testQueryUserByNamePassword() {
// //insertOne
// User user = insertOne();
// //queryUserByNamePassword
// User queryUser = userMapper.queryUserByNamePassword(user.getUserName(),user.getUserPassword());
// Assert.assertEquals(queryUser.getUserName(),user.getUserName());
// Assert.assertEquals(queryUser.getUserPassword(), user.getUserPassword());
// }
/** /**
* test page * test page
@ -317,23 +286,6 @@ public class UserMapperTest {
Assert.assertEquals(user.getUserName(), queryUser.getUserName()); Assert.assertEquals(user.getUserName(), queryUser.getUserName());
} }
/**
* test query user list by alertgroupId
*/
@Test
public void testQueryUserListByAlertGroupId() {
//insertOne
User user = insertOne();
//insertOneAlertGroup
AlertGroup alertGroup = insertOneAlertGroup();
//insertOneUserAlertGroup
UserAlertGroup userAlertGroup = insertOneUserAlertGroup(user, alertGroup);
//queryUserListByAlertGroupId
List<User> userList = userMapper.queryUserListByAlertGroupId(userAlertGroup.getAlertgroupId());
Assert.assertNotEquals(userList.size(), 0);
}
/** /**
* test query tenant code by userId * test query tenant code by userId
*/ */

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

@ -14,8 +14,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.server.master.runner;
package org.apache.dolphinscheduler.server.master.runner;
import org.apache.dolphinscheduler.common.Constants; import org.apache.dolphinscheduler.common.Constants;
import org.apache.dolphinscheduler.common.enums.ExecutionStatus; import org.apache.dolphinscheduler.common.enums.ExecutionStatus;
@ -42,7 +42,6 @@ import org.apache.dolphinscheduler.service.bean.SpringApplicationContext;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.Set;
/** /**
* master task exec thread * master task exec thread
*/ */
@ -64,6 +63,7 @@ public class MasterTaskExecThread extends MasterBaseTaskExecThread {
/** /**
* constructor of MasterTaskExecThread * constructor of MasterTaskExecThread
*
* @param taskInstance task instance * @param taskInstance task instance
*/ */
public MasterTaskExecThread(TaskInstance taskInstance) { public MasterTaskExecThread(TaskInstance taskInstance) {
@ -75,6 +75,7 @@ public class MasterTaskExecThread extends MasterBaseTaskExecThread {
/** /**
* get task instance * get task instance
*
* @return TaskInstance * @return TaskInstance
*/ */
@Override @Override
@ -112,8 +113,9 @@ public class MasterTaskExecThread extends MasterBaseTaskExecThread {
/** /**
* polling db * polling db
* * <p>
* wait task quit * wait task quit
*
* @return true if task quit success * @return true if task quit success
*/ */
public Boolean waitTaskQuit() { public Boolean waitTaskQuit() {
@ -157,8 +159,7 @@ 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(), alertDao.sendTaskTimeoutAlert(processInstance.getWarningGroupId(), processInstance.getId(), processInstance.getName(),
processDefine.getReceiversCc(), processInstance.getId(), processInstance.getName(),
taskInstance.getId(), taskInstance.getName()); taskInstance.getId(), taskInstance.getName());
checkTimeout = false; checkTimeout = false;
} }
@ -180,7 +181,6 @@ public class MasterTaskExecThread extends MasterBaseTaskExecThread {
/** /**
* pause task if task have not been dispatched to worker, do not dispatch anymore. * pause task if task have not been dispatched to worker, do not dispatch anymore.
*
*/ */
public void pauseTask() { public void pauseTask() {
taskInstance = processService.findTaskInstanceById(taskInstance.getId()); taskInstance = processService.findTaskInstanceById(taskInstance.getId());
@ -194,7 +194,6 @@ public class MasterTaskExecThread extends MasterBaseTaskExecThread {
} }
} }
/** /**
* task instance add queue , waiting worker to kill * task instance add queue , waiting worker to kill
*/ */
@ -227,6 +226,7 @@ public class MasterTaskExecThread extends MasterBaseTaskExecThread {
/** /**
* whether exists valid worker group * whether exists valid worker group
*
* @param taskInstanceWorkerGroup taskInstanceWorkerGroup * @param taskInstanceWorkerGroup taskInstanceWorkerGroup
* @return whether exists * @return whether exists
*/ */
@ -250,6 +250,7 @@ public class MasterTaskExecThread extends MasterBaseTaskExecThread {
/** /**
* get task timeout parameter * get task timeout parameter
*
* @return TaskTimeoutParameter * @return TaskTimeoutParameter
*/ */
private TaskTimeoutParameter getTaskTimeoutParameter() { private TaskTimeoutParameter getTaskTimeoutParameter() {

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

@ -17,7 +17,6 @@
package org.apache.dolphinscheduler.server.utils; package org.apache.dolphinscheduler.server.utils;
import org.apache.dolphinscheduler.common.enums.AlertType;
import org.apache.dolphinscheduler.common.enums.CommandType; import org.apache.dolphinscheduler.common.enums.CommandType;
import org.apache.dolphinscheduler.common.enums.WarningType; import org.apache.dolphinscheduler.common.enums.WarningType;
import org.apache.dolphinscheduler.common.utils.JSONUtils; import org.apache.dolphinscheduler.common.utils.JSONUtils;
@ -28,7 +27,6 @@ import org.apache.dolphinscheduler.dao.entity.ProcessAlertContent;
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; import org.apache.dolphinscheduler.dao.entity.ProcessDefinition;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance; import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.entity.TaskInstance; import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.spi.alert.ShowType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -171,14 +169,10 @@ public class AlertManager {
try { try {
Alert alert = new Alert(); Alert alert = new Alert();
alert.setTitle("worker fault tolerance"); alert.setTitle("worker fault tolerance");
//alert.setShowType(ShowType.TABLE);
String content = getWorkerToleranceContent(processInstance, toleranceTaskList); String content = getWorkerToleranceContent(processInstance, toleranceTaskList);
alert.setContent(content); alert.setContent(content);
alert.setAlertType(AlertType.EMAIL);
alert.setCreateTime(new Date()); alert.setCreateTime(new Date());
alert.setAlertGroupId(processInstance.getWarningGroupId() == null ? 1 : processInstance.getWarningGroupId()); alert.setAlertGroupId(processInstance.getWarningGroupId() == null ? 1 : processInstance.getWarningGroupId());
alert.setReceivers(processInstance.getProcessDefinition().getReceivers());
alert.setReceiversCc(processInstance.getProcessDefinition().getReceiversCc());
alertDao.addAlert(alert); alertDao.addAlert(alert);
logger.info("add alert to db , alert : {}", alert.toString()); logger.info("add alert to db , alert : {}", alert.toString());
@ -225,16 +219,10 @@ public class AlertManager {
String cmdName = getCommandCnName(processInstance.getCommandType()); String cmdName = getCommandCnName(processInstance.getCommandType());
String success = processInstance.getState().typeIsSuccess() ? "success" : "failed"; String success = processInstance.getState().typeIsSuccess() ? "success" : "failed";
alert.setTitle(cmdName + " " + success); alert.setTitle(cmdName + " " + success);
ShowType showType = processInstance.getState().typeIsSuccess() ? ShowType.TEXT : ShowType.TABLE;
//alert.setShowType(showType);
String content = getContentProcessInstance(processInstance, taskInstances); String content = getContentProcessInstance(processInstance, taskInstances);
alert.setContent(content); alert.setContent(content);
alert.setAlertType(AlertType.EMAIL);
alert.setAlertGroupId(processInstance.getWarningGroupId()); alert.setAlertGroupId(processInstance.getWarningGroupId());
alert.setCreateTime(new Date()); alert.setCreateTime(new Date());
alert.setReceivers(processInstance.getProcessDefinition().getReceivers());
alert.setReceiversCc(processInstance.getProcessDefinition().getReceiversCc());
alertDao.addAlert(alert); alertDao.addAlert(alert);
logger.info("add alert to db , alert: {}", alert.toString()); logger.info("add alert to db , alert: {}", alert.toString());
} }

7
dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/registry/DependencyConfig.java

@ -34,7 +34,6 @@ import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
import org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.server.master.cache.impl.TaskInstanceCacheManagerImpl; import org.apache.dolphinscheduler.server.master.cache.impl.TaskInstanceCacheManagerImpl;
import org.apache.dolphinscheduler.server.master.config.MasterConfig; import org.apache.dolphinscheduler.server.master.config.MasterConfig;
@ -66,11 +65,6 @@ public class DependencyConfig {
return Mockito.mock(AlertMapper.class); return Mockito.mock(AlertMapper.class);
} }
@Bean
public UserAlertGroupMapper userAlertGroupMapper() {
return Mockito.mock(UserAlertGroupMapper.class);
}
@Bean @Bean
public TaskInstanceCacheManagerImpl taskInstanceCacheManagerImpl() { public TaskInstanceCacheManagerImpl taskInstanceCacheManagerImpl() {
return Mockito.mock(TaskInstanceCacheManagerImpl.class); return Mockito.mock(TaskInstanceCacheManagerImpl.class);
@ -136,7 +130,6 @@ public class DependencyConfig {
return Mockito.mock(ResourceMapper.class); return Mockito.mock(ResourceMapper.class);
} }
@Bean @Bean
public ErrorCommandMapper errorCommandMapper() { public ErrorCommandMapper errorCommandMapper() {
return Mockito.mock(ErrorCommandMapper.class); return Mockito.mock(ErrorCommandMapper.class);

8
dolphinscheduler-server/src/test/java/org/apache/dolphinscheduler/server/worker/processor/TaskCallbackServiceTestConfig.java

@ -34,7 +34,6 @@ import org.apache.dolphinscheduler.dao.mapper.ScheduleMapper;
import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper; import org.apache.dolphinscheduler.dao.mapper.TaskInstanceMapper;
import org.apache.dolphinscheduler.dao.mapper.TenantMapper; import org.apache.dolphinscheduler.dao.mapper.TenantMapper;
import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper; import org.apache.dolphinscheduler.dao.mapper.UdfFuncMapper;
import org.apache.dolphinscheduler.dao.mapper.UserAlertGroupMapper;
import org.apache.dolphinscheduler.dao.mapper.UserMapper; import org.apache.dolphinscheduler.dao.mapper.UserMapper;
import org.apache.dolphinscheduler.server.master.cache.impl.TaskInstanceCacheManagerImpl; import org.apache.dolphinscheduler.server.master.cache.impl.TaskInstanceCacheManagerImpl;
import org.apache.dolphinscheduler.service.process.ProcessService; import org.apache.dolphinscheduler.service.process.ProcessService;
@ -49,7 +48,6 @@ import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
public class TaskCallbackServiceTestConfig { public class TaskCallbackServiceTestConfig {
@Bean @Bean
public AlertDao alertDao() { public AlertDao alertDao() {
return new AlertDao(); return new AlertDao();
@ -60,11 +58,6 @@ public class TaskCallbackServiceTestConfig {
return Mockito.mock(AlertMapper.class); return Mockito.mock(AlertMapper.class);
} }
@Bean
public UserAlertGroupMapper userAlertGroupMapper() {
return Mockito.mock(UserAlertGroupMapper.class);
}
@Bean @Bean
public TaskInstanceCacheManagerImpl taskInstanceCacheManagerImpl() { public TaskInstanceCacheManagerImpl taskInstanceCacheManagerImpl() {
return Mockito.mock(TaskInstanceCacheManagerImpl.class); return Mockito.mock(TaskInstanceCacheManagerImpl.class);
@ -125,7 +118,6 @@ public class TaskCallbackServiceTestConfig {
return Mockito.mock(ResourceMapper.class); return Mockito.mock(ResourceMapper.class);
} }
@Bean @Bean
public ErrorCommandMapper errorCommandMapper() { public ErrorCommandMapper errorCommandMapper() {
return Mockito.mock(ErrorCommandMapper.class); return Mockito.mock(ErrorCommandMapper.class);

112
dolphinscheduler-service/src/main/java/org/apache/dolphinscheduler/service/process/ProcessService.java

@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.dolphinscheduler.service.process; package org.apache.dolphinscheduler.service.process;
import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE; import static org.apache.dolphinscheduler.common.Constants.CMDPARAM_COMPLEMENT_DATA_END_DATE;
@ -145,7 +146,6 @@ public class ProcessService {
private ResourceMapper resourceMapper; private ResourceMapper resourceMapper;
@Autowired @Autowired
private ErrorCommandMapper errorCommandMapper; private ErrorCommandMapper errorCommandMapper;
@ -157,6 +157,7 @@ public class ProcessService {
/** /**
* handle Command (construct ProcessInstance from Command) , wrapped in transaction * handle Command (construct ProcessInstance from Command) , wrapped in transaction
*
* @param logger logger * @param logger logger
* @param host host * @param host host
* @param validThreadNum validThreadNum * @param validThreadNum validThreadNum
@ -186,6 +187,7 @@ public class ProcessService {
/** /**
* save error command, and delete original command * save error command, and delete original command
*
* @param command command * @param command command
* @param message message * @param message message
*/ */
@ -198,6 +200,7 @@ public class ProcessService {
/** /**
* set process waiting thread * set process waiting thread
*
* @param command command * @param command command
* @param processInstance processInstance * @param processInstance processInstance
* @return process instance * @return process instance
@ -215,6 +218,7 @@ public class ProcessService {
/** /**
* check thread num * check thread num
*
* @param command command * @param command command
* @param validThreadNum validThreadNum * @param validThreadNum validThreadNum
* @return if thread is enough * @return if thread is enough
@ -226,6 +230,7 @@ public class ProcessService {
/** /**
* insert one command * insert one command
*
* @param command command * @param command command
* @return create result * @return create result
*/ */
@ -239,6 +244,7 @@ public class ProcessService {
/** /**
* find one command from queue list * find one command from queue list
*
* @return command * @return command
*/ */
public Command findOneCommand() { public Command findOneCommand() {
@ -247,6 +253,7 @@ public class ProcessService {
/** /**
* check the input command exists in queue list * check the input command exists in queue list
*
* @param command command * @param command command
* @return create command result * @return create command result
*/ */
@ -279,6 +286,7 @@ public class ProcessService {
/** /**
* find process instance detail by id * find process instance detail by id
*
* @param processId processId * @param processId processId
* @return process instance * @return process instance
*/ */
@ -288,6 +296,7 @@ public class ProcessService {
/** /**
* get task node list by definitionId * get task node list by definitionId
*
* @param defineId * @param defineId
* @return * @return
*/ */
@ -312,6 +321,7 @@ public class ProcessService {
/** /**
* find process instance by id * find process instance by id
*
* @param processId processId * @param processId processId
* @return process instance * @return process instance
*/ */
@ -321,6 +331,7 @@ public class ProcessService {
/** /**
* find process define by id. * find process define by id.
*
* @param processDefinitionId processDefinitionId * @param processDefinitionId processDefinitionId
* @return process definition * @return process definition
*/ */
@ -330,6 +341,7 @@ public class ProcessService {
/** /**
* delete work process instance by id * delete work process instance by id
*
* @param processInstanceId processInstanceId * @param processInstanceId processInstanceId
* @return delete process instance result * @return delete process instance result
*/ */
@ -339,6 +351,7 @@ public class ProcessService {
/** /**
* delete all sub process by parent instance id * delete all sub process by parent instance id
*
* @param processInstanceId processInstanceId * @param processInstanceId processInstanceId
* @return delete all sub process instance result * @return delete all sub process instance result
*/ */
@ -355,9 +368,9 @@ public class ProcessService {
return 1; return 1;
} }
/** /**
* remove task log file * remove task log file
*
* @param processInstanceId processInstanceId * @param processInstanceId processInstanceId
*/ */
public void removeTaskLogFile(Integer processInstanceId) { public void removeTaskLogFile(Integer processInstanceId) {
@ -383,16 +396,14 @@ public class ProcessService {
// compatible old version // compatible old version
ip = taskInstance.getHost(); ip = taskInstance.getHost();
} }
// remove task log from loggerserver // remove task log from loggerserver
logClient.removeTaskLog(ip, port, taskLogPath); logClient.removeTaskLog(ip, port, taskLogPath);
} }
} }
/** /**
* calculate sub process number in the process define. * calculate sub process number in the process define.
*
* @param processDefinitionId processDefinitionId * @param processDefinitionId processDefinitionId
* @return process thread num count * @return process thread num count
*/ */
@ -404,6 +415,7 @@ public class ProcessService {
/** /**
* recursive query sub process definition id by parent id. * recursive query sub process definition id by parent id.
*
* @param parentId parentId * @param parentId parentId
* @param ids ids * @param ids ids
*/ */
@ -435,6 +447,7 @@ public class ProcessService {
* sub work process instance need not to create recovery command. * sub work process instance need not to create recovery command.
* create recovery waiting thread command and delete origin command at the same time. * create recovery waiting thread command and delete origin command at the same time.
* if the recovery command is exists, only update the field update_time * if the recovery command is exists, only update the field update_time
*
* @param originCommand originCommand * @param originCommand originCommand
* @param processInstance processInstance * @param processInstance processInstance
*/ */
@ -485,6 +498,7 @@ public class ProcessService {
/** /**
* get schedule time from command * get schedule time from command
*
* @param command command * @param command command
* @param cmdParam cmdParam map * @param cmdParam cmdParam map
* @return date * @return date
@ -501,6 +515,7 @@ public class ProcessService {
/** /**
* generate a new work process instance from command. * generate a new work process instance from command.
*
* @param processDefinition processDefinition * @param processDefinition processDefinition
* @param command command * @param command command
* @param cmdParam cmdParam map * @param cmdParam cmdParam map
@ -558,6 +573,7 @@ public class ProcessService {
* there is tenant id in definition, use the tenant of the definition. * there is tenant id in definition, use the tenant of the definition.
* if there is not tenant id in the definiton or the tenant not exist * if there is not tenant id in the definiton or the tenant not exist
* use definition creator's tenant. * use definition creator's tenant.
*
* @param tenantId tenantId * @param tenantId tenantId
* @param userId userId * @param userId userId
* @return tenant * @return tenant
@ -581,6 +597,7 @@ public class ProcessService {
/** /**
* check command parameters is valid * check command parameters is valid
*
* @param command command * @param command command
* @param cmdParam cmdParam map * @param cmdParam cmdParam map
* @return whether command param is valid * @return whether command param is valid
@ -599,6 +616,7 @@ public class ProcessService {
/** /**
* construct process instance according to one command. * construct process instance according to one command.
*
* @param command command * @param command command
* @param host host * @param host host
* @return process instance * @return process instance
@ -755,6 +773,7 @@ public class ProcessService {
/** /**
* return complement data if the process start with complement data * return complement data if the process start with complement data
*
* @param processInstance processInstance * @param processInstance processInstance
* @param command command * @param command command
* @return command type * @return command type
@ -769,6 +788,7 @@ public class ProcessService {
/** /**
* initialize complement data parameters * initialize complement data parameters
*
* @param processDefinition processDefinition * @param processDefinition processDefinition
* @param processInstance processInstance * @param processInstance processInstance
* @param cmdParam cmdParam * @param cmdParam cmdParam
@ -792,11 +812,11 @@ public class ProcessService {
} }
/** /**
* set sub work process parameters. * set sub work process parameters.
* handle sub work process instance, update relation table and command parameters * handle sub work process instance, update relation table and command parameters
* set sub work process flag, extends parent work process command parameters * set sub work process flag, extends parent work process command parameters
*
* @param subProcessInstance subProcessInstance * @param subProcessInstance subProcessInstance
* @return process instance * @return process instance
*/ */
@ -841,6 +861,7 @@ public class ProcessService {
/** /**
* join parent global params into sub process. * join parent global params into sub process.
* only the keys doesn't in sub process global would be joined. * only the keys doesn't in sub process global would be joined.
*
* @param parentGlobalParams parentGlobalParams * @param parentGlobalParams parentGlobalParams
* @param subGlobalParams subGlobalParams * @param subGlobalParams subGlobalParams
* @return global params join * @return global params join
@ -862,6 +883,7 @@ public class ProcessService {
/** /**
* initialize task instance * initialize task instance
*
* @param taskInstance taskInstance * @param taskInstance taskInstance
*/ */
private void initTaskInstance(TaskInstance taskInstance) { private void initTaskInstance(TaskInstance taskInstance) {
@ -880,6 +902,7 @@ public class ProcessService {
/** /**
* submit task to db * submit task to db
* submit sub process to command * submit sub process to command
*
* @param taskInstance taskInstance * @param taskInstance taskInstance
* @return task instance * @return task instance
*/ */
@ -909,6 +932,7 @@ public class ProcessService {
* consider o * consider o
* repeat running does not generate new sub process instance * repeat running does not generate new sub process instance
* set map {parent instance id, task instance id, 0(child instance id)} * set map {parent instance id, task instance id, 0(child instance id)}
*
* @param parentInstance parentInstance * @param parentInstance parentInstance
* @param parentTask parentTask * @param parentTask parentTask
* @return process instance map * @return process instance map
@ -937,6 +961,7 @@ public class ProcessService {
/** /**
* find previous task work process map. * find previous task work process map.
*
* @param parentProcessInstance parentProcessInstance * @param parentProcessInstance parentProcessInstance
* @param parentTask parentTask * @param parentTask parentTask
* @return process instance map * @return process instance map
@ -990,6 +1015,7 @@ public class ProcessService {
/** /**
* complement data needs transform parent parameter to child. * complement data needs transform parent parameter to child.
*
* @param instanceMap * @param instanceMap
* @param parentProcessInstance * @param parentProcessInstance
* @return * @return
@ -1011,6 +1037,7 @@ public class ProcessService {
/** /**
* create sub work process command * create sub work process command
*
* @param parentProcessInstance * @param parentProcessInstance
* @param childInstance * @param childInstance
* @param instanceMap * @param instanceMap
@ -1043,6 +1070,7 @@ public class ProcessService {
/** /**
* initialize sub work flow state * initialize sub work flow state
* child instance state would be initialized when 'recovery from pause/stop/failure' * child instance state would be initialized when 'recovery from pause/stop/failure'
*
* @param childInstance * @param childInstance
*/ */
private void initSubInstanceState(ProcessInstance childInstance) { private void initSubInstanceState(ProcessInstance childInstance) {
@ -1070,7 +1098,8 @@ public class ProcessService {
} }
/** /**
* update sub process definition * update sub process definition todo
*
* @param parentProcessInstance parentProcessInstance * @param parentProcessInstance parentProcessInstance
* @param childDefinitionId childDefinitionId * @param childDefinitionId childDefinitionId
*/ */
@ -1078,14 +1107,14 @@ public class ProcessService {
ProcessDefinition fatherDefinition = this.findProcessDefineById(parentProcessInstance.getProcessDefinitionId()); ProcessDefinition fatherDefinition = this.findProcessDefineById(parentProcessInstance.getProcessDefinitionId());
ProcessDefinition childDefinition = this.findProcessDefineById(childDefinitionId); ProcessDefinition childDefinition = this.findProcessDefineById(childDefinitionId);
if (childDefinition != null && fatherDefinition != null) { if (childDefinition != null && fatherDefinition != null) {
childDefinition.setReceivers(fatherDefinition.getReceivers()); childDefinition.setWarningGroupId(fatherDefinition.getWarningGroupId());
childDefinition.setReceiversCc(fatherDefinition.getReceiversCc());
processDefineMapper.updateById(childDefinition); processDefineMapper.updateById(childDefinition);
} }
} }
/** /**
* submit task to mysql * submit task to mysql
*
* @param taskInstance taskInstance * @param taskInstance taskInstance
* @param processInstance processInstance * @param processInstance processInstance
* @return task instance * @return task instance
@ -1132,10 +1161,10 @@ public class ProcessService {
return taskInstance; return taskInstance;
} }
/** /**
* ${processInstancePriority}_${processInstanceId}_${taskInstancePriority}_${taskInstanceId}_${task executed by ip1},${ip2}... * ${processInstancePriority}_${processInstanceId}_${taskInstancePriority}_${taskInstanceId}_${task executed by ip1},${ip2}...
* The tasks with the highest priority are selected by comparing the priorities of the above four levels from high to low. * The tasks with the highest priority are selected by comparing the priorities of the above four levels from high to low.
*
* @param taskInstance taskInstance * @param taskInstance taskInstance
* @return task zk queue str * @return task zk queue str
*/ */
@ -1199,6 +1228,7 @@ public class ProcessService {
/** /**
* check process instance strategy * check process instance strategy
*
* @param taskInstance taskInstance * @param taskInstance taskInstance
* @return check strategy result * @return check strategy result
*/ */
@ -1220,6 +1250,7 @@ public class ProcessService {
/** /**
* check the task instance existing in queue * check the task instance existing in queue
*
* @param taskInstance taskInstance * @param taskInstance taskInstance
* @return whether taskinstance exists queue * @return whether taskinstance exists queue
*/ */
@ -1235,6 +1266,7 @@ public class ProcessService {
/** /**
* create a new process instance * create a new process instance
*
* @param processInstance processInstance * @param processInstance processInstance
*/ */
public void createProcessInstance(ProcessInstance processInstance) { public void createProcessInstance(ProcessInstance processInstance) {
@ -1246,6 +1278,7 @@ public class ProcessService {
/** /**
* insert or update work process instance to data base * insert or update work process instance to data base
*
* @param processInstance processInstance * @param processInstance processInstance
*/ */
public void saveProcessInstance(ProcessInstance processInstance) { public void saveProcessInstance(ProcessInstance processInstance) {
@ -1263,6 +1296,7 @@ public class ProcessService {
/** /**
* insert or update command * insert or update command
*
* @param command command * @param command command
* @return save command result * @return save command result
*/ */
@ -1276,6 +1310,7 @@ public class ProcessService {
/** /**
* insert or update task instance * insert or update task instance
*
* @param taskInstance taskInstance * @param taskInstance taskInstance
* @return save task instance result * @return save task instance result
*/ */
@ -1289,6 +1324,7 @@ public class ProcessService {
/** /**
* insert task instance * insert task instance
*
* @param taskInstance taskInstance * @param taskInstance taskInstance
* @return create task instance result * @return create task instance result
*/ */
@ -1299,6 +1335,7 @@ public class ProcessService {
/** /**
* update task instance * update task instance
*
* @param taskInstance taskInstance * @param taskInstance taskInstance
* @return update task instance result * @return update task instance result
*/ */
@ -1306,8 +1343,10 @@ public class ProcessService {
int count = taskInstanceMapper.updateById(taskInstance); int count = taskInstanceMapper.updateById(taskInstance);
return count > 0; return count > 0;
} }
/** /**
* delete a command by id * delete a command by id
*
* @param id id * @param id id
*/ */
public void delCommandByid(int id) { public void delCommandByid(int id) {
@ -1316,6 +1355,7 @@ public class ProcessService {
/** /**
* find task instance by id * find task instance by id
*
* @param taskId task id * @param taskId task id
* @return task intance * @return task intance
*/ */
@ -1323,9 +1363,9 @@ public class ProcessService {
return taskInstanceMapper.selectById(taskId); return taskInstanceMapper.selectById(taskId);
} }
/** /**
* package task instanceassociate processInstance and processDefine * package task instanceassociate processInstance and processDefine
*
* @param taskInstId taskInstId * @param taskInstId taskInstId
* @return task instance * @return task instance
*/ */
@ -1345,9 +1385,9 @@ public class ProcessService {
return taskInstance; return taskInstance;
} }
/** /**
* get id list by task state * get id list by task state
*
* @param instanceId instanceId * @param instanceId instanceId
* @param state state * @param state state
* @return task instance states * @return task instance states
@ -1358,6 +1398,7 @@ public class ProcessService {
/** /**
* find valid task list by process definition id * find valid task list by process definition id
*
* @param processInstanceId processInstanceId * @param processInstanceId processInstanceId
* @return task instance list * @return task instance list
*/ */
@ -1367,6 +1408,7 @@ public class ProcessService {
/** /**
* find previous task list by work process id * find previous task list by work process id
*
* @param processInstanceId processInstanceId * @param processInstanceId processInstanceId
* @return task instance list * @return task instance list
*/ */
@ -1376,6 +1418,7 @@ public class ProcessService {
/** /**
* update work process instance map * update work process instance map
*
* @param processInstanceMap processInstanceMap * @param processInstanceMap processInstanceMap
* @return update process instance result * @return update process instance result
*/ */
@ -1383,9 +1426,9 @@ public class ProcessService {
return processInstanceMapMapper.updateById(processInstanceMap); return processInstanceMapMapper.updateById(processInstanceMap);
} }
/** /**
* create work process instance map * create work process instance map
*
* @param processInstanceMap processInstanceMap * @param processInstanceMap processInstanceMap
* @return create process instance result * @return create process instance result
*/ */
@ -1399,6 +1442,7 @@ public class ProcessService {
/** /**
* find work process map by parent process id and parent task id. * find work process map by parent process id and parent task id.
*
* @param parentWorkProcessId parentWorkProcessId * @param parentWorkProcessId parentWorkProcessId
* @param parentTaskId parentTaskId * @param parentTaskId parentTaskId
* @return process instance map * @return process instance map
@ -1409,6 +1453,7 @@ public class ProcessService {
/** /**
* delete work process map by parent process id * delete work process map by parent process id
*
* @param parentWorkProcessId parentWorkProcessId * @param parentWorkProcessId parentWorkProcessId
* @return delete process map result * @return delete process map result
*/ */
@ -1419,6 +1464,7 @@ public class ProcessService {
/** /**
* find sub process instance * find sub process instance
*
* @param parentProcessId parentProcessId * @param parentProcessId parentProcessId
* @param parentTaskId parentTaskId * @param parentTaskId parentTaskId
* @return process instance * @return process instance
@ -1435,6 +1481,7 @@ public class ProcessService {
/** /**
* find parent process instance * find parent process instance
*
* @param subProcessId subProcessId * @param subProcessId subProcessId
* @return process instance * @return process instance
*/ */
@ -1448,9 +1495,9 @@ public class ProcessService {
return processInstance; return processInstance;
} }
/** /**
* change task state * change task state
*
* @param state state * @param state state
* @param startTime startTime * @param startTime startTime
* @param host host * @param host host
@ -1473,6 +1520,7 @@ public class ProcessService {
/** /**
* update process instance * update process instance
*
* @param processInstance processInstance * @param processInstance processInstance
* @return update process instance result * @return update process instance result
*/ */
@ -1482,6 +1530,7 @@ public class ProcessService {
/** /**
* update the process instance * update the process instance
*
* @param processInstanceId processInstanceId * @param processInstanceId processInstanceId
* @param processJson processJson * @param processJson processJson
* @param globalParams globalParams * @param globalParams globalParams
@ -1508,6 +1557,7 @@ public class ProcessService {
/** /**
* change task state * change task state
*
* @param state state * @param state state
* @param endTime endTime * @param endTime endTime
* @param taskInstId taskInstId * @param taskInstId taskInstId
@ -1530,6 +1580,7 @@ public class ProcessService {
/** /**
* convert integer list to string list * convert integer list to string list
*
* @param intList intList * @param intList intList
* @return string list * @return string list
*/ */
@ -1546,6 +1597,7 @@ public class ProcessService {
/** /**
* query schedule by id * query schedule by id
*
* @param id id * @param id id
* @return schedule * @return schedule
*/ */
@ -1555,6 +1607,7 @@ public class ProcessService {
/** /**
* query Schedule by processDefinitionId * query Schedule by processDefinitionId
*
* @param processDefinitionId processDefinitionId * @param processDefinitionId processDefinitionId
* @see Schedule * @see Schedule
*/ */
@ -1564,6 +1617,7 @@ public class ProcessService {
/** /**
* query need failover process instance * query need failover process instance
*
* @param host host * @param host host
* @return process instance list * @return process instance list
*/ */
@ -1574,6 +1628,7 @@ public class ProcessService {
/** /**
* process need failover process instance * process need failover process instance
*
* @param processInstance processInstance * @param processInstance processInstance
*/ */
@Transactional(rollbackFor = RuntimeException.class) @Transactional(rollbackFor = RuntimeException.class)
@ -1593,6 +1648,7 @@ public class ProcessService {
/** /**
* query all need failover task instances by host * query all need failover task instances by host
*
* @param host host * @param host host
* @return task instance list * @return task instance list
*/ */
@ -1603,6 +1659,7 @@ public class ProcessService {
/** /**
* find data source by id * find data source by id
*
* @param id id * @param id id
* @return datasource * @return datasource
*/ */
@ -1610,9 +1667,9 @@ public class ProcessService {
return dataSourceMapper.selectById(id); return dataSourceMapper.selectById(id);
} }
/** /**
* update process instance state by id * update process instance state by id
*
* @param processInstanceId processInstanceId * @param processInstanceId processInstanceId
* @param executionStatus executionStatus * @param executionStatus executionStatus
* @return update process result * @return update process result
@ -1626,6 +1683,7 @@ public class ProcessService {
/** /**
* find process instance by the task id * find process instance by the task id
*
* @param taskId taskId * @param taskId taskId
* @return process instance * @return process instance
*/ */
@ -1639,6 +1697,7 @@ public class ProcessService {
/** /**
* find udf function list by id list string * find udf function list by id list string
*
* @param ids ids * @param ids ids
* @return udf function list * @return udf function list
*/ */
@ -1648,6 +1707,7 @@ public class ProcessService {
/** /**
* find tenant code by resource name * find tenant code by resource name
*
* @param resName resource name * @param resName resource name
* @param resourceType resource type * @param resourceType resource type
* @return tenant code * @return tenant code
@ -1658,6 +1718,7 @@ public class ProcessService {
/** /**
* find schedule list by process define id. * find schedule list by process define id.
*
* @param ids ids * @param ids ids
* @return schedule list * @return schedule list
*/ */
@ -1668,6 +1729,7 @@ public class ProcessService {
/** /**
* get dependency cycle by work process define id and scheduler fire time * get dependency cycle by work process define id and scheduler fire time
*
* @param masterId masterId * @param masterId masterId
* @param processDefinitionId processDefinitionId * @param processDefinitionId processDefinitionId
* @param scheduledFireTime the time the task schedule is expected to trigger * @param scheduledFireTime the time the task schedule is expected to trigger
@ -1682,6 +1744,7 @@ public class ProcessService {
/** /**
* get dependency cycle list by work process define id list and scheduler fire time * get dependency cycle list by work process define id list and scheduler fire time
*
* @param masterId masterId * @param masterId masterId
* @param ids ids * @param ids ids
* @param scheduledFireTime the time the task schedule is expected to trigger * @param scheduledFireTime the time the task schedule is expected to trigger
@ -1699,7 +1762,6 @@ public class ProcessService {
return cycleDependencyList; return cycleDependencyList;
} }
String strCrontab = ""; String strCrontab = "";
CronExpression depCronExpression; CronExpression depCronExpression;
Cron depCron; Cron depCron;
@ -1754,6 +1816,7 @@ public class ProcessService {
/** /**
* find last scheduler process instance in the date interval * find last scheduler process instance in the date interval
*
* @param definitionId definitionId * @param definitionId definitionId
* @param dateInterval dateInterval * @param dateInterval dateInterval
* @return process instance * @return process instance
@ -1766,6 +1829,7 @@ public class ProcessService {
/** /**
* find last manual process instance interval * find last manual process instance interval
*
* @param definitionId process definition id * @param definitionId process definition id
* @param dateInterval dateInterval * @param dateInterval dateInterval
* @return process instance * @return process instance
@ -1778,6 +1842,7 @@ public class ProcessService {
/** /**
* find last running process instance * find last running process instance
*
* @param definitionId process definition id * @param definitionId process definition id
* @param startTime start time * @param startTime start time
* @param endTime end time * @param endTime end time
@ -1792,6 +1857,7 @@ public class ProcessService {
/** /**
* query user queue by process instance id * query user queue by process instance id
*
* @param processInstanceId processInstanceId * @param processInstanceId processInstanceId
* @return queue * @return queue
*/ */
@ -1809,16 +1875,14 @@ public class ProcessService {
return queue; return queue;
} }
/** /**
* get task worker group * get task worker group
*
* @param taskInstance taskInstance * @param taskInstance taskInstance
* @return workerGroupId * @return workerGroupId
*/ */
public String getTaskWorkerGroup(TaskInstance taskInstance) { public String getTaskWorkerGroup(TaskInstance taskInstance) {
String workerGroup = taskInstance.getWorkerGroup(); String workerGroup = taskInstance.getWorkerGroup();
if (StringUtils.isNotBlank(workerGroup)) { if (StringUtils.isNotBlank(workerGroup)) {
return workerGroup; return workerGroup;
} }
@ -1834,6 +1898,7 @@ public class ProcessService {
/** /**
* get have perm project list * get have perm project list
*
* @param userId userId * @param userId userId
* @return project list * @return project list
*/ */
@ -1853,6 +1918,7 @@ public class ProcessService {
/** /**
* get have perm project ids * get have perm project ids
*
* @param userId userId * @param userId userId
* @return project ids * @return project ids
*/ */
@ -1867,6 +1933,7 @@ public class ProcessService {
/** /**
* list unauthorized udf function * list unauthorized udf function
*
* @param userId user id * @param userId user id
* @param needChecks data source id array * @param needChecks data source id array
* @return unauthorized udf function list * @return unauthorized udf function list
@ -1898,6 +1965,8 @@ public class ProcessService {
Set<Integer> authorizedUdfs = udfFuncMapper.listAuthorizedUdfFunc(userId, needChecks).stream().map(t -> t.getId()).collect(toSet()); Set<Integer> authorizedUdfs = udfFuncMapper.listAuthorizedUdfFunc(userId, needChecks).stream().map(t -> t.getId()).collect(toSet());
originResSet.removeAll(authorizedUdfs); originResSet.removeAll(authorizedUdfs);
break; break;
default:
break;
} }
resultList.addAll(originResSet); resultList.addAll(originResSet);
@ -1908,6 +1977,7 @@ public class ProcessService {
/** /**
* get user by user id * get user by user id
*
* @param userId user id * @param userId user id
* @return User * @return User
*/ */
@ -1917,6 +1987,7 @@ public class ProcessService {
/** /**
* get resource by resoruce id * get resource by resoruce id
*
* @param resoruceId resource id * @param resoruceId resource id
* @return Resource * @return Resource
*/ */
@ -1924,9 +1995,9 @@ public class ProcessService {
return resourceMapper.selectById(resoruceId); return resourceMapper.selectById(resoruceId);
} }
/** /**
* list resources by ids * list resources by ids
*
* @param resIds resIds * @param resIds resIds
* @return resource list * @return resource list
*/ */
@ -1936,6 +2007,7 @@ public class ProcessService {
/** /**
* format task app id in task instance * format task app id in task instance
*
* @param taskInstance * @param taskInstance
* @return * @return
*/ */

1
pom.xml

@ -940,7 +940,6 @@
<include>**/dao/mapper/TenantMapperTest.java</include> <include>**/dao/mapper/TenantMapperTest.java</include>
<include>**/dao/mapper/UdfFuncMapperTest.java</include> <include>**/dao/mapper/UdfFuncMapperTest.java</include>
<include>**/dao/mapper/UDFUserMapperTest.java</include> <include>**/dao/mapper/UDFUserMapperTest.java</include>
<include>**/dao/mapper/UserAlertGroupMapperTest.java</include>
<include>**/dao/mapper/UserMapperTest.java</include> <include>**/dao/mapper/UserMapperTest.java</include>
<include>**/dao/mapper/AlertPluginInstanceMapperTest.java</include> <include>**/dao/mapper/AlertPluginInstanceMapperTest.java</include>
<include>**/dao/mapper/PluginDefineTest.java</include> <include>**/dao/mapper/PluginDefineTest.java</include>

47
sql/dolphinscheduler-postgre.sql

@ -187,14 +187,10 @@ DROP TABLE IF EXISTS t_ds_alert;
CREATE TABLE t_ds_alert ( CREATE TABLE t_ds_alert (
id int NOT NULL , id int NOT NULL ,
title varchar(64) DEFAULT NULL , title varchar(64) DEFAULT NULL ,
show_type int DEFAULT NULL ,
content text , content text ,
alert_type int DEFAULT NULL ,
alert_status int DEFAULT '0' , alert_status int DEFAULT '0' ,
log text , log text ,
alertgroup_id int DEFAULT NULL , alertgroup_id int DEFAULT NULL ,
receivers text ,
receivers_cc text ,
create_time timestamp DEFAULT NULL , create_time timestamp DEFAULT NULL ,
update_time timestamp DEFAULT NULL , update_time timestamp DEFAULT NULL ,
PRIMARY KEY (id) PRIMARY KEY (id)
@ -206,8 +202,8 @@ CREATE TABLE t_ds_alert (
DROP TABLE IF EXISTS t_ds_alertgroup; DROP TABLE IF EXISTS t_ds_alertgroup;
CREATE TABLE t_ds_alertgroup( CREATE TABLE t_ds_alertgroup(
id int NOT NULL, id int NOT NULL,
create_user_id int4 DEFAULT NULL,
group_name varchar(255) DEFAULT NULL, group_name varchar(255) DEFAULT NULL,
group_type int DEFAULT NULL ,
description varchar(255) DEFAULT NULL, description varchar(255) DEFAULT NULL,
create_time timestamp DEFAULT NULL, create_time timestamp DEFAULT NULL,
update_time timestamp DEFAULT NULL, update_time timestamp DEFAULT NULL,
@ -301,8 +297,7 @@ CREATE TABLE t_ds_process_definition (
flag int DEFAULT NULL , flag int DEFAULT NULL ,
locations text , locations text ,
connects text , connects text ,
receivers text , warning_group_id int4 DEFAULT NULL ,
receivers_cc text ,
create_time timestamp DEFAULT NULL , create_time timestamp DEFAULT NULL ,
timeout int DEFAULT '0' , timeout int DEFAULT '0' ,
tenant_id int NOT NULL DEFAULT '-1' , tenant_id int NOT NULL DEFAULT '-1' ,
@ -329,8 +324,7 @@ CREATE TABLE t_ds_process_definition_version (
global_params text , global_params text ,
locations text , locations text ,
connects text , connects text ,
receivers text , warning_group_id int4 DEFAULT NULL,
receivers_cc text ,
create_time timestamp DEFAULT NULL , create_time timestamp DEFAULT NULL ,
timeout int DEFAULT '0' , timeout int DEFAULT '0' ,
resource_ids varchar(64), resource_ids varchar(64),
@ -492,20 +486,6 @@ CREATE TABLE t_ds_relation_udfs_user (
) ; ) ;
; ;
--
-- Table structure for table t_ds_relation_user_alertgroup
--
DROP TABLE IF EXISTS t_ds_relation_user_alertgroup;
CREATE TABLE t_ds_relation_user_alertgroup (
id int NOT NULL,
alertgroup_id int DEFAULT NULL,
user_id int DEFAULT NULL,
create_time timestamp DEFAULT NULL,
update_time timestamp DEFAULT NULL,
PRIMARY KEY (id)
);
-- --
-- Table structure for table t_ds_resources -- Table structure for table t_ds_resources
-- --
@ -748,9 +728,6 @@ ALTER TABLE t_ds_relation_resources_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_
DROP SEQUENCE IF EXISTS t_ds_relation_udfs_user_id_sequence; DROP SEQUENCE IF EXISTS t_ds_relation_udfs_user_id_sequence;
CREATE SEQUENCE t_ds_relation_udfs_user_id_sequence; CREATE SEQUENCE t_ds_relation_udfs_user_id_sequence;
ALTER TABLE t_ds_relation_udfs_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_udfs_user_id_sequence'); ALTER TABLE t_ds_relation_udfs_user ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_udfs_user_id_sequence');
DROP SEQUENCE IF EXISTS t_ds_relation_user_alertgroup_id_sequence;
CREATE SEQUENCE t_ds_relation_user_alertgroup_id_sequence;
ALTER TABLE t_ds_relation_user_alertgroup ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_relation_user_alertgroup_id_sequence');
DROP SEQUENCE IF EXISTS t_ds_resources_id_sequence; DROP SEQUENCE IF EXISTS t_ds_resources_id_sequence;
CREATE SEQUENCE t_ds_resources_id_sequence; CREATE SEQUENCE t_ds_resources_id_sequence;
@ -777,21 +754,27 @@ ALTER TABLE t_ds_version ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_version_id_se
DROP SEQUENCE IF EXISTS t_ds_worker_group_id_sequence; DROP SEQUENCE IF EXISTS t_ds_worker_group_id_sequence;
CREATE SEQUENCE t_ds_worker_group_id_sequence; CREATE SEQUENCE t_ds_worker_group_id_sequence;
ALTER TABLE t_ds_worker_group ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_group_id_sequence'); ALTER TABLE t_ds_worker_group
ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_group_id_sequence');
DROP SEQUENCE IF EXISTS t_ds_worker_server_id_sequence; DROP SEQUENCE IF EXISTS t_ds_worker_server_id_sequence;
CREATE SEQUENCE t_ds_worker_server_id_sequence; CREATE SEQUENCE t_ds_worker_server_id_sequence;
ALTER TABLE t_ds_worker_server ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_server_id_sequence'); ALTER TABLE t_ds_worker_server
ALTER COLUMN id SET DEFAULT NEXTVAL('t_ds_worker_server_id_sequence');
-- Records of t_ds_user?user : admin , password : dolphinscheduler123 -- Records of t_ds_user?user : admin , password : dolphinscheduler123
INSERT INTO t_ds_user(user_name,user_password,user_type,email,phone,tenant_id,state,create_time,update_time) VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '0', 1, '2018-03-27 15:48:50', '2018-10-24 17:40:22'); INSERT INTO t_ds_user(user_name, user_password, user_type, email, phone, tenant_id, state, create_time, update_time)
VALUES ('admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '0', 1, '2018-03-27 15:48:50',
'2018-10-24 17:40:22');
-- Records of t_ds_alertgroup,dolphinscheduler warning group -- Records of t_ds_alertgroup,dolphinscheduler warning group
INSERT INTO t_ds_alertgroup(group_name,group_type,description,create_time,update_time) VALUES ('dolphinscheduler warning group', '0', 'dolphinscheduler warning group','2018-11-29 10:20:39', '2018-11-29 10:20:39'); INSERT INTO t_ds_alertgroup(id, create_user_id, group_name, description, create_time, update_time)
INSERT INTO t_ds_relation_user_alertgroup(alertgroup_id,user_id,create_time,update_time) VALUES ( '1', '1', '2018-11-29 10:22:33', '2018-11-29 10:22:33'); VALUES (1, 'dolphinscheduler warning group', 'dolphinscheduler warning group', '2018-11-29 10:20:39',
'2018-11-29 10:20:39');
-- Records of t_ds_queue,default queue name : default -- Records of t_ds_queue,default queue name : default
INSERT INTO t_ds_queue(queue_name,queue,create_time,update_time) VALUES ('default', 'default','2018-11-29 10:22:33', '2018-11-29 10:22:33'); INSERT INTO t_ds_queue(queue_name, queue, create_time, update_time)
VALUES ('default', 'default', '2018-11-29 10:22:33', '2018-11-29 10:22:33');
-- Records of t_ds_queue,default queue name : default -- Records of t_ds_queue,default queue name : default
INSERT INTO t_ds_version(version) VALUES ('1.3.0'); INSERT INTO t_ds_version(version) VALUES ('1.3.0');

52
sql/dolphinscheduler_mysql.sql

@ -279,14 +279,10 @@ DROP TABLE IF EXISTS `t_ds_alert`;
CREATE TABLE `t_ds_alert` ( CREATE TABLE `t_ds_alert` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key', `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
`title` varchar(64) DEFAULT NULL COMMENT 'title', `title` varchar(64) DEFAULT NULL COMMENT 'title',
`show_type` tinyint(4) DEFAULT NULL COMMENT 'send email type,0:TABLE,1:TEXT',
`content` text COMMENT 'Message content (can be email, can be SMS. Mail is stored in JSON map, and SMS is string)', `content` text COMMENT 'Message content (can be email, can be SMS. Mail is stored in JSON map, and SMS is string)',
`alert_type` tinyint(4) DEFAULT NULL COMMENT '0:email,1:sms',
`alert_status` tinyint(4) DEFAULT '0' COMMENT '0:wait running,1:success,2:failed', `alert_status` tinyint(4) DEFAULT '0' COMMENT '0:wait running,1:success,2:failed',
`log` text COMMENT 'log', `log` text COMMENT 'log',
`alertgroup_id` int(11) DEFAULT NULL COMMENT 'alert group id', `alertgroup_id` int(11) DEFAULT NULL COMMENT 'alert group id',
`receivers` text COMMENT 'receivers',
`receivers_cc` text COMMENT 'cc',
`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',
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
@ -302,8 +298,8 @@ CREATE TABLE `t_ds_alert` (
DROP TABLE IF EXISTS `t_ds_alertgroup`; DROP TABLE IF EXISTS `t_ds_alertgroup`;
CREATE TABLE `t_ds_alertgroup`( CREATE TABLE `t_ds_alertgroup`(
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key', `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
`create_user_id` int(11) DEFAULT NULL COMMENT 'create user id',
`group_name` varchar(255) DEFAULT NULL COMMENT 'group name', `group_name` varchar(255) DEFAULT NULL COMMENT 'group name',
`group_type` tinyint(4) DEFAULT NULL COMMENT 'Group type (message 0, SMS 1...)',
`description` varchar(255) DEFAULT NULL, `description` varchar(255) DEFAULT NULL,
`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',
@ -406,8 +402,7 @@ CREATE TABLE `t_ds_process_definition` (
`flag` tinyint(4) DEFAULT NULL COMMENT '0 not available, 1 available', `flag` tinyint(4) DEFAULT NULL COMMENT '0 not available, 1 available',
`locations` text COMMENT 'Node location information', `locations` text COMMENT 'Node location information',
`connects` text COMMENT 'Node connection information', `connects` text COMMENT 'Node connection information',
`receivers` text COMMENT 'receivers', `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id',
`receivers_cc` text COMMENT 'cc',
`create_time` datetime DEFAULT NULL COMMENT 'create time', `create_time` datetime DEFAULT NULL COMMENT 'create time',
`timeout` int(11) DEFAULT '0' COMMENT 'time out', `timeout` int(11) DEFAULT '0' COMMENT 'time out',
`tenant_id` int(11) NOT NULL DEFAULT '-1' COMMENT 'tenant id', `tenant_id` int(11) NOT NULL DEFAULT '-1' COMMENT 'tenant id',
@ -436,8 +431,7 @@ CREATE TABLE `t_ds_process_definition_version` (
`global_params` text COMMENT 'global parameters', `global_params` text COMMENT 'global parameters',
`locations` text COMMENT 'Node location information', `locations` text COMMENT 'Node location information',
`connects` text COMMENT 'Node connection information', `connects` text COMMENT 'Node connection information',
`receivers` text COMMENT 'receivers', `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id',
`receivers_cc` text COMMENT 'cc',
`create_time` datetime DEFAULT NULL COMMENT 'create time', `create_time` datetime DEFAULT NULL COMMENT 'create time',
`timeout` int(11) DEFAULT '0' COMMENT 'time out', `timeout` int(11) DEFAULT '0' COMMENT 'time out',
`resource_ids` varchar(255) DEFAULT NULL COMMENT 'resource ids', `resource_ids` varchar(255) DEFAULT NULL COMMENT 'resource ids',
@ -620,27 +614,6 @@ CREATE TABLE `t_ds_relation_udfs_user` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_ds_relation_udfs_user
-- ----------------------------
-- ----------------------------
-- Table structure for t_ds_relation_user_alertgroup
-- ----------------------------
DROP TABLE IF EXISTS `t_ds_relation_user_alertgroup`;
CREATE TABLE `t_ds_relation_user_alertgroup` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'key',
`alertgroup_id` int(11) DEFAULT NULL COMMENT 'alert group id',
`user_id` int(11) DEFAULT NULL COMMENT 'user id',
`create_time` datetime DEFAULT NULL COMMENT 'create time',
`update_time` datetime DEFAULT NULL COMMENT 'update time',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of t_ds_relation_user_alertgroup
-- ----------------------------
-- ---------------------------- -- ----------------------------
-- Table structure for t_ds_resources -- Table structure for t_ds_resources
-- ---------------------------- -- ----------------------------
@ -831,28 +804,29 @@ CREATE TABLE `t_ds_version` (
-- ---------------------------- -- ----------------------------
-- Records of t_ds_version -- Records of t_ds_version
-- ---------------------------- -- ----------------------------
INSERT INTO `t_ds_version` VALUES ('1', '1.3.0'); INSERT INTO `t_ds_version`
VALUES ('1', '1.3.0');
-- ---------------------------- -- ----------------------------
-- Records of t_ds_alertgroup -- Records of t_ds_alertgroup
-- ---------------------------- -- ----------------------------
INSERT INTO `t_ds_alertgroup` VALUES ('1', 'default admin warning group', '0', 'default admin warning group', '2018-11-29 10:20:39', '2018-11-29 10:20:39'); INSERT INTO `t_ds_alertgroup`
VALUES (1, 1, 'default admin warning group', 'default admin warning group', '2018-11-29 10:20:39',
-- ---------------------------- '2018-11-29 10:20:39');
-- Records of t_ds_relation_user_alertgroup
-- ----------------------------
INSERT INTO `t_ds_relation_user_alertgroup` VALUES ('1', '1', '1', '2018-11-29 10:22:33', '2018-11-29 10:22:33');
-- ---------------------------- -- ----------------------------
-- Records of t_ds_user -- Records of t_ds_user
-- ---------------------------- -- ----------------------------
INSERT INTO `t_ds_user` VALUES ('1', 'admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '0', '2018-03-27 15:48:50', '2018-10-24 17:40:22', null, 1); INSERT INTO `t_ds_user`
VALUES ('1', 'admin', '7ad2410b2f4c074479a8937a28a22b8f', '0', 'xxx@qq.com', '', '0', '2018-03-27 15:48:50',
'2018-10-24 17:40:22', null, 1);
-- ---------------------------- -- ----------------------------
-- Table structure for t_ds_plugin_define -- Table structure for t_ds_plugin_define
-- ---------------------------- -- ----------------------------
SET sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY','')); SET
sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
DROP TABLE IF EXISTS `t_ds_plugin_define`; DROP TABLE IF EXISTS `t_ds_plugin_define`;
CREATE TABLE `t_ds_plugin_define` ( CREATE TABLE `t_ds_plugin_define` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,

26
sql/upgrade/1.4.0_schema/mysql/dolphinscheduler_ddl.sql

@ -40,4 +40,30 @@ CREATE TABLE `t_ds_alert_plugin_instance` (
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8; ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
ALTER TABLE t_ds_process_definition
ADD COLUMN `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
ALTER TABLE t_ds_process_definition_version
ADD COLUMN `warning_group_id` int(11) DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
ALTER TABLE t_ds_alertgroup
ADD COLUMN `create_user_id` int(11) DEFAULT NULL COMMENT 'create user id' AFTER `id`;
-- ----------------------------
-- These columns will not be used in the new version,if you determine that the historical data is useless, you can delete it using the sql below
-- ----------------------------
/*
ALTER TABLE t_ds_process_definition DROP receivers, DROP receivers_cc;
ALTER TABLE t_ds_process_definition_version DROP receivers, DROP receivers_cc;
ALTER TABLE t_ds_alert DROP show_type,DROP alert_type,DROP receivers,DROP receivers_cc;
ALTER TABLE t_ds_alertgroup DROP group_type;
DROP TABLE IF EXISTS t_ds_relation_user_alertgroup;
*/

24
sql/upgrade/1.4.0_schema/postgresql/dolphinscheduler_ddl.sql

@ -38,3 +38,27 @@ CREATE TABLE t_ds_alert_plugin_instance (
instance_name varchar(200) NULL, instance_name varchar(200) NULL,
CONSTRAINT t_ds_alert_plugin_instance_pk PRIMARY KEY (id) CONSTRAINT t_ds_alert_plugin_instance_pk PRIMARY KEY (id)
); );
ALTER TABLE t_ds_process_definition
ADD COLUMN `warning_group_id` int4 DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
ALTER TABLE t_ds_process_definition_version
ADD COLUMN `warning_group_id` int4 DEFAULT NULL COMMENT 'alert group id' AFTER `connects`;
ALTER TABLE t_ds_alertgroup
ADD COLUMN `create_user_id` int4 DEFAULT NULL COMMENT 'create user id' AFTER `id`;
-- ----------------------------
-- These columns will not be used in the new version,if you determine that the historical data is useless, you can delete it using the sql below
-- ----------------------------
/*
ALTER TABLE t_ds_process_definition DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
ALTER TABLE t_ds_process_definition_version DROP COLUMN "receivers", DROP COLUMN "receivers_cc";
ALTER TABLE t_ds_alert DROP COLUMN "show_type",DROP COLUMN "alert_type",DROP COLUMN "receivers",DROP COLUMN "receivers_cc";
ALTER TABLE t_ds_alertgroup DROP COLUMN "group_type";
DROP TABLE IF EXISTS t_ds_relation_user_alertgroup;
*/

Loading…
Cancel
Save