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