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;
}
Aggregations