Search in sources :

Example 36 with RuleDataSource

use of com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource in project Qualitis by WeBankFinTech.

the class ExecutionManagerImpl method getRuleCluster.

private Map<String, List<Rule>> getRuleCluster(List<Rule> rules) {
    Map<String, List<Rule>> clusterNameMap = new HashMap<>(8);
    for (Rule rule : rules) {
        Map<String, Integer> clusterCount = new HashMap<>(2);
        String maxClusterName = null;
        Integer maxClusterCount = 0;
        for (RuleDataSource ruleDataSource : rule.getRuleDataSources()) {
            if (StringUtils.isBlank(ruleDataSource.getTableName())) {
                continue;
            }
            String clusterName = ruleDataSource.getClusterName();
            if (clusterCount.containsKey(clusterName)) {
                clusterCount.put(clusterName, clusterCount.get(clusterName) + 1);
            } else {
                clusterCount.put(clusterName, 1);
            }
            if (clusterCount.get(clusterName) > maxClusterCount) {
                maxClusterCount = clusterCount.get(clusterName);
                maxClusterName = clusterName;
            }
        }
        LOGGER.info("rule: rule_id: {}, rule_name: {} will be submit to cluster: {}", rule.getId(), rule.getName(), maxClusterName);
        if (!clusterNameMap.containsKey(maxClusterName)) {
            List<Rule> tmp = new ArrayList<>();
            tmp.add(rule);
            clusterNameMap.put(maxClusterName, tmp);
        } else {
            clusterNameMap.get(maxClusterName).add(rule);
        }
    }
    return clusterNameMap;
}
Also used : TaskRuleDataSource(com.webank.wedatasphere.qualitis.bean.TaskRuleDataSource) RuleDataSource(com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) TaskRule(com.webank.wedatasphere.qualitis.bean.TaskRule) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule)

Example 37 with RuleDataSource

use of com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource in project Qualitis by WeBankFinTech.

the class ExecutionManagerImpl method getTaskRuleDataSourceBean.

private List<TaskRuleDataSource> getTaskRuleDataSourceBean(Rule rule) {
    List<TaskRuleDataSource> taskRuleDataSources = new ArrayList<>();
    for (RuleDataSource ruleDataSource : rule.getRuleDataSources()) {
        if (StringUtils.isBlank(ruleDataSource.getTableName())) {
            continue;
        }
        TaskRuleDataSource taskRuleDataSource = new TaskRuleDataSource();
        taskRuleDataSource.setClusterName(ruleDataSource.getClusterName());
        taskRuleDataSource.setDatabaseName(ruleDataSource.getDbName());
        taskRuleDataSource.setTableName(ruleDataSource.getTableName());
        taskRuleDataSource.setDatasourceType(ruleDataSource.getDatasourceType());
        taskRuleDataSource.setDatasourceIndex(ruleDataSource.getDatasourceIndex());
        taskRuleDataSource.setColName(ruleDataSource.getColName());
        taskRuleDataSource.setProjectId(rule.getProject().getId());
        taskRuleDataSource.setRuleId(rule.getId());
        taskRuleDataSources.add(taskRuleDataSource);
    }
    return taskRuleDataSources;
}
Also used : TaskRuleDataSource(com.webank.wedatasphere.qualitis.bean.TaskRuleDataSource) RuleDataSource(com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource) ArrayList(java.util.ArrayList) TaskRuleDataSource(com.webank.wedatasphere.qualitis.bean.TaskRuleDataSource)

Aggregations

RuleDataSource (com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource)37 ArrayList (java.util.ArrayList)29 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)21 AlarmConfig (com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig)18 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)14 Template (com.webank.wedatasphere.qualitis.rule.entity.Template)11 HashSet (java.util.HashSet)11 List (java.util.List)10 Set (java.util.Set)10 Transactional (org.springframework.transaction.annotation.Transactional)10 RuleMetric (com.webank.wedatasphere.qualitis.entity.RuleMetric)9 Project (com.webank.wedatasphere.qualitis.project.entity.Project)9 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)9 RuleDataSourceMapping (com.webank.wedatasphere.qualitis.rule.entity.RuleDataSourceMapping)9 Date (java.util.Date)9 HashMap (java.util.HashMap)9 RuleVariable (com.webank.wedatasphere.qualitis.rule.entity.RuleVariable)8 Map (java.util.Map)8 SpecCharEnum (com.webank.wedatasphere.qualitis.constant.SpecCharEnum)6 MetaDataAcquireFailedException (com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException)6