Search in sources :

Example 1 with ApplicationTaskSimpleResponse

use of com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse in project Qualitis by WeBankFinTech.

the class OuterExecutionServiceImpl method commonExecution.

@Override
public ApplicationTaskSimpleResponse commonExecution(List<Rule> rules, StringBuffer partition, String executionUser, String nodeName, String startupParam, String clusterName, String setFlag, Map<String, String> execParams, Application newApplication, Date date, StringBuffer runDate) throws RuleVariableNotSupportException, JobSubmitException, RuleVariableNotFoundException, ArgumentException, ConvertException, DataQualityTaskException, TaskTypeException, ClusterInfoNotConfigException, SystemConfigException, UnExpectedRequestException, MetaDataAcquireFailedException, IOException, TaskNotExistException, SemanticException, ParseException, DataSourceMoveException, DataSourceOverSizeException, org.apache.hadoop.hive.ql.parse.ParseException, BothNullDatasourceException, RightNullDatasourceException, LeftNullDatasourceException, java.text.ParseException {
    // current user
    String userName = executionUser;
    // Generate database name.
    String database = generateDatabase(userName);
    LOGGER.info("Succeed to generate database_name: {}", database);
    // Save application
    newApplication.setRuleSize(rules.size());
    newApplication.setSavedDb(database);
    Application saveApplication = applicationDao.saveApplication(newApplication);
    List<TaskSubmitResult> taskSubmitResults = new ArrayList<>();
    List<Rule> fileRules = new ArrayList<>();
    Map<Long, Map> dataSourceMysqlConnect = new HashMap<>(2);
    for (Iterator<Rule> iterator = rules.iterator(); iterator.hasNext(); ) {
        Rule currentRule = iterator.next();
        if (currentRule.getRuleType().equals(RuleTypeEnum.CUSTOM_RULE.getCode())) {
            // Replace with execution parameter and parse datasource to save.
            customReSaveDateSource(currentRule, execParams, clusterName, date);
        }
        List<Map<String, String>> mappingCols = new ArrayList<>();
        getMappingCols(currentRule, mappingCols);
        // Check datasource before submit job.
        try {
            checkDatasource(currentRule, userName, partition, mappingCols, nodeName, clusterName, dataSourceMysqlConnect);
        } catch (BothNullDatasourceException e) {
            Task taskInDb = taskDao.save(new Task(newApplication, newApplication.getSubmitTime(), TaskStatusEnum.SUCCEED.getCode()));
            taskInDb.setClusterName(clusterName);
            TaskRuleSimple taskRuleSimple = new TaskRuleSimple(currentRule, taskInDb);
            Set<TaskDataSource> taskDataSources = new HashSet<>(fileRules.size());
            Set<TaskRuleSimple> taskRuleSimples = new HashSet<>(fileRules.size());
            taskRuleSimples.add(taskRuleSimpleRepository.save(taskRuleSimple));
            for (RuleDataSource ruleDataSource : currentRule.getRuleDataSources()) {
                taskDataSources.add(taskDataSourceRepository.save(new TaskDataSource(ruleDataSource, taskInDb)));
            }
            taskInDb.setEndTime(ExecutionManagerImpl.PRINT_TIME_FORMAT.format(new Date()));
            taskInDb.setTaskDataSources(taskDataSources);
            taskInDb.setTaskRuleSimples(taskRuleSimples);
            TaskResult taskResult = new TaskResult();
            taskResult.setApplicationId(newApplication.getId());
            taskResult.setCreateTime(newApplication.getSubmitTime());
            taskResult.setRuleId(currentRule.getId());
            taskResult.setResultType("Long");
            taskResult.setValue(0 + "");
            taskResultDao.saveTaskResult(taskResult);
            taskDao.save(taskInDb);
            iterator.remove();
            if (!iterator.hasNext()) {
                throw e;
            }
            continue;
        }
        if (currentRule.getRuleType().equals(RuleTypeEnum.FILE_TEMPLATE_RULE.getCode())) {
            fileRules.add(currentRule);
            LOGGER.info("Succeed to find file rule. Rule: {}", currentRule.getId() + " " + currentRule.getName());
            iterator.remove();
        }
    }
    String submitTime = ExecutionManagerImpl.PRINT_TIME_FORMAT.format(date);
    // General task.
    if (!rules.isEmpty()) {
        taskSubmitResults.addAll(executionManager.submitApplication(rules, nodeName, submitTime, userName, database, partition, date, saveApplication, clusterName, startupParam, setFlag, execParams, runDate, dataSourceMysqlConnect));
    }
    // Execute file rule task and save task result.
    if (!fileRules.isEmpty()) {
        taskSubmitResults.add(executionManager.executeFileRule(fileRules, submitTime, saveApplication, userName, clusterName, runDate));
    }
    saveApplication.setTotalTaskNum(taskSubmitResults.size());
    LOGGER.info("Succeed to submit application. result: {}", taskSubmitResults);
    Application applicationInDb = applicationDao.saveApplication(saveApplication);
    LOGGER.info("Succeed to save application. application: {}", applicationInDb);
    return new ApplicationTaskSimpleResponse(taskSubmitResults);
}
Also used : Task(com.webank.wedatasphere.qualitis.entity.Task) RuleDataSource(com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource) ApplicationTaskSimpleResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse) Set(java.util.Set) HashSet(java.util.HashSet) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Date(java.util.Date) TaskDataSource(com.webank.wedatasphere.qualitis.entity.TaskDataSource) BothNullDatasourceException(com.webank.wedatasphere.qualitis.exception.BothNullDatasourceException) TaskResult(com.webank.wedatasphere.qualitis.entity.TaskResult) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule) Application(com.webank.wedatasphere.qualitis.entity.Application) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) TaskRuleSimple(com.webank.wedatasphere.qualitis.entity.TaskRuleSimple) TaskSubmitResult(com.webank.wedatasphere.qualitis.bean.TaskSubmitResult)

Example 2 with ApplicationTaskSimpleResponse

use of com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse in project Qualitis by WeBankFinTech.

the class OuterExecutionServiceImpl method groupExecution.

@Override
public GeneralResponse<?> groupExecution(GroupExecutionRequest request, Integer invokeCode) throws UnExpectedRequestException, PermissionDeniedRequestException {
    LOGGER.info("Execute application by group. group_id: {}", request.getGroupId());
    LOGGER.info("Execute application by nodename. nodename: {}", request.getNodeName());
    // Check Arguments
    GroupExecutionRequest.checkRequest(request);
    String loginUser = getLoginUser(httpServletRequest, request.getCreateUser(), request.getAsync());
    // Check existence of project
    RuleGroup ruleGroupInDb = ruleGroupDao.findById(request.getGroupId());
    if (null == ruleGroupInDb) {
        throw new UnExpectedRequestException("Group_id " + request.getGroupId() + " {&DOES_NOT_EXIST}");
    }
    LOGGER.info("Succeed to find rule group. group_id: {}", ruleGroupInDb.getId());
    Project projectInDb = projectDao.findById(ruleGroupInDb.getProjectId());
    // Check permissions of project
    List<Integer> permissions = new ArrayList<>();
    permissions.add(ProjectUserPermissionEnum.OPERATOR.getCode());
    projectService.checkProjectPermission(projectInDb, loginUser, permissions);
    checkPermissionCreateUserProxyExecuteUser(request.getCreateUser(), request.getExecutionUser());
    // Find all rules
    List<Rule> rules = ruleDao.findByRuleGroup(ruleGroupInDb);
    if (CollectionUtils.isEmpty(rules)) {
        throw new UnExpectedRequestException("{&NO_RULE_CAN_BE_EXECUTED}");
    }
    List<Long> ruleIds = rules.stream().map(Rule::getId).collect(Collectors.toList());
    StringBuffer runDate = new StringBuffer();
    StringBuffer partition = new StringBuffer();
    Map<String, String> execParamMap = new HashMap<>(5);
    parseExecParams(partition, runDate, request.getExecutionParam(), execParamMap);
    List<ApplicationSubmitRequest> applicationSubmitRequests = new ArrayList<>();
    // Construct dynamic partition.
    try {
        submitRulesWithDynamicPartition(applicationSubmitRequests, projectInDb.getId(), ruleGroupInDb.getId(), rules, ruleIds, request.getExecutionUser(), request.getDyNamicPartition(), request.getClusterName(), partition, request.getDyNamicPartitionPrefix());
    } catch (ResourceAccessException e) {
        generateAbnormalApplicationInfo(projectInDb.getId(), request.getGroupId(), request.getCreateUser(), request.getExecutionUser(), new Date(), invokeCode, partition.toString(), request.getStartupParamName(), request.getExecutionParam(), e, ApplicationCommentEnum.METADATA_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules);
        LOGGER.error("One group execution[id={}] of the project execution start failed!", request.getGroupId());
    } catch (NoPartitionException e) {
        generateAbnormalApplicationInfo(projectInDb.getId(), request.getGroupId(), request.getCreateUser(), request.getExecutionUser(), new Date(), invokeCode, partition.toString(), request.getStartupParamName(), request.getExecutionParam(), e, ApplicationCommentEnum.METADATA_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules);
        LOGGER.error("One group execution[id={}] of the project execution start failed!", request.getGroupId());
    } catch (Exception e) {
        generateAbnormalApplicationInfo(projectInDb.getId(), request.getGroupId(), request.getCreateUser(), request.getExecutionUser(), new Date(), invokeCode, partition.toString(), request.getStartupParamName(), request.getExecutionParam(), e, ApplicationCommentEnum.UNKNOWN_ERROR_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules);
        LOGGER.error("One group execution[id={}] of the project execution start failed!", request.getGroupId());
    }
    if (CollectionUtils.isEmpty(ruleIds)) {
        return new GeneralResponse<>("200", "{&SUCCEED_TO_DISPATCH_TASK}", null);
    }
    GeneralResponse<ApplicationTaskSimpleResponse> generalResponse = (GeneralResponse<ApplicationTaskSimpleResponse>) outerExecutionService.submitRules(ruleIds, partition, loginUser, request.getExecutionUser(), request.getNodeName(), projectInDb.getId(), ruleGroupInDb.getId(), request.getStartupParamName(), request.getClusterName(), request.getSetFlag(), execParamMap, request.getExecutionParam(), runDate, invokeCode);
    // Record project event.
    projectEventService.record(projectInDb.getId(), loginUser, "submit group execution", "group[name=" + ruleGroupInDb.getRuleGroupName() + "].", EventTypeEnum.SUBMIT_PROJECT.getCode());
    return generalResponse;
}
Also used : ApplicationSubmitRequest(com.webank.wedatasphere.qualitis.request.ApplicationSubmitRequest) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) ApplicationTaskSimpleResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RuleGroup(com.webank.wedatasphere.qualitis.rule.entity.RuleGroup) ResourceAccessException(org.springframework.web.client.ResourceAccessException) Date(java.util.Date) ClusterInfoNotConfigException(com.webank.wedatasphere.qualitis.exception.ClusterInfoNotConfigException) DataSourceOverSizeException(com.webank.wedatasphere.qualitis.exception.DataSourceOverSizeException) JobSubmitException(com.webank.wedatasphere.qualitis.exception.JobSubmitException) ConvertException(com.webank.wedatasphere.qualitis.exception.ConvertException) LeftNullDatasourceException(com.webank.wedatasphere.qualitis.exception.LeftNullDatasourceException) JobKillException(com.webank.wedatasphere.qualitis.exception.JobKillException) TaskTypeException(com.webank.wedatasphere.qualitis.exception.TaskTypeException) ArgumentException(com.webank.wedatasphere.qualitis.exception.ArgumentException) BothNullDatasourceException(com.webank.wedatasphere.qualitis.exception.BothNullDatasourceException) IOException(java.io.IOException) TaskNotExistException(com.webank.wedatasphere.qualitis.exception.TaskNotExistException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) PermissionDeniedRequestException(com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException) ParseException(org.apache.hadoop.hive.ql.parse.ParseException) SystemConfigException(com.webank.wedatasphere.qualitis.exception.SystemConfigException) RuleVariableNotSupportException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotSupportException) MetaDataAcquireFailedException(com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) LogPartialException(com.webank.wedatasphere.qualitis.exception.LogPartialException) DataQualityTaskException(com.webank.wedatasphere.qualitis.exception.DataQualityTaskException) RuleVariableNotFoundException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotFoundException) DataSourceMoveException(com.webank.wedatasphere.qualitis.exception.DataSourceMoveException) ResourceAccessException(org.springframework.web.client.ResourceAccessException) RightNullDatasourceException(com.webank.wedatasphere.qualitis.exception.RightNullDatasourceException) NoPartitionException(com.webank.wedatasphere.qualitis.exception.NoPartitionException) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) Project(com.webank.wedatasphere.qualitis.project.entity.Project) NoPartitionException(com.webank.wedatasphere.qualitis.exception.NoPartitionException) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule)

Example 3 with ApplicationTaskSimpleResponse

use of com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse in project Qualitis by WeBankFinTech.

the class OuterExecutionServiceImpl method submitRules.

/**
 * Generate jobs by rules and submit jobs to linkis.
 *
 * @param ruleIds
 * @param partition
 * @param createUser
 * @param executionUser
 * @param nodeName
 * @param projectId
 * @param ruleGroupId
 * @param execParams
 * @param runDate
 * @param invokeCode
 * @return
 * @throws UnExpectedRequestException
 */
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW, rollbackFor = { RuntimeException.class, UnExpectedRequestException.class })
public GeneralResponse<?> submitRules(List<Long> ruleIds, StringBuffer partition, String createUser, String executionUser, String nodeName, Long projectId, Long ruleGroupId, String startupParam, String clusterName, String setFlag, Map<String, String> execParams, String execParamStr, StringBuffer runDate, Integer invokeCode) {
    // Get rule eneity.
    List<Rule> rules = ruleDao.findByIds(ruleIds);
    // Init application basic info.
    Date date = new Date();
    Application newApplication = outerExecutionService.generateApplicationInfo(createUser, executionUser, date, invokeCode);
    newApplication.setProjectId(projectId);
    newApplication.setRuleGroupId(ruleGroupId);
    newApplication.setPartition(partition.toString());
    newApplication.setClusterName(clusterName);
    newApplication.setStartupParam(startupParam);
    newApplication.setExecutionParam(execParamStr);
    newApplication.setSetFlag(setFlag);
    ApplicationTaskSimpleResponse response;
    try {
        response = outerExecutionService.commonExecution(rules, partition, executionUser, nodeName, startupParam, clusterName, setFlag, execParams, newApplication, date, runDate);
    } catch (BothNullDatasourceException e) {
        catchAndSolve(e, ApplicationCommentEnum.BOTH_NULL_ISSUES.getCode(), ApplicationStatusEnum.FINISHED.getCode(), rules, newApplication);
        return new GeneralResponse<>("500", e.getMessage(), null);
    } catch (LeftNullDatasourceException e) {
        catchAndSolve(e, ApplicationCommentEnum.LEFT_NULL_DATA_ISSUES.getCode(), ApplicationStatusEnum.NOT_PASS.getCode(), rules, newApplication);
        return new GeneralResponse<>("500", e.getMessage(), null);
    } catch (RightNullDatasourceException e) {
        catchAndSolve(e, ApplicationCommentEnum.RIGHT_NULL_DATA_ISSUES.getCode(), ApplicationStatusEnum.NOT_PASS.getCode(), rules, newApplication);
        return new GeneralResponse<>("500", e.getMessage(), null);
    } catch (MetaDataAcquireFailedException e) {
        catchAndSolve(e, ApplicationCommentEnum.METADATA_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules, newApplication);
        return new GeneralResponse<>("500", "{&THE_CHECK_FIELD_HAS_BEEN_MODIFIED}", null);
    } catch (DataSourceMoveException e) {
        catchAndSolve(e, ApplicationCommentEnum.PERMISSION_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules, newApplication);
        return new GeneralResponse<>("500", e.getMessage(), null);
    } catch (DataSourceOverSizeException e) {
        catchAndSolve(e, ApplicationCommentEnum.PERMISSION_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules, newApplication);
        return new GeneralResponse<>("500", e.getMessage(), null);
    } catch (ParseException e) {
        catchAndSolve(e, ApplicationCommentEnum.GRAMMAR_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules, newApplication);
        LOGGER.error(e.getMessage(), e);
        return new GeneralResponse<>("500", "{&PARSE_SQL_FAILED_PLEASE_CHECKOUT_YOUR_CUSTOM_SQL}", null);
    } catch (Exception e) {
        catchAndSolve(e, ApplicationCommentEnum.UNKNOWN_ERROR_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules, newApplication);
        return new GeneralResponse<>("500", e.getMessage(), null);
    }
    LOGGER.info("Succeed to dispatch task. response: {}", response);
    return new GeneralResponse<>("200", "{&SUCCEED_TO_DISPATCH_TASK}", response);
}
Also used : ApplicationTaskSimpleResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse) LeftNullDatasourceException(com.webank.wedatasphere.qualitis.exception.LeftNullDatasourceException) RightNullDatasourceException(com.webank.wedatasphere.qualitis.exception.RightNullDatasourceException) Date(java.util.Date) ClusterInfoNotConfigException(com.webank.wedatasphere.qualitis.exception.ClusterInfoNotConfigException) DataSourceOverSizeException(com.webank.wedatasphere.qualitis.exception.DataSourceOverSizeException) JobSubmitException(com.webank.wedatasphere.qualitis.exception.JobSubmitException) ConvertException(com.webank.wedatasphere.qualitis.exception.ConvertException) LeftNullDatasourceException(com.webank.wedatasphere.qualitis.exception.LeftNullDatasourceException) JobKillException(com.webank.wedatasphere.qualitis.exception.JobKillException) TaskTypeException(com.webank.wedatasphere.qualitis.exception.TaskTypeException) ArgumentException(com.webank.wedatasphere.qualitis.exception.ArgumentException) BothNullDatasourceException(com.webank.wedatasphere.qualitis.exception.BothNullDatasourceException) IOException(java.io.IOException) TaskNotExistException(com.webank.wedatasphere.qualitis.exception.TaskNotExistException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) PermissionDeniedRequestException(com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException) ParseException(org.apache.hadoop.hive.ql.parse.ParseException) SystemConfigException(com.webank.wedatasphere.qualitis.exception.SystemConfigException) RuleVariableNotSupportException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotSupportException) MetaDataAcquireFailedException(com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) LogPartialException(com.webank.wedatasphere.qualitis.exception.LogPartialException) DataQualityTaskException(com.webank.wedatasphere.qualitis.exception.DataQualityTaskException) RuleVariableNotFoundException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotFoundException) DataSourceMoveException(com.webank.wedatasphere.qualitis.exception.DataSourceMoveException) ResourceAccessException(org.springframework.web.client.ResourceAccessException) RightNullDatasourceException(com.webank.wedatasphere.qualitis.exception.RightNullDatasourceException) NoPartitionException(com.webank.wedatasphere.qualitis.exception.NoPartitionException) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) DataSourceOverSizeException(com.webank.wedatasphere.qualitis.exception.DataSourceOverSizeException) MetaDataAcquireFailedException(com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException) BothNullDatasourceException(com.webank.wedatasphere.qualitis.exception.BothNullDatasourceException) DataSourceMoveException(com.webank.wedatasphere.qualitis.exception.DataSourceMoveException) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule) ParseException(org.apache.hadoop.hive.ql.parse.ParseException) Application(com.webank.wedatasphere.qualitis.entity.Application) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with ApplicationTaskSimpleResponse

use of com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse in project Qualitis by WeBankFinTech.

the class OuterExecutionServiceImpl method dataSourceExecution.

@Override
public GeneralResponse<?> dataSourceExecution(DataSourceExecutionRequest request) throws UnExpectedRequestException, PermissionDeniedRequestException {
    LOGGER.info("Execute application by datasource. cluster: {}, database: {}, table: {}", request.getCluster(), request.getDatabase(), request.getTable());
    // Check Arguments.
    DataSourceExecutionRequest.checkRequest(request);
    String loginUser = getLoginUser(httpServletRequest, request.getCreateUser(), request.getAsync());
    // Find all rule datasources by user.
    List<RuleDataSource> ruleDataSources = new ArrayList<>();
    ruleDataSources.addAll(ruleDataSourceDao.findDatasourcesByUser(loginUser, request.getCluster(), request.getDatabase(), request.getTable()));
    List<Rule> rules = ruleDataSources.stream().filter(r -> r.getClusterName().equals(request.getCluster()) && r.getDbName().equals(request.getDatabase()) && r.getTableName().equals(request.getTable())).map(RuleDataSource::getRule).distinct().filter(rule -> {
        if (!request.getCrossTable()) {
            return rule.getRuleDataSources().size() == 1;
        }
        return true;
    }).collect(Collectors.toList());
    if (CollectionUtils.isEmpty(rules)) {
        throw new UnExpectedRequestException("{&NO_RULE_CAN_BE_EXECUTED}");
    }
    checkPermissionCreateUserProxyExecuteUser(request.getCreateUser(), request.getExecutionUser());
    ApplicationProjectResponse applicationProjectResponse = new ApplicationProjectResponse();
    List<ApplicationSubmitRequest> applicationSubmitRequests = new ArrayList<>();
    StringBuffer partition = new StringBuffer();
    StringBuffer runDate = new StringBuffer();
    Map<String, String> execParamMap = new HashMap<>(5);
    parseExecParams(partition, runDate, request.getExecutionParam(), execParamMap);
    List<Project> projects = rules.stream().map(Rule::getProject).distinct().collect(Collectors.toList());
    for (Project projectInDb : projects) {
        // Check permissions of project
        List<Integer> permissions = new ArrayList<>();
        permissions.add(ProjectUserPermissionEnum.OPERATOR.getCode());
        projectService.checkProjectPermission(projectInDb, loginUser, permissions);
        List<Rule> currentRules = rules.stream().filter(rule -> rule.getProject().getId().equals(projectInDb.getId())).collect(Collectors.toList());
        List<RuleGroup> currentRuleGroups = currentRules.stream().map(Rule::getRuleGroup).distinct().collect(Collectors.toList());
        for (RuleGroup ruleGroup : currentRuleGroups) {
            List<Rule> currentRulesOfGroup = currentRules.stream().filter(rule -> rule.getRuleGroup().getRuleGroupName().equals(ruleGroup.getRuleGroupName())).distinct().collect(Collectors.toList());
            List<Long> currentRuleIds = currentRulesOfGroup.stream().map(Rule::getId).distinct().collect(Collectors.toList());
            LOGGER.info("Succeed to find current rules of one group with datasource. rule_id: {}", currentRuleIds);
            // Dynamic partition.
            try {
                submitRulesWithDynamicPartition(applicationSubmitRequests, projectInDb.getId(), ruleGroup.getId(), rules, currentRuleIds, request.getExecutionUser(), request.getDyNamicPartition(), request.getClusterName(), partition, request.getDyNamicPartitionPrefix());
            } catch (ResourceAccessException e) {
                // Record submit failed applicatoin.
                generateAbnormalApplicationInfo(projectInDb.getId(), ruleGroup.getId(), request.getCreateUser(), request.getExecutionUser(), new Date(), InvokeTypeEnum.BDP_CLIENT_API_INVOKE.getCode(), partition.toString(), request.getStartupParamName(), request.getExecutionParam(), e, ApplicationCommentEnum.METADATA_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules);
                LOGGER.error("One group execution[id={}] of the datasource execution start failed!", ruleGroup.getId());
            } catch (NoPartitionException e) {
                // Record submit failed applicatoin.
                generateAbnormalApplicationInfo(projectInDb.getId(), ruleGroup.getId(), request.getCreateUser(), request.getExecutionUser(), new Date(), InvokeTypeEnum.BDP_CLIENT_API_INVOKE.getCode(), partition.toString(), request.getStartupParamName(), request.getExecutionParam(), e, ApplicationCommentEnum.METADATA_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules);
                LOGGER.error("One group execution[id={}] of the datasource execution start failed!", ruleGroup.getId());
            } catch (Exception e) {
                // Record submit failed applicatoin.
                generateAbnormalApplicationInfo(projectInDb.getId(), ruleGroup.getId(), request.getCreateUser(), request.getExecutionUser(), new Date(), InvokeTypeEnum.BDP_CLIENT_API_INVOKE.getCode(), partition.toString(), request.getStartupParamName(), request.getExecutionParam(), e, ApplicationCommentEnum.UNKNOWN_ERROR_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules);
                LOGGER.error("One group execution[id={}] of the datasource execution start failed!", ruleGroup.getId());
            }
            if (CollectionUtils.isNotEmpty(currentRuleIds)) {
                applicationSubmitRequests.add(new ApplicationSubmitRequest(request.getJobId(), projectInDb.getId(), ruleGroup.getId(), currentRuleIds, partition));
            }
        }
        projectEventService.record(projectInDb.getId(), loginUser, "submit datasource execution", "rule name[" + Arrays.toString(rules.stream().filter(rule -> rule.getProject().getId().equals(projectInDb.getId())).toArray()) + "].", EventTypeEnum.SUBMIT_PROJECT.getCode());
    }
    GeneralResponse<ApplicationTaskSimpleResponse> generalResponse;
    for (ApplicationSubmitRequest applicationSubmitRequest : applicationSubmitRequests) {
        if (StringUtils.isNotBlank(request.getJobId())) {
            applicationSubmitRequest.setJobId(request.getJobId());
        }
        generalResponse = (GeneralResponse<ApplicationTaskSimpleResponse>) outerExecutionService.submitRules(applicationSubmitRequest.getRuleIds(), applicationSubmitRequest.getPartition(), loginUser, request.getExecutionUser(), DEFAULT_NODE_NAME, applicationSubmitRequest.getProjectId(), applicationSubmitRequest.getRuleGroupId(), request.getStartupParamName(), request.getClusterName(), request.getSetFlag(), execParamMap, request.getExecutionParam(), runDate, InvokeTypeEnum.BDP_CLIENT_API_INVOKE.getCode());
        applicationProjectResponse.getApplicationTaskSimpleResponses().add(generalResponse.getData());
    }
    return new GeneralResponse<>("200", "{&SUCCEED_TO_DISPATCH_TASK}", applicationProjectResponse);
}
Also used : AlarmConfigStatusEnum(com.webank.wedatasphere.qualitis.constant.AlarmConfigStatusEnum) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) ClusterInfoNotConfigException(com.webank.wedatasphere.qualitis.exception.ClusterInfoNotConfigException) Autowired(org.springframework.beans.factory.annotation.Autowired) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) AlarmConfig(com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig) ApplicationTaskSimpleResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse) DataSourceOverSizeException(com.webank.wedatasphere.qualitis.exception.DataSourceOverSizeException) GroupExecutionRequest(com.webank.wedatasphere.qualitis.request.GroupExecutionRequest) HttpUtils(com.webank.wedatasphere.qualitis.util.HttpUtils) Map(java.util.Map) LocaleParser(com.webank.wedatasphere.qualitis.parser.LocaleParser) JobSubmitException(com.webank.wedatasphere.qualitis.exception.JobSubmitException) ConvertException(com.webank.wedatasphere.qualitis.exception.ConvertException) MonitorManager(com.webank.wedatasphere.qualitis.job.MonitorManager) ProjectUserPermissionEnum(com.webank.wedatasphere.qualitis.project.constant.ProjectUserPermissionEnum) Set(java.util.Set) RuleConstraintEnum(com.webank.wedatasphere.qualitis.metadata.constant.RuleConstraintEnum) UserProxyUser(com.webank.wedatasphere.qualitis.entity.UserProxyUser) TableStat(com.alibaba.druid.stat.TableStat) InvokeTypeEnum(com.webank.wedatasphere.qualitis.constant.InvokeTypeEnum) LeftNullDatasourceException(com.webank.wedatasphere.qualitis.exception.LeftNullDatasourceException) MetaDataClient(com.webank.wedatasphere.qualitis.metadata.client.MetaDataClient) DbType(com.alibaba.druid.DbType) GeneralExecutionRequest(com.webank.wedatasphere.qualitis.request.GeneralExecutionRequest) Project(com.webank.wedatasphere.qualitis.project.entity.Project) TaskStatusEnum(com.webank.wedatasphere.qualitis.constant.TaskStatusEnum) JobKillException(com.webank.wedatasphere.qualitis.exception.JobKillException) RuleDataSourceDao(com.webank.wedatasphere.qualitis.rule.dao.RuleDataSourceDao) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule) ProjectDao(com.webank.wedatasphere.qualitis.project.dao.ProjectDao) ApplicationTaskResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskResponse) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) HttpServletRequest(javax.servlet.http.HttpServletRequest) RuleListExecutionRequest(com.webank.wedatasphere.qualitis.request.RuleListExecutionRequest) TaskDao(com.webank.wedatasphere.qualitis.dao.TaskDao) ApplicationResultResponse(com.webank.wedatasphere.qualitis.response.ApplicationResultResponse) Service(org.springframework.stereotype.Service) TaskTypeException(com.webank.wedatasphere.qualitis.exception.TaskTypeException) TaskResult(com.webank.wedatasphere.qualitis.entity.TaskResult) ArgumentException(com.webank.wedatasphere.qualitis.exception.ArgumentException) GetTaskLogRequest(com.webank.wedatasphere.qualitis.request.GetTaskLogRequest) CsTableInfoDetail(com.webank.wedatasphere.qualitis.metadata.response.table.CsTableInfoDetail) MySqlSchemaStatVisitor(com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor) SystemConfigDao(com.webank.wedatasphere.qualitis.dao.SystemConfigDao) ExceptionUtils(org.apache.commons.lang.exception.ExceptionUtils) TaskRuleSimpleRepository(com.webank.wedatasphere.qualitis.dao.repository.TaskRuleSimpleRepository) BothNullDatasourceException(com.webank.wedatasphere.qualitis.exception.BothNullDatasourceException) IOException(java.io.IOException) TaskRuleSimple(com.webank.wedatasphere.qualitis.entity.TaskRuleSimple) DataInfo(com.webank.wedatasphere.qualitis.metadata.response.DataInfo) SystemKeyConfig(com.webank.wedatasphere.qualitis.config.SystemKeyConfig) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement) UserDao(com.webank.wedatasphere.qualitis.dao.UserDao) UnitTransfer(com.webank.wedatasphere.qualitis.rule.util.UnitTransfer) LogResult(com.webank.wedatasphere.qualitis.bean.LogResult) TaskDataSource(com.webank.wedatasphere.qualitis.entity.TaskDataSource) Date(java.util.Date) LinkisConfig(com.webank.wedatasphere.qualitis.config.LinkisConfig) LoggerFactory(org.slf4j.LoggerFactory) GetUserColumnByCsRequest(com.webank.wedatasphere.qualitis.metadata.request.GetUserColumnByCsRequest) Application(com.webank.wedatasphere.qualitis.entity.Application) TaskNotExistException(com.webank.wedatasphere.qualitis.exception.TaskNotExistException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) ProjectUserDao(com.webank.wedatasphere.qualitis.project.dao.ProjectUserDao) DataSourceExecutionRequest(com.webank.wedatasphere.qualitis.request.DataSourceExecutionRequest) PermissionDeniedRequestException(com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException) ApplicationCommentEnum(com.webank.wedatasphere.qualitis.constant.ApplicationCommentEnum) EventTypeEnum(com.webank.wedatasphere.qualitis.project.constant.EventTypeEnum) RuleDataSource(com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource) DateExprReplaceUtil(com.webank.wedatasphere.qualitis.util.DateExprReplaceUtil) ClusterInfoDao(com.webank.wedatasphere.qualitis.dao.ClusterInfoDao) ParseException(org.apache.hadoop.hive.ql.parse.ParseException) Task(com.webank.wedatasphere.qualitis.entity.Task) OuterExecutionService(com.webank.wedatasphere.qualitis.service.OuterExecutionService) RuleGroupDao(com.webank.wedatasphere.qualitis.rule.dao.RuleGroupDao) TaskRuleAlarmConfig(com.webank.wedatasphere.qualitis.entity.TaskRuleAlarmConfig) SystemConfigException(com.webank.wedatasphere.qualitis.exception.SystemConfigException) ProjectService(com.webank.wedatasphere.qualitis.project.service.ProjectService) RuleVariableNotSupportException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotSupportException) ProjectEventService(com.webank.wedatasphere.qualitis.project.service.ProjectEventService) ExecutionManager(com.webank.wedatasphere.qualitis.submitter.ExecutionManager) PartitionStatisticsInfo(com.webank.wedatasphere.qualitis.metadata.response.table.PartitionStatisticsInfo) Context(javax.ws.rs.core.Context) UuidGenerator(com.webank.wedatasphere.qualitis.util.UuidGenerator) Collectors(java.util.stream.Collectors) RuleDataSourceMapping(com.webank.wedatasphere.qualitis.rule.entity.RuleDataSourceMapping) MetaDataAcquireFailedException(com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException) ApplicationProjectResponse(com.webank.wedatasphere.qualitis.response.ApplicationProjectResponse) ExecutionManagerImpl(com.webank.wedatasphere.qualitis.submitter.impl.ExecutionManagerImpl) List(java.util.List) ClusterInfo(com.webank.wedatasphere.qualitis.entity.ClusterInfo) JdbcConstants(com.alibaba.druid.util.JdbcConstants) ApplicationSubmitRequest(com.webank.wedatasphere.qualitis.request.ApplicationSubmitRequest) SystemConfig(com.webank.wedatasphere.qualitis.entity.SystemConfig) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) LogPartialException(com.webank.wedatasphere.qualitis.exception.LogPartialException) BeanUtils(org.springframework.beans.BeanUtils) RuleGroup(com.webank.wedatasphere.qualitis.rule.entity.RuleGroup) SpecCharEnum(com.webank.wedatasphere.qualitis.constant.SpecCharEnum) HashMap(java.util.HashMap) HashSet(java.util.HashSet) User(com.webank.wedatasphere.qualitis.entity.User) CollectionUtils(org.apache.commons.collections.CollectionUtils) Propagation(org.springframework.transaction.annotation.Propagation) Name(com.alibaba.druid.stat.TableStat.Name) TaskSubmitResult(com.webank.wedatasphere.qualitis.bean.TaskSubmitResult) DataQualityTaskException(com.webank.wedatasphere.qualitis.exception.DataQualityTaskException) ApplicationStatusEnum(com.webank.wedatasphere.qualitis.constant.ApplicationStatusEnum) TaskDataSourceRepository(com.webank.wedatasphere.qualitis.dao.repository.TaskDataSourceRepository) GetUserTableByCsIdRequest(com.webank.wedatasphere.qualitis.metadata.request.GetUserTableByCsIdRequest) RuleVariableNotFoundException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotFoundException) DataSourceMoveException(com.webank.wedatasphere.qualitis.exception.DataSourceMoveException) SQLUtils(com.alibaba.druid.sql.SQLUtils) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) RuleMetric(com.webank.wedatasphere.qualitis.entity.RuleMetric) ResourceAccessException(org.springframework.web.client.ResourceAccessException) ColumnInfoDetail(com.webank.wedatasphere.qualitis.metadata.response.column.ColumnInfoDetail) FastDateFormat(org.apache.commons.lang3.time.FastDateFormat) TableStatisticsInfo(com.webank.wedatasphere.qualitis.metadata.response.table.TableStatisticsInfo) RuleTypeEnum(com.webank.wedatasphere.qualitis.rule.constant.RuleTypeEnum) ProjectExecutionRequest(com.webank.wedatasphere.qualitis.request.ProjectExecutionRequest) RightNullDatasourceException(com.webank.wedatasphere.qualitis.exception.RightNullDatasourceException) RuleDao(com.webank.wedatasphere.qualitis.rule.dao.RuleDao) ApplicationDao(com.webank.wedatasphere.qualitis.dao.ApplicationDao) NoPartitionException(com.webank.wedatasphere.qualitis.exception.NoPartitionException) TaskResultDao(com.webank.wedatasphere.qualitis.dao.TaskResultDao) HiveSqlParser(com.webank.wedatasphere.qualitis.parser.HiveSqlParser) Transactional(org.springframework.transaction.annotation.Transactional) ApplicationSubmitRequest(com.webank.wedatasphere.qualitis.request.ApplicationSubmitRequest) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) RuleDataSource(com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource) ApplicationTaskSimpleResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse) ApplicationProjectResponse(com.webank.wedatasphere.qualitis.response.ApplicationProjectResponse) RuleGroup(com.webank.wedatasphere.qualitis.rule.entity.RuleGroup) ResourceAccessException(org.springframework.web.client.ResourceAccessException) Date(java.util.Date) ClusterInfoNotConfigException(com.webank.wedatasphere.qualitis.exception.ClusterInfoNotConfigException) DataSourceOverSizeException(com.webank.wedatasphere.qualitis.exception.DataSourceOverSizeException) JobSubmitException(com.webank.wedatasphere.qualitis.exception.JobSubmitException) ConvertException(com.webank.wedatasphere.qualitis.exception.ConvertException) LeftNullDatasourceException(com.webank.wedatasphere.qualitis.exception.LeftNullDatasourceException) JobKillException(com.webank.wedatasphere.qualitis.exception.JobKillException) TaskTypeException(com.webank.wedatasphere.qualitis.exception.TaskTypeException) ArgumentException(com.webank.wedatasphere.qualitis.exception.ArgumentException) BothNullDatasourceException(com.webank.wedatasphere.qualitis.exception.BothNullDatasourceException) IOException(java.io.IOException) TaskNotExistException(com.webank.wedatasphere.qualitis.exception.TaskNotExistException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) PermissionDeniedRequestException(com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException) ParseException(org.apache.hadoop.hive.ql.parse.ParseException) SystemConfigException(com.webank.wedatasphere.qualitis.exception.SystemConfigException) RuleVariableNotSupportException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotSupportException) MetaDataAcquireFailedException(com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) LogPartialException(com.webank.wedatasphere.qualitis.exception.LogPartialException) DataQualityTaskException(com.webank.wedatasphere.qualitis.exception.DataQualityTaskException) RuleVariableNotFoundException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotFoundException) DataSourceMoveException(com.webank.wedatasphere.qualitis.exception.DataSourceMoveException) ResourceAccessException(org.springframework.web.client.ResourceAccessException) RightNullDatasourceException(com.webank.wedatasphere.qualitis.exception.RightNullDatasourceException) NoPartitionException(com.webank.wedatasphere.qualitis.exception.NoPartitionException) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) Project(com.webank.wedatasphere.qualitis.project.entity.Project) NoPartitionException(com.webank.wedatasphere.qualitis.exception.NoPartitionException) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule)

Example 5 with ApplicationTaskSimpleResponse

use of com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse in project Qualitis by WeBankFinTech.

the class OuterExecutionServiceImpl method ruleListExecution.

@Override
public GeneralResponse<?> ruleListExecution(RuleListExecutionRequest request, Integer invokeCode) throws UnExpectedRequestException, PermissionDeniedRequestException {
    LOGGER.info("Execute application by rules. rule_ids: {}", request.getRuleList());
    // Check Arguments.
    RuleListExecutionRequest.checkRequest(request);
    String loginUser = getLoginUser(httpServletRequest, request.getCreateUser(), request.getAsync());
    // Check the existence of rule.
    List<Rule> rules = ruleDao.findByIds(request.getRuleList());
    if (CollectionUtils.isEmpty(rules)) {
        throw new UnExpectedRequestException("{&NO_RULE_CAN_BE_EXECUTED}");
    }
    List<Long> ruleIds = rules.stream().map(Rule::getId).distinct().collect(Collectors.toList());
    // Check rule exists on the request.
    List<Long> notExistRules = request.getRuleList().stream().filter(ruleId -> !ruleIds.contains(ruleId)).collect(Collectors.toList());
    if (!notExistRules.isEmpty()) {
        throw new UnExpectedRequestException("The ids of rule: " + notExistRules.toString() + " {&DOES_NOT_EXIST}");
    }
    LOGGER.info("Succeed to find all rules.");
    checkPermissionCreateUserProxyExecuteUser(request.getCreateUser(), request.getExecutionUser());
    StringBuffer runDate = new StringBuffer();
    StringBuffer partition = new StringBuffer();
    Map<String, String> execParamMap = new HashMap<>(5);
    parseExecParams(partition, runDate, request.getExecutionParam(), execParamMap);
    ApplicationProjectResponse applicationProjectResponse = new ApplicationProjectResponse();
    List<ApplicationSubmitRequest> applicationSubmitRequests = new ArrayList<>(rules.size());
    List<Project> projects = rules.stream().map(Rule::getProject).distinct().collect(Collectors.toList());
    GeneralResponse<ApplicationTaskSimpleResponse> generalResponse;
    // Check permissions of projects.
    for (Project projectInDb : projects) {
        List<Integer> permissions = new ArrayList<>();
        permissions.add(ProjectUserPermissionEnum.OPERATOR.getCode());
        projectService.checkProjectPermission(projectInDb, loginUser, permissions);
        List<Rule> currentRules = rules.stream().filter(rule -> rule.getProject().getId().equals(projectInDb.getId())).collect(Collectors.toList());
        List<RuleGroup> currentRuleGroups = currentRules.stream().map(Rule::getRuleGroup).distinct().collect(Collectors.toList());
        for (RuleGroup ruleGroup : currentRuleGroups) {
            List<Rule> currentRulesOfGroup = currentRules.stream().filter(rule -> rule.getRuleGroup().getRuleGroupName().equals(ruleGroup.getRuleGroupName())).distinct().collect(Collectors.toList());
            List<Long> currentRuleIds = currentRulesOfGroup.stream().map(Rule::getId).distinct().collect(Collectors.toList());
            // Dynamic partition.
            try {
                submitRulesWithDynamicPartition(applicationSubmitRequests, projectInDb.getId(), ruleGroup.getId(), currentRulesOfGroup, currentRuleIds, request.getExecutionUser(), request.getDyNamicPartition(), request.getClusterName(), partition, request.getDyNamicPartitionPrefix());
                if (CollectionUtils.isEmpty(currentRuleIds)) {
                    continue;
                }
            } catch (ResourceAccessException e) {
                // Record submit failed applicatoin.
                generateAbnormalApplicationInfo(projectInDb.getId(), ruleGroup.getId(), request.getCreateUser(), request.getExecutionUser(), new Date(), invokeCode, partition.toString(), request.getStartupParamName(), request.getExecutionParam(), e, ApplicationCommentEnum.METADATA_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules);
                LOGGER.error("One group execution[id={}] of the rule list execution start failed!", ruleGroup.getId());
            } catch (NoPartitionException e) {
                // Record submit failed applicatoin.
                generateAbnormalApplicationInfo(projectInDb.getId(), ruleGroup.getId(), request.getCreateUser(), request.getExecutionUser(), new Date(), invokeCode, partition.toString(), request.getStartupParamName(), request.getExecutionParam(), e, ApplicationCommentEnum.METADATA_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules);
                LOGGER.error("One group execution[id={}] of the rule list execution start failed!", ruleGroup.getId());
            } catch (Exception e) {
                // Record submit failed applicatoin.
                generateAbnormalApplicationInfo(projectInDb.getId(), ruleGroup.getId(), request.getCreateUser(), request.getExecutionUser(), new Date(), invokeCode, partition.toString(), request.getStartupParamName(), request.getExecutionParam(), e, ApplicationCommentEnum.METADATA_ISSUES.getCode(), ApplicationStatusEnum.TASK_SUBMIT_FAILED.getCode(), rules);
                LOGGER.error("One group execution[id={}] of the rule list execution start failed!", ruleGroup.getId());
            }
            applicationSubmitRequests.add(new ApplicationSubmitRequest(projectInDb.getId(), ruleGroup.getId(), currentRuleIds, partition));
        }
        projectEventService.record(projectInDb.getId(), loginUser, "submit rule list execution", "rule name[" + Arrays.toString(currentRules.toArray()) + "].", EventTypeEnum.SUBMIT_PROJECT.getCode());
    }
    for (ApplicationSubmitRequest applicationSubmitRequest : applicationSubmitRequests) {
        generalResponse = (GeneralResponse<ApplicationTaskSimpleResponse>) outerExecutionService.submitRules(applicationSubmitRequest.getRuleIds(), applicationSubmitRequest.getPartition(), loginUser, request.getExecutionUser(), DEFAULT_NODE_NAME, applicationSubmitRequest.getProjectId(), applicationSubmitRequest.getRuleGroupId(), request.getStartupParamName(), request.getClusterName(), request.getSetFlag(), execParamMap, request.getExecutionParam(), runDate, invokeCode);
        applicationProjectResponse.getApplicationTaskSimpleResponses().add(generalResponse.getData());
    }
    return new GeneralResponse<>("200", "{&SUCCEED_TO_DISPATCH_TASK}", applicationProjectResponse);
}
Also used : AlarmConfigStatusEnum(com.webank.wedatasphere.qualitis.constant.AlarmConfigStatusEnum) Arrays(java.util.Arrays) StringUtils(org.apache.commons.lang.StringUtils) ClusterInfoNotConfigException(com.webank.wedatasphere.qualitis.exception.ClusterInfoNotConfigException) Autowired(org.springframework.beans.factory.annotation.Autowired) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) AlarmConfig(com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig) ApplicationTaskSimpleResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse) DataSourceOverSizeException(com.webank.wedatasphere.qualitis.exception.DataSourceOverSizeException) GroupExecutionRequest(com.webank.wedatasphere.qualitis.request.GroupExecutionRequest) HttpUtils(com.webank.wedatasphere.qualitis.util.HttpUtils) Map(java.util.Map) LocaleParser(com.webank.wedatasphere.qualitis.parser.LocaleParser) JobSubmitException(com.webank.wedatasphere.qualitis.exception.JobSubmitException) ConvertException(com.webank.wedatasphere.qualitis.exception.ConvertException) MonitorManager(com.webank.wedatasphere.qualitis.job.MonitorManager) ProjectUserPermissionEnum(com.webank.wedatasphere.qualitis.project.constant.ProjectUserPermissionEnum) Set(java.util.Set) RuleConstraintEnum(com.webank.wedatasphere.qualitis.metadata.constant.RuleConstraintEnum) UserProxyUser(com.webank.wedatasphere.qualitis.entity.UserProxyUser) TableStat(com.alibaba.druid.stat.TableStat) InvokeTypeEnum(com.webank.wedatasphere.qualitis.constant.InvokeTypeEnum) LeftNullDatasourceException(com.webank.wedatasphere.qualitis.exception.LeftNullDatasourceException) MetaDataClient(com.webank.wedatasphere.qualitis.metadata.client.MetaDataClient) DbType(com.alibaba.druid.DbType) GeneralExecutionRequest(com.webank.wedatasphere.qualitis.request.GeneralExecutionRequest) Project(com.webank.wedatasphere.qualitis.project.entity.Project) TaskStatusEnum(com.webank.wedatasphere.qualitis.constant.TaskStatusEnum) JobKillException(com.webank.wedatasphere.qualitis.exception.JobKillException) RuleDataSourceDao(com.webank.wedatasphere.qualitis.rule.dao.RuleDataSourceDao) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule) ProjectDao(com.webank.wedatasphere.qualitis.project.dao.ProjectDao) ApplicationTaskResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskResponse) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) HttpServletRequest(javax.servlet.http.HttpServletRequest) RuleListExecutionRequest(com.webank.wedatasphere.qualitis.request.RuleListExecutionRequest) TaskDao(com.webank.wedatasphere.qualitis.dao.TaskDao) ApplicationResultResponse(com.webank.wedatasphere.qualitis.response.ApplicationResultResponse) Service(org.springframework.stereotype.Service) TaskTypeException(com.webank.wedatasphere.qualitis.exception.TaskTypeException) TaskResult(com.webank.wedatasphere.qualitis.entity.TaskResult) ArgumentException(com.webank.wedatasphere.qualitis.exception.ArgumentException) GetTaskLogRequest(com.webank.wedatasphere.qualitis.request.GetTaskLogRequest) CsTableInfoDetail(com.webank.wedatasphere.qualitis.metadata.response.table.CsTableInfoDetail) MySqlSchemaStatVisitor(com.alibaba.druid.sql.dialect.mysql.visitor.MySqlSchemaStatVisitor) SystemConfigDao(com.webank.wedatasphere.qualitis.dao.SystemConfigDao) ExceptionUtils(org.apache.commons.lang.exception.ExceptionUtils) TaskRuleSimpleRepository(com.webank.wedatasphere.qualitis.dao.repository.TaskRuleSimpleRepository) BothNullDatasourceException(com.webank.wedatasphere.qualitis.exception.BothNullDatasourceException) IOException(java.io.IOException) TaskRuleSimple(com.webank.wedatasphere.qualitis.entity.TaskRuleSimple) DataInfo(com.webank.wedatasphere.qualitis.metadata.response.DataInfo) SystemKeyConfig(com.webank.wedatasphere.qualitis.config.SystemKeyConfig) SQLStatement(com.alibaba.druid.sql.ast.SQLStatement) UserDao(com.webank.wedatasphere.qualitis.dao.UserDao) UnitTransfer(com.webank.wedatasphere.qualitis.rule.util.UnitTransfer) LogResult(com.webank.wedatasphere.qualitis.bean.LogResult) TaskDataSource(com.webank.wedatasphere.qualitis.entity.TaskDataSource) Date(java.util.Date) LinkisConfig(com.webank.wedatasphere.qualitis.config.LinkisConfig) LoggerFactory(org.slf4j.LoggerFactory) GetUserColumnByCsRequest(com.webank.wedatasphere.qualitis.metadata.request.GetUserColumnByCsRequest) Application(com.webank.wedatasphere.qualitis.entity.Application) TaskNotExistException(com.webank.wedatasphere.qualitis.exception.TaskNotExistException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) ProjectUserDao(com.webank.wedatasphere.qualitis.project.dao.ProjectUserDao) DataSourceExecutionRequest(com.webank.wedatasphere.qualitis.request.DataSourceExecutionRequest) PermissionDeniedRequestException(com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException) ApplicationCommentEnum(com.webank.wedatasphere.qualitis.constant.ApplicationCommentEnum) EventTypeEnum(com.webank.wedatasphere.qualitis.project.constant.EventTypeEnum) RuleDataSource(com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource) DateExprReplaceUtil(com.webank.wedatasphere.qualitis.util.DateExprReplaceUtil) ClusterInfoDao(com.webank.wedatasphere.qualitis.dao.ClusterInfoDao) ParseException(org.apache.hadoop.hive.ql.parse.ParseException) Task(com.webank.wedatasphere.qualitis.entity.Task) OuterExecutionService(com.webank.wedatasphere.qualitis.service.OuterExecutionService) RuleGroupDao(com.webank.wedatasphere.qualitis.rule.dao.RuleGroupDao) TaskRuleAlarmConfig(com.webank.wedatasphere.qualitis.entity.TaskRuleAlarmConfig) SystemConfigException(com.webank.wedatasphere.qualitis.exception.SystemConfigException) ProjectService(com.webank.wedatasphere.qualitis.project.service.ProjectService) RuleVariableNotSupportException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotSupportException) ProjectEventService(com.webank.wedatasphere.qualitis.project.service.ProjectEventService) ExecutionManager(com.webank.wedatasphere.qualitis.submitter.ExecutionManager) PartitionStatisticsInfo(com.webank.wedatasphere.qualitis.metadata.response.table.PartitionStatisticsInfo) Context(javax.ws.rs.core.Context) UuidGenerator(com.webank.wedatasphere.qualitis.util.UuidGenerator) Collectors(java.util.stream.Collectors) RuleDataSourceMapping(com.webank.wedatasphere.qualitis.rule.entity.RuleDataSourceMapping) MetaDataAcquireFailedException(com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException) ApplicationProjectResponse(com.webank.wedatasphere.qualitis.response.ApplicationProjectResponse) ExecutionManagerImpl(com.webank.wedatasphere.qualitis.submitter.impl.ExecutionManagerImpl) List(java.util.List) ClusterInfo(com.webank.wedatasphere.qualitis.entity.ClusterInfo) JdbcConstants(com.alibaba.druid.util.JdbcConstants) ApplicationSubmitRequest(com.webank.wedatasphere.qualitis.request.ApplicationSubmitRequest) SystemConfig(com.webank.wedatasphere.qualitis.entity.SystemConfig) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) LogPartialException(com.webank.wedatasphere.qualitis.exception.LogPartialException) BeanUtils(org.springframework.beans.BeanUtils) RuleGroup(com.webank.wedatasphere.qualitis.rule.entity.RuleGroup) SpecCharEnum(com.webank.wedatasphere.qualitis.constant.SpecCharEnum) HashMap(java.util.HashMap) HashSet(java.util.HashSet) User(com.webank.wedatasphere.qualitis.entity.User) CollectionUtils(org.apache.commons.collections.CollectionUtils) Propagation(org.springframework.transaction.annotation.Propagation) Name(com.alibaba.druid.stat.TableStat.Name) TaskSubmitResult(com.webank.wedatasphere.qualitis.bean.TaskSubmitResult) DataQualityTaskException(com.webank.wedatasphere.qualitis.exception.DataQualityTaskException) ApplicationStatusEnum(com.webank.wedatasphere.qualitis.constant.ApplicationStatusEnum) TaskDataSourceRepository(com.webank.wedatasphere.qualitis.dao.repository.TaskDataSourceRepository) GetUserTableByCsIdRequest(com.webank.wedatasphere.qualitis.metadata.request.GetUserTableByCsIdRequest) RuleVariableNotFoundException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotFoundException) DataSourceMoveException(com.webank.wedatasphere.qualitis.exception.DataSourceMoveException) SQLUtils(com.alibaba.druid.sql.SQLUtils) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) RuleMetric(com.webank.wedatasphere.qualitis.entity.RuleMetric) ResourceAccessException(org.springframework.web.client.ResourceAccessException) ColumnInfoDetail(com.webank.wedatasphere.qualitis.metadata.response.column.ColumnInfoDetail) FastDateFormat(org.apache.commons.lang3.time.FastDateFormat) TableStatisticsInfo(com.webank.wedatasphere.qualitis.metadata.response.table.TableStatisticsInfo) RuleTypeEnum(com.webank.wedatasphere.qualitis.rule.constant.RuleTypeEnum) ProjectExecutionRequest(com.webank.wedatasphere.qualitis.request.ProjectExecutionRequest) RightNullDatasourceException(com.webank.wedatasphere.qualitis.exception.RightNullDatasourceException) RuleDao(com.webank.wedatasphere.qualitis.rule.dao.RuleDao) ApplicationDao(com.webank.wedatasphere.qualitis.dao.ApplicationDao) NoPartitionException(com.webank.wedatasphere.qualitis.exception.NoPartitionException) TaskResultDao(com.webank.wedatasphere.qualitis.dao.TaskResultDao) HiveSqlParser(com.webank.wedatasphere.qualitis.parser.HiveSqlParser) Transactional(org.springframework.transaction.annotation.Transactional) ApplicationSubmitRequest(com.webank.wedatasphere.qualitis.request.ApplicationSubmitRequest) LinkedHashMap(java.util.LinkedHashMap) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) ApplicationTaskSimpleResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse) ApplicationProjectResponse(com.webank.wedatasphere.qualitis.response.ApplicationProjectResponse) RuleGroup(com.webank.wedatasphere.qualitis.rule.entity.RuleGroup) ResourceAccessException(org.springframework.web.client.ResourceAccessException) Date(java.util.Date) ClusterInfoNotConfigException(com.webank.wedatasphere.qualitis.exception.ClusterInfoNotConfigException) DataSourceOverSizeException(com.webank.wedatasphere.qualitis.exception.DataSourceOverSizeException) JobSubmitException(com.webank.wedatasphere.qualitis.exception.JobSubmitException) ConvertException(com.webank.wedatasphere.qualitis.exception.ConvertException) LeftNullDatasourceException(com.webank.wedatasphere.qualitis.exception.LeftNullDatasourceException) JobKillException(com.webank.wedatasphere.qualitis.exception.JobKillException) TaskTypeException(com.webank.wedatasphere.qualitis.exception.TaskTypeException) ArgumentException(com.webank.wedatasphere.qualitis.exception.ArgumentException) BothNullDatasourceException(com.webank.wedatasphere.qualitis.exception.BothNullDatasourceException) IOException(java.io.IOException) TaskNotExistException(com.webank.wedatasphere.qualitis.exception.TaskNotExistException) SemanticException(org.apache.hadoop.hive.ql.parse.SemanticException) PermissionDeniedRequestException(com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException) ParseException(org.apache.hadoop.hive.ql.parse.ParseException) SystemConfigException(com.webank.wedatasphere.qualitis.exception.SystemConfigException) RuleVariableNotSupportException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotSupportException) MetaDataAcquireFailedException(com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) LogPartialException(com.webank.wedatasphere.qualitis.exception.LogPartialException) DataQualityTaskException(com.webank.wedatasphere.qualitis.exception.DataQualityTaskException) RuleVariableNotFoundException(com.webank.wedatasphere.qualitis.exception.RuleVariableNotFoundException) DataSourceMoveException(com.webank.wedatasphere.qualitis.exception.DataSourceMoveException) ResourceAccessException(org.springframework.web.client.ResourceAccessException) RightNullDatasourceException(com.webank.wedatasphere.qualitis.exception.RightNullDatasourceException) NoPartitionException(com.webank.wedatasphere.qualitis.exception.NoPartitionException) GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) Project(com.webank.wedatasphere.qualitis.project.entity.Project) NoPartitionException(com.webank.wedatasphere.qualitis.exception.NoPartitionException) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule)

Aggregations

BothNullDatasourceException (com.webank.wedatasphere.qualitis.exception.BothNullDatasourceException)5 ApplicationTaskSimpleResponse (com.webank.wedatasphere.qualitis.response.ApplicationTaskSimpleResponse)5 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)5 Date (java.util.Date)5 Application (com.webank.wedatasphere.qualitis.entity.Application)4 ArgumentException (com.webank.wedatasphere.qualitis.exception.ArgumentException)4 ClusterInfoNotConfigException (com.webank.wedatasphere.qualitis.exception.ClusterInfoNotConfigException)4 ConvertException (com.webank.wedatasphere.qualitis.exception.ConvertException)4 DataQualityTaskException (com.webank.wedatasphere.qualitis.exception.DataQualityTaskException)4 DataSourceMoveException (com.webank.wedatasphere.qualitis.exception.DataSourceMoveException)4 DataSourceOverSizeException (com.webank.wedatasphere.qualitis.exception.DataSourceOverSizeException)4 JobKillException (com.webank.wedatasphere.qualitis.exception.JobKillException)4 JobSubmitException (com.webank.wedatasphere.qualitis.exception.JobSubmitException)4 LeftNullDatasourceException (com.webank.wedatasphere.qualitis.exception.LeftNullDatasourceException)4 LogPartialException (com.webank.wedatasphere.qualitis.exception.LogPartialException)4 NoPartitionException (com.webank.wedatasphere.qualitis.exception.NoPartitionException)4 PermissionDeniedRequestException (com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException)4 RightNullDatasourceException (com.webank.wedatasphere.qualitis.exception.RightNullDatasourceException)4 RuleVariableNotFoundException (com.webank.wedatasphere.qualitis.exception.RuleVariableNotFoundException)4 RuleVariableNotSupportException (com.webank.wedatasphere.qualitis.exception.RuleVariableNotSupportException)4