Search in sources :

Example 61 with Rule

use of com.webank.wedatasphere.qualitis.rule.entity.Rule 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)

Aggregations

Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)61 ArrayList (java.util.ArrayList)41 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)35 GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)25 RuleDataSource (com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource)25 Project (com.webank.wedatasphere.qualitis.project.entity.Project)23 AlarmConfig (com.webank.wedatasphere.qualitis.rule.entity.AlarmConfig)21 Date (java.util.Date)20 List (java.util.List)20 Transactional (org.springframework.transaction.annotation.Transactional)19 HashMap (java.util.HashMap)18 RuleMetric (com.webank.wedatasphere.qualitis.entity.RuleMetric)15 IOException (java.io.IOException)15 Set (java.util.Set)14 RuleGroup (com.webank.wedatasphere.qualitis.rule.entity.RuleGroup)13 Template (com.webank.wedatasphere.qualitis.rule.entity.Template)13 HashSet (java.util.HashSet)13 Collectors (java.util.stream.Collectors)13 Logger (org.slf4j.Logger)13 MetaDataAcquireFailedException (com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException)12