Search in sources :

Example 1 with BatchTaskTask

use of com.dtstack.taier.dao.domain.BatchTaskTask in project Taier by DTStack.

the class BatchTaskService method allProductGlobalSearch.

/**
 * 查找所有产品提交的任务
 *
 * @param searchVO
 * @return
 */
public List<BatchAllProductGlobalReturnVO> allProductGlobalSearch(AllProductGlobalSearchVO searchVO) {
    BatchTask batchTask = developTaskDao.getOne(searchVO.getTaskId());
    if (batchTask == null) {
        throw new RdosDefineException(ErrorCode.CAN_NOT_FIND_TASK);
    }
    if (batchTask.getTaskType().intValue() == EScheduleJobType.VIRTUAL.getVal().intValue()) {
        throw new RdosDefineException(ErrorCode.VIRTUAL_TASK_UNSUPPORTED_OPERATION);
    }
    // 过滤掉已经依赖的任务
    final List<BatchTaskTask> taskTasks = this.batchTaskTaskService.getByParentTaskId(searchVO.getTaskId());
    final List<Long> excludeIds = new ArrayList<>(taskTasks.size());
    excludeIds.add(searchVO.getTaskId());
    taskTasks.forEach(taskTask -> excludeIds.add(taskTask.getTaskId()));
    List<ScheduleTaskShade> scheduleTaskShadeList = taskService.findTaskByTaskName(searchVO.getTaskName(), searchVO.getSelectTenantId(), searchVO.getUserId());
    List<ScheduleTaskShade> filterTask = scheduleTaskShadeList.stream().filter(scheduleTask -> !excludeIds.contains(scheduleTask.getTaskId())).collect(Collectors.toList());
    Map<Long, Tenant> tenantMap = tenantService.listAllTenant().stream().collect(Collectors.toMap(Tenant::getId, g -> (g)));
    List<BatchAllProductGlobalReturnVO> voList = Lists.newArrayList();
    for (ScheduleTaskShade scheduleTaskShade : filterTask) {
        BatchAllProductGlobalReturnVO vo = new BatchAllProductGlobalReturnVO();
        vo.setTaskId(scheduleTaskShade.getTaskId());
        vo.setTaskName(scheduleTaskShade.getName());
        Tenant tenant = tenantMap.get(scheduleTaskShade.getTenantId());
        if (tenant != null) {
            vo.setTenantId(tenant.getId());
            vo.setTenantName(tenant.getTenantName());
        }
        voList.add(vo);
    }
    return voList;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) SourceDTOType(com.dtstack.taier.develop.enums.develop.SourceDTOType) DependencyType(com.dtstack.taier.common.enums.DependencyType) TaskParamTemplate(com.dtstack.taier.dao.domain.TaskParamTemplate) ISourceDTO(com.dtstack.dtcenter.loader.dto.source.ISourceDTO) CatalogueType(com.dtstack.taier.common.enums.CatalogueType) Autowired(org.springframework.beans.factory.annotation.Autowired) KerberosConfigVerify(com.dtstack.taier.common.kerberos.KerberosConfigVerify) JSONPath(com.alibaba.fastjson.JSONPath) BooleanUtils(org.apache.commons.lang.BooleanUtils) SyncModel(com.dtstack.taier.develop.enums.develop.SyncModel) Matcher(java.util.regex.Matcher) ComponentService(com.dtstack.taier.scheduler.service.ComponentService) Pair(org.apache.commons.lang3.tuple.Pair) BatchReadWriteLock(com.dtstack.taier.dao.domain.BatchReadWriteLock) Map(java.util.Map) TaskCatalogueVO(com.dtstack.taier.develop.dto.devlop.TaskCatalogueVO) TaskGetNotDeleteVO(com.dtstack.taier.develop.dto.devlop.TaskGetNotDeleteVO) DevelopTaskDao(com.dtstack.taier.dao.mapper.DevelopTaskDao) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) DictType(com.dtstack.taier.common.enums.DictType) Strings(com.dtstack.taier.common.util.Strings) BatchTaskVersionDetailDTO(com.dtstack.taier.dao.dto.BatchTaskVersionDetailDTO) Resource(javax.annotation.Resource) PublishTaskStatusEnum(com.dtstack.taier.common.enums.PublishTaskStatusEnum) AllProductGlobalSearchVO(com.dtstack.taier.develop.vo.develop.query.AllProductGlobalSearchVO) Set(java.util.Set) DatasourceService(com.dtstack.taier.develop.service.datasource.impl.DatasourceService) BatchTaskVersion(com.dtstack.taier.dao.domain.BatchTaskVersion) BatchResource(com.dtstack.taier.dao.domain.BatchResource) SyncJobCheck(com.dtstack.taier.develop.utils.develop.sync.job.SyncJobCheck) ScheduleTaskVO(com.dtstack.taier.scheduler.vo.ScheduleTaskVO) TypeReference(com.alibaba.fastjson.TypeReference) SqlQueryDTO(com.dtstack.dtcenter.loader.dto.SqlQueryDTO) PageQuery(com.dtstack.taier.dao.pager.PageQuery) BatchTaskBatchVO(com.dtstack.taier.develop.dto.devlop.BatchTaskBatchVO) EScheduleStatus(com.dtstack.taier.common.enums.EScheduleStatus) ScheduleFactory(com.dtstack.taier.develop.parser.ScheduleFactory) CheckSyntaxResult(com.dtstack.taier.develop.dto.devlop.CheckSyntaxResult) LocalDateTime(java.time.LocalDateTime) EnvironmentContext(com.dtstack.taier.common.env.EnvironmentContext) TenantService(com.dtstack.taier.develop.service.console.TenantService) SimpleDateFormat(java.text.SimpleDateFormat) IClient(com.dtstack.dtcenter.loader.client.IClient) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) MathUtil(com.dtstack.taier.pluginapi.util.MathUtil) ArrayList(java.util.ArrayList) UserDTO(com.dtstack.taier.dao.dto.UserDTO) JSONArray(com.alibaba.fastjson.JSONArray) Dict(com.dtstack.taier.dao.domain.Dict) FuncType(com.dtstack.taier.common.enums.FuncType) Tenant(com.dtstack.taier.dao.domain.Tenant) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) ClusterService(com.dtstack.taier.scheduler.service.ClusterService) DataSourceType(com.dtstack.dtcenter.loader.source.DataSourceType) TaskLockStatus(com.dtstack.taier.common.enums.TaskLockStatus) ErrorCode(com.dtstack.taier.common.exception.ErrorCode) TaskOperateType(com.dtstack.taier.develop.enums.develop.TaskOperateType) ScheduleTaskShadeDTO(com.dtstack.taier.scheduler.dto.schedule.ScheduleTaskShadeDTO) User(com.dtstack.taier.dao.domain.User) IOException(java.io.IOException) Sort(com.dtstack.taier.dao.pager.Sort) ScheduleDictService(com.dtstack.taier.scheduler.service.ScheduleDictService) File(java.io.File) BatchTaskResource(com.dtstack.taier.dao.domain.BatchTaskResource) JSON(com.alibaba.fastjson.JSON) PublicUtil(com.dtstack.taier.common.util.PublicUtil) BatchDataSource(com.dtstack.taier.dao.domain.BatchDataSource) ResourceRefType(com.dtstack.taier.common.enums.ResourceRefType) Preconditions(com.google.common.base.Preconditions) EScheduleJobType(com.dtstack.taier.common.enums.EScheduleJobType) SavaTaskDTO(com.dtstack.taier.scheduler.dto.schedule.SavaTaskDTO) UserService(com.dtstack.taier.develop.service.user.UserService) Date(java.util.Date) ListUtils(org.apache.commons.collections.ListUtils) LoggerFactory(org.slf4j.LoggerFactory) BatchTaskTask(com.dtstack.taier.dao.domain.BatchTaskTask) BatchTaskGetComponentVersionResultVO(com.dtstack.taier.develop.vo.develop.result.BatchTaskGetComponentVersionResultVO) ColumnMetaDTO(com.dtstack.dtcenter.loader.dto.ColumnMetaDTO) Base64Util(com.dtstack.taier.common.util.Base64Util) Component(com.dtstack.taier.dao.domain.Component) ScheduleCron(com.dtstack.taier.develop.parser.ScheduleCron) DateFormat(java.text.DateFormat) EDeployType(com.dtstack.taier.common.enums.EDeployType) PatternConstant(com.dtstack.taier.common.constant.PatternConstant) ESchedulePeriodType(com.dtstack.taier.develop.parser.ESchedulePeriodType) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) IKerberos(com.dtstack.dtcenter.loader.client.IKerberos) ClientCache(com.dtstack.dtcenter.loader.client.ClientCache) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) TaskCheckResultVO(com.dtstack.taier.develop.dto.devlop.TaskCheckResultVO) TaskResourceParam(com.dtstack.taier.develop.dto.devlop.TaskResourceParam) Objects(java.util.Objects) List(java.util.List) BatchSysParameter(com.dtstack.taier.dao.domain.BatchSysParameter) DevelopReadWriteLockDao(com.dtstack.taier.dao.mapper.DevelopReadWriteLockDao) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) JSONObject(com.alibaba.fastjson.JSONObject) PluginName(com.dtstack.taier.develop.utils.develop.sync.job.PluginName) Pattern(java.util.regex.Pattern) BatchAllProductGlobalReturnVO(com.dtstack.taier.develop.vo.develop.result.BatchAllProductGlobalReturnVO) Deleted(com.dtstack.taier.common.enums.Deleted) BeanUtils(org.springframework.beans.BeanUtils) HashMap(java.util.HashMap) BatchCatalogue(com.dtstack.taier.dao.domain.BatchCatalogue) HashSet(java.util.HashSet) TaskCreateModelType(com.dtstack.taier.develop.enums.develop.TaskCreateModelType) CollectionUtils(org.apache.commons.collections.CollectionUtils) TaskParamTemplateService(com.dtstack.taier.develop.service.task.TaskParamTemplateService) Constant(com.dtstack.taier.develop.utils.develop.common.enums.Constant) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) BatchTask(com.dtstack.taier.dao.domain.BatchTask) TaskService(com.dtstack.taier.develop.service.schedule.TaskService) Logger(org.slf4j.Logger) MapUtils(org.apache.commons.collections.MapUtils) DataFilter(com.dtstack.taier.common.util.DataFilter) ReadWriteLockType(com.dtstack.taier.common.enums.ReadWriteLockType) BatchTaskDTO(com.dtstack.taier.dao.dto.BatchTaskDTO) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Maps(com.google.common.collect.Maps) EComponentType(com.dtstack.taier.common.enums.EComponentType) ReadWriteLockVO(com.dtstack.taier.develop.dto.devlop.ReadWriteLockVO) BatchTaskParam(com.dtstack.taier.dao.domain.BatchTaskParam) Comparator(java.util.Comparator) ESubmitStatus(com.dtstack.taier.common.enums.ESubmitStatus) JsonUtils(com.dtstack.taier.common.util.JsonUtils) Transactional(org.springframework.transaction.annotation.Transactional) BatchTask(com.dtstack.taier.dao.domain.BatchTask) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) ArrayList(java.util.ArrayList) BatchAllProductGlobalReturnVO(com.dtstack.taier.develop.vo.develop.result.BatchAllProductGlobalReturnVO) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) BatchTaskTask(com.dtstack.taier.dao.domain.BatchTaskTask) Tenant(com.dtstack.taier.dao.domain.Tenant)

Example 2 with BatchTaskTask

use of com.dtstack.taier.dao.domain.BatchTaskTask in project Taier by DTStack.

the class BatchTaskTaskService method getForefathers.

/**
 * 展开上一个父节点
 *
 * @author toutian
 */
public ScheduleTaskVO getForefathers(BatchTask task) {
    BatchTaskBatchVO vo = new BatchTaskBatchVO();
    BeanUtils.copyProperties(task, vo);
    vo.setVersion(task.getVersion());
    vo.setCreateUser(userService.getUserByDTO(task.getCreateUserId()));
    vo.setModifyUser(userService.getUserByDTO(task.getModifyUserId()));
    vo.setTenantName(tenantService.getTenantById(task.getTenantId()).getTenantName());
    List<BatchTaskTask> taskTasks = developTaskTaskDao.listByTaskId(task.getId());
    if (CollectionUtils.isEmpty(taskTasks)) {
        return vo;
    }
    List<ScheduleTaskVO> fatherTaskVOs = Lists.newArrayList();
    for (BatchTaskTask taskTask : taskTasks) {
        Long parentTaskId = taskTask.getParentTaskId();
        ScheduleTaskShade taskShade = taskService.findTaskByTaskId(parentTaskId);
        if (taskShade != null) {
            ScheduleTaskVO scheduleTaskVO = new ScheduleTaskVO();
            BeanUtils.copyProperties(taskShade, scheduleTaskVO);
            scheduleTaskVO.setId(taskShade.getTaskId());
            scheduleTaskVO.setTenantName(tenantService.getByDtTenantId(taskShade.getTenantId()).getTenantName());
            fatherTaskVOs.add(scheduleTaskVO);
        }
    }
    vo.setTaskVOS(fatherTaskVOs);
    return vo;
}
Also used : BatchTaskTask(com.dtstack.taier.dao.domain.BatchTaskTask) BatchTaskBatchVO(com.dtstack.taier.develop.dto.devlop.BatchTaskBatchVO) ScheduleTaskVO(com.dtstack.taier.scheduler.vo.ScheduleTaskVO) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade)

Example 3 with BatchTaskTask

use of com.dtstack.taier.dao.domain.BatchTaskTask in project Taier by DTStack.

the class BatchTaskService method checkTaskAndSaveVersion.

/**
 * 检查要发布的任务并保存版本信息
 *
 * @param task 任务信息
 * @param tenantId 项目id
 * @param userId 用户id
 * @param publishDesc 发布描述
 * @param isRoot 是否是管理员
 * @param ignoreCheck 是否忽略检查
 * @return 检查结果
 */
private TaskCheckResultVO checkTaskAndSaveVersion(BatchTask task, Long tenantId, Long userId, String publishDesc, Boolean isRoot, Boolean ignoreCheck) {
    TaskCheckResultVO checkVo = new TaskCheckResultVO();
    checkVo.setErrorSign(PublishTaskStatusEnum.NOMAL.getType());
    checkTaskCanSubmit(task);
    task.setSubmitStatus(ESubmitStatus.SUBMIT.getStatus());
    task.setGmtModified(Timestamp.valueOf(LocalDateTime.now()));
    final BatchTaskVersion version = new BatchTaskVersion();
    version.setCreateUserId(userId);
    String versionSqlText = StringUtils.EMPTY;
    if (EScheduleJobType.SPARK_SQL.getVal().intValue() == task.getTaskType().intValue()) {
        // 语法检测
        List<BatchTaskParam> taskParamsToReplace = batchTaskParamService.getTaskParam(task.getId());
        versionSqlText = this.jobParamReplace.paramReplace(task.getSqlText(), taskParamsToReplace, this.sdf.format(new Date()));
        // 避免重复校验
        CheckSyntaxResult syntaxResult = batchSqlExeService.processSqlText(task.getTenantId(), task.getTaskType(), versionSqlText);
        if (!syntaxResult.getCheckResult()) {
            checkVo.setErrorSign(PublishTaskStatusEnum.CHECKSYNTAXERROR.getType());
            checkVo.setErrorMessage(syntaxResult.getMessage());
            return checkVo;
        }
    } else if (EScheduleJobType.SYNC.getVal().intValue() == task.getTaskType().intValue()) {
        if (StringUtils.isNotEmpty(task.getSqlText())) {
            final JSONObject jsonTask = JSON.parseObject(Base64Util.baseDecode(task.getSqlText()));
            Integer createModelType = Integer.valueOf(jsonTask.getString("createModel"));
            JSONObject job = jsonTask.getJSONObject("job");
            if (Objects.isNull(job)) {
                throw new RdosDefineException(String.format("数据同步任务:%s 未配置", task.getName()));
            }
            // 检测job格式
            SyncJobCheck.checkJobFormat(job.toJSONString(), createModelType);
            versionSqlText = jsonTask.getString("job");
        }
    }
    version.setSqlText(versionSqlText);
    version.setOriginSql(task.getSqlText());
    version.setTenantId(task.getTenantId());
    version.setTaskId(task.getId());
    // 任务的版本号
    version.setVersion(task.getVersion());
    version.setTaskParams(task.getTaskParams());
    version.setScheduleConf(task.getScheduleConf());
    version.setScheduleStatus(task.getScheduleStatus());
    version.setGmtModified(task.getGmtModified());
    String dependencyTaskIds = StringUtils.EMPTY;
    final List<BatchTaskTask> taskTasks = this.batchTaskTaskService.getAllParentTask(task.getId());
    if (CollectionUtils.isNotEmpty(taskTasks)) {
        List<Map<String, Object>> parentTasks = taskTasks.stream().map(taskTask -> {
            Map<String, Object> map = Maps.newHashMap();
            map.put("parentTaskId", taskTask.getParentTaskId());
            return map;
        }).collect(Collectors.toList());
        dependencyTaskIds = JSON.toJSONString(parentTasks);
    }
    version.setDependencyTaskIds(dependencyTaskIds);
    version.setPublishDesc(null == publishDesc ? "" : publishDesc);
    // 插入一条记录信息
    batchTaskVersionService.insert(version);
    task.setVersion(version.getId().intValue());
    return checkVo;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) SourceDTOType(com.dtstack.taier.develop.enums.develop.SourceDTOType) DependencyType(com.dtstack.taier.common.enums.DependencyType) TaskParamTemplate(com.dtstack.taier.dao.domain.TaskParamTemplate) ISourceDTO(com.dtstack.dtcenter.loader.dto.source.ISourceDTO) CatalogueType(com.dtstack.taier.common.enums.CatalogueType) Autowired(org.springframework.beans.factory.annotation.Autowired) KerberosConfigVerify(com.dtstack.taier.common.kerberos.KerberosConfigVerify) JSONPath(com.alibaba.fastjson.JSONPath) BooleanUtils(org.apache.commons.lang.BooleanUtils) SyncModel(com.dtstack.taier.develop.enums.develop.SyncModel) Matcher(java.util.regex.Matcher) ComponentService(com.dtstack.taier.scheduler.service.ComponentService) Pair(org.apache.commons.lang3.tuple.Pair) BatchReadWriteLock(com.dtstack.taier.dao.domain.BatchReadWriteLock) Map(java.util.Map) TaskCatalogueVO(com.dtstack.taier.develop.dto.devlop.TaskCatalogueVO) TaskGetNotDeleteVO(com.dtstack.taier.develop.dto.devlop.TaskGetNotDeleteVO) DevelopTaskDao(com.dtstack.taier.dao.mapper.DevelopTaskDao) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) DictType(com.dtstack.taier.common.enums.DictType) Strings(com.dtstack.taier.common.util.Strings) BatchTaskVersionDetailDTO(com.dtstack.taier.dao.dto.BatchTaskVersionDetailDTO) Resource(javax.annotation.Resource) PublishTaskStatusEnum(com.dtstack.taier.common.enums.PublishTaskStatusEnum) AllProductGlobalSearchVO(com.dtstack.taier.develop.vo.develop.query.AllProductGlobalSearchVO) Set(java.util.Set) DatasourceService(com.dtstack.taier.develop.service.datasource.impl.DatasourceService) BatchTaskVersion(com.dtstack.taier.dao.domain.BatchTaskVersion) BatchResource(com.dtstack.taier.dao.domain.BatchResource) SyncJobCheck(com.dtstack.taier.develop.utils.develop.sync.job.SyncJobCheck) ScheduleTaskVO(com.dtstack.taier.scheduler.vo.ScheduleTaskVO) TypeReference(com.alibaba.fastjson.TypeReference) SqlQueryDTO(com.dtstack.dtcenter.loader.dto.SqlQueryDTO) PageQuery(com.dtstack.taier.dao.pager.PageQuery) BatchTaskBatchVO(com.dtstack.taier.develop.dto.devlop.BatchTaskBatchVO) EScheduleStatus(com.dtstack.taier.common.enums.EScheduleStatus) ScheduleFactory(com.dtstack.taier.develop.parser.ScheduleFactory) CheckSyntaxResult(com.dtstack.taier.develop.dto.devlop.CheckSyntaxResult) LocalDateTime(java.time.LocalDateTime) EnvironmentContext(com.dtstack.taier.common.env.EnvironmentContext) TenantService(com.dtstack.taier.develop.service.console.TenantService) SimpleDateFormat(java.text.SimpleDateFormat) IClient(com.dtstack.dtcenter.loader.client.IClient) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) MathUtil(com.dtstack.taier.pluginapi.util.MathUtil) ArrayList(java.util.ArrayList) UserDTO(com.dtstack.taier.dao.dto.UserDTO) JSONArray(com.alibaba.fastjson.JSONArray) Dict(com.dtstack.taier.dao.domain.Dict) FuncType(com.dtstack.taier.common.enums.FuncType) Tenant(com.dtstack.taier.dao.domain.Tenant) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) ClusterService(com.dtstack.taier.scheduler.service.ClusterService) DataSourceType(com.dtstack.dtcenter.loader.source.DataSourceType) TaskLockStatus(com.dtstack.taier.common.enums.TaskLockStatus) ErrorCode(com.dtstack.taier.common.exception.ErrorCode) TaskOperateType(com.dtstack.taier.develop.enums.develop.TaskOperateType) ScheduleTaskShadeDTO(com.dtstack.taier.scheduler.dto.schedule.ScheduleTaskShadeDTO) User(com.dtstack.taier.dao.domain.User) IOException(java.io.IOException) Sort(com.dtstack.taier.dao.pager.Sort) ScheduleDictService(com.dtstack.taier.scheduler.service.ScheduleDictService) File(java.io.File) BatchTaskResource(com.dtstack.taier.dao.domain.BatchTaskResource) JSON(com.alibaba.fastjson.JSON) PublicUtil(com.dtstack.taier.common.util.PublicUtil) BatchDataSource(com.dtstack.taier.dao.domain.BatchDataSource) ResourceRefType(com.dtstack.taier.common.enums.ResourceRefType) Preconditions(com.google.common.base.Preconditions) EScheduleJobType(com.dtstack.taier.common.enums.EScheduleJobType) SavaTaskDTO(com.dtstack.taier.scheduler.dto.schedule.SavaTaskDTO) UserService(com.dtstack.taier.develop.service.user.UserService) Date(java.util.Date) ListUtils(org.apache.commons.collections.ListUtils) LoggerFactory(org.slf4j.LoggerFactory) BatchTaskTask(com.dtstack.taier.dao.domain.BatchTaskTask) BatchTaskGetComponentVersionResultVO(com.dtstack.taier.develop.vo.develop.result.BatchTaskGetComponentVersionResultVO) ColumnMetaDTO(com.dtstack.dtcenter.loader.dto.ColumnMetaDTO) Base64Util(com.dtstack.taier.common.util.Base64Util) Component(com.dtstack.taier.dao.domain.Component) ScheduleCron(com.dtstack.taier.develop.parser.ScheduleCron) DateFormat(java.text.DateFormat) EDeployType(com.dtstack.taier.common.enums.EDeployType) PatternConstant(com.dtstack.taier.common.constant.PatternConstant) ESchedulePeriodType(com.dtstack.taier.develop.parser.ESchedulePeriodType) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) IKerberos(com.dtstack.dtcenter.loader.client.IKerberos) ClientCache(com.dtstack.dtcenter.loader.client.ClientCache) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) TaskCheckResultVO(com.dtstack.taier.develop.dto.devlop.TaskCheckResultVO) TaskResourceParam(com.dtstack.taier.develop.dto.devlop.TaskResourceParam) Objects(java.util.Objects) List(java.util.List) BatchSysParameter(com.dtstack.taier.dao.domain.BatchSysParameter) DevelopReadWriteLockDao(com.dtstack.taier.dao.mapper.DevelopReadWriteLockDao) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) JSONObject(com.alibaba.fastjson.JSONObject) PluginName(com.dtstack.taier.develop.utils.develop.sync.job.PluginName) Pattern(java.util.regex.Pattern) BatchAllProductGlobalReturnVO(com.dtstack.taier.develop.vo.develop.result.BatchAllProductGlobalReturnVO) Deleted(com.dtstack.taier.common.enums.Deleted) BeanUtils(org.springframework.beans.BeanUtils) HashMap(java.util.HashMap) BatchCatalogue(com.dtstack.taier.dao.domain.BatchCatalogue) HashSet(java.util.HashSet) TaskCreateModelType(com.dtstack.taier.develop.enums.develop.TaskCreateModelType) CollectionUtils(org.apache.commons.collections.CollectionUtils) TaskParamTemplateService(com.dtstack.taier.develop.service.task.TaskParamTemplateService) Constant(com.dtstack.taier.develop.utils.develop.common.enums.Constant) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) BatchTask(com.dtstack.taier.dao.domain.BatchTask) TaskService(com.dtstack.taier.develop.service.schedule.TaskService) Logger(org.slf4j.Logger) MapUtils(org.apache.commons.collections.MapUtils) DataFilter(com.dtstack.taier.common.util.DataFilter) ReadWriteLockType(com.dtstack.taier.common.enums.ReadWriteLockType) BatchTaskDTO(com.dtstack.taier.dao.dto.BatchTaskDTO) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Maps(com.google.common.collect.Maps) EComponentType(com.dtstack.taier.common.enums.EComponentType) ReadWriteLockVO(com.dtstack.taier.develop.dto.devlop.ReadWriteLockVO) BatchTaskParam(com.dtstack.taier.dao.domain.BatchTaskParam) Comparator(java.util.Comparator) ESubmitStatus(com.dtstack.taier.common.enums.ESubmitStatus) JsonUtils(com.dtstack.taier.common.util.JsonUtils) Transactional(org.springframework.transaction.annotation.Transactional) BatchTaskVersion(com.dtstack.taier.dao.domain.BatchTaskVersion) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) CheckSyntaxResult(com.dtstack.taier.develop.dto.devlop.CheckSyntaxResult) Date(java.util.Date) BatchTaskTask(com.dtstack.taier.dao.domain.BatchTaskTask) JSONObject(com.alibaba.fastjson.JSONObject) BatchTaskParam(com.dtstack.taier.dao.domain.BatchTaskParam) TaskCheckResultVO(com.dtstack.taier.develop.dto.devlop.TaskCheckResultVO) Map(java.util.Map) HashMap(java.util.HashMap)

Example 4 with BatchTaskTask

use of com.dtstack.taier.dao.domain.BatchTaskTask in project Taier by DTStack.

the class BatchTaskService method isHasLoop.

public Long isHasLoop(final Long parentTaskId, final HashSet<Long> node) {
    HashSet<Long> loopNode = new HashSet<>(node.size() + 1);
    loopNode.addAll(node);
    loopNode.add(parentTaskId);
    // 出现闭环则返回
    if (loopNode.size() == node.size()) {
        return parentTaskId;
    }
    List<BatchTaskTask> taskTasks = batchTaskTaskService.getAllParentTask(parentTaskId);
    if (CollectionUtils.isEmpty(taskTasks)) {
        return 0L;
    }
    for (BatchTaskTask subTask : taskTasks) {
        Long loopTaskId = isHasLoop(subTask.getParentTaskId(), loopNode);
        if (loopTaskId != 0L) {
            return loopTaskId;
        }
    }
    return 0L;
}
Also used : BatchTaskTask(com.dtstack.taier.dao.domain.BatchTaskTask) HashSet(java.util.HashSet)

Example 5 with BatchTaskTask

use of com.dtstack.taier.dao.domain.BatchTaskTask in project Taier by DTStack.

the class BatchTaskTaskService method addOrUpdateTaskTask.

@Transactional(rollbackFor = Exception.class)
public void addOrUpdateTaskTask(Long taskId, List<BatchTask> dependencyTasks) {
    List<BatchTaskTask> taskTasks = developTaskTaskDao.listByTaskId(taskId);
    List<BatchTaskTask> dependencyTaskTasks = getTaskTasksByTaskIdAndTasks(taskId, dependencyTasks);
    List<BatchTaskTask> existDependencyTasks = Lists.newArrayList();
    for (BatchTaskTask taskTask : taskTasks) {
        BatchTaskTask existTaskTask = existTaskTask(dependencyTaskTasks, taskTask);
        if (existTaskTask != null) {
            existDependencyTasks.add(existTaskTask);
            continue;
        }
        developTaskTaskDao.delete(taskTask.getId());
    }
    dependencyTaskTasks.removeAll(existDependencyTasks);
    for (BatchTaskTask taskTask : dependencyTaskTasks) {
        addOrUpdate(taskTask);
    }
}
Also used : BatchTaskTask(com.dtstack.taier.dao.domain.BatchTaskTask) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

BatchTaskTask (com.dtstack.taier.dao.domain.BatchTaskTask)6 JSON (com.alibaba.fastjson.JSON)2 JSONArray (com.alibaba.fastjson.JSONArray)2 JSONObject (com.alibaba.fastjson.JSONObject)2 JSONPath (com.alibaba.fastjson.JSONPath)2 TypeReference (com.alibaba.fastjson.TypeReference)2 ClientCache (com.dtstack.dtcenter.loader.client.ClientCache)2 IClient (com.dtstack.dtcenter.loader.client.IClient)2 IKerberos (com.dtstack.dtcenter.loader.client.IKerberos)2 ColumnMetaDTO (com.dtstack.dtcenter.loader.dto.ColumnMetaDTO)2 SqlQueryDTO (com.dtstack.dtcenter.loader.dto.SqlQueryDTO)2 ISourceDTO (com.dtstack.dtcenter.loader.dto.source.ISourceDTO)2 DataSourceType (com.dtstack.dtcenter.loader.source.DataSourceType)2 PatternConstant (com.dtstack.taier.common.constant.PatternConstant)2 CatalogueType (com.dtstack.taier.common.enums.CatalogueType)2 Deleted (com.dtstack.taier.common.enums.Deleted)2 DependencyType (com.dtstack.taier.common.enums.DependencyType)2 DictType (com.dtstack.taier.common.enums.DictType)2 EComponentType (com.dtstack.taier.common.enums.EComponentType)2 EDeployType (com.dtstack.taier.common.enums.EDeployType)2