|
@@ -65,11 +65,18 @@ public class TaskService {
|
|
@Value("${scheduler.manual-project.result-path-minio}")
|
|
@Value("${scheduler.manual-project.result-path-minio}")
|
|
String resultPathMinio;
|
|
String resultPathMinio;
|
|
@Value("${scheduler.score.hostname}")
|
|
@Value("${scheduler.score.hostname}")
|
|
- String hostname;
|
|
|
|
|
|
+ String hostnameScore;
|
|
@Value("${scheduler.score.username}")
|
|
@Value("${scheduler.score.username}")
|
|
- String username;
|
|
|
|
|
|
+ String usernameScore;
|
|
@Value("${scheduler.score.password}")
|
|
@Value("${scheduler.score.password}")
|
|
- String password;
|
|
|
|
|
|
+ String passwordScore;
|
|
|
|
+
|
|
|
|
+ @Value("${spring.kafka.hostname}")
|
|
|
|
+ String hostnameKafka;
|
|
|
|
+ @Value("${spring.kafka.username}")
|
|
|
|
+ String usernameKafka;
|
|
|
|
+ @Value("${spring.kafka.password}")
|
|
|
|
+ String passwordKafka;
|
|
@Value("${scheduler.score.py-path}")
|
|
@Value("${scheduler.score.py-path}")
|
|
String pyPath;
|
|
String pyPath;
|
|
@Value("${scheduler.linux-temp-path}")
|
|
@Value("${scheduler.linux-temp-path}")
|
|
@@ -114,17 +121,20 @@ public class TaskService {
|
|
}
|
|
}
|
|
projectMapper.updateProjectState(projectId, DictConstants.PROJECT_COMPLETED); // 修改该 project 的状态为已完成
|
|
projectMapper.updateProjectState(projectId, DictConstants.PROJECT_COMPLETED); // 修改该 project 的状态为已完成
|
|
LinuxUtil.execute("kubectl delete job project-" + projectId);
|
|
LinuxUtil.execute("kubectl delete job project-" + projectId);
|
|
|
|
+ ClientSession sessionKafka = SshUtil.getSession(hostnameKafka, usernameKafka, passwordKafka);
|
|
|
|
+// SshUtil.execute(sessionKafka, "/opt/module/kafka_2.13-3.1.0/bin/kafka-topics.sh --bootstrap-server " + hostnameKafka + ":9092 --delete --topic " + projectId);
|
|
|
|
+ SshUtil.execute(sessionKafka, "/opt/module/kafka_2.13-3.1.0/bin/kafka-topics.sh --bootstrap-server " + hostnameKafka + ":9092 --delete --topic test");
|
|
List<TaskPO> taskList = taskMapper.selectTaskListByProjectId(projectId); // 所有任务信息
|
|
List<TaskPO> taskList = taskMapper.selectTaskListByProjectId(projectId); // 所有任务信息
|
|
// -------------------------------- 查询叶子指标 --------------------------------
|
|
// -------------------------------- 查询叶子指标 --------------------------------
|
|
List<IndexTemplatePO> leafIndexTemplateList = indexTemplateMapper.selectLeafIndexWithRuleDetailsByPackageId(scenePackageId);
|
|
List<IndexTemplatePO> leafIndexTemplateList = indexTemplateMapper.selectLeafIndexWithRuleDetailsByPackageId(scenePackageId);
|
|
List<TaskIndexPO> leafTaskIndexList = new ArrayList<>();
|
|
List<TaskIndexPO> leafTaskIndexList = new ArrayList<>();
|
|
log.info("------- /state 共有 " + leafIndexTemplateList.size() + "个叶子节点!");
|
|
log.info("------- /state 共有 " + leafIndexTemplateList.size() + "个叶子节点!");
|
|
|
|
|
|
- ClientSession session = SshUtil.getSession(hostname, username, password);
|
|
|
|
|
|
+ ClientSession sessionScore = SshUtil.getSession(hostnameScore, usernameScore, passwordScore);
|
|
for (int i = 0; i < leafIndexTemplateList.size(); i++) {
|
|
for (int i = 0; i < leafIndexTemplateList.size(); i++) {
|
|
IndexTemplatePO indexTemplatePO = leafIndexTemplateList.get(i);
|
|
IndexTemplatePO indexTemplatePO = leafIndexTemplateList.get(i);
|
|
String indexId = indexTemplatePO.getIndexId();
|
|
String indexId = indexTemplatePO.getIndexId();
|
|
- log.info("------- /state 开始执行对第 " + (i+1) + " 个叶子节点 " + indexId + " 进行打分!");
|
|
|
|
|
|
+ log.info("------- /state 开始执行对第 " + (i + 1) + " 个叶子节点 " + indexId + " 进行打分!");
|
|
String ruleName = indexTemplatePO.getRuleName(); // 打分脚本名称,例如 AEB_1-1
|
|
String ruleName = indexTemplatePO.getRuleName(); // 打分脚本名称,例如 AEB_1-1
|
|
String ruleDetails = indexTemplatePO.getRuleDetails(); // 打分脚本内容
|
|
String ruleDetails = indexTemplatePO.getRuleDetails(); // 打分脚本内容
|
|
String ruleFilePath = pyPath + "script/" + ruleName.split("_")[0] + "/" + ruleName + ".py";
|
|
String ruleFilePath = pyPath + "script/" + ruleName.split("_")[0] + "/" + ruleName + ".py";
|
|
@@ -171,7 +181,7 @@ public class TaskService {
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
log.info("------- /state 开始执行打分命令:" + command);
|
|
log.info("------- /state 开始执行打分命令:" + command);
|
|
- score = JsonUtil.jsonToBean(SshUtil.execute(session, command), ScoreTO.class);
|
|
|
|
|
|
+ score = JsonUtil.jsonToBean(SshUtil.execute(sessionScore, command), ScoreTO.class);
|
|
log.info("------- /state 打分结束,结果为:" + score);
|
|
log.info("------- /state 打分结束,结果为:" + score);
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
throw new RuntimeException("------- /state 任务 " + task2Id + " 打分出错,命令为:" + command + " 修改状态为:" + DictConstants.TASK_ABORTED + "\n" + e.getMessage());
|
|
throw new RuntimeException("------- /state 任务 " + task2Id + " 打分出错,命令为:" + command + " 修改状态为:" + DictConstants.TASK_ABORTED + "\n" + e.getMessage());
|
|
@@ -208,7 +218,7 @@ public class TaskService {
|
|
leafTaskIndex.setIsDeleted("0");
|
|
leafTaskIndex.setIsDeleted("0");
|
|
leafTaskIndexList.add(leafTaskIndex);
|
|
leafTaskIndexList.add(leafTaskIndex);
|
|
}
|
|
}
|
|
- SshUtil.stop(session);
|
|
|
|
|
|
+ SshUtil.stop(sessionScore);
|
|
|
|
|
|
// 根据每个指标的得分和权重算出 project 的总得分。
|
|
// 根据每个指标的得分和权重算出 project 的总得分。
|
|
double totalScore = compute(leafIndexTemplateList);
|
|
double totalScore = compute(leafIndexTemplateList);
|
|
@@ -247,9 +257,6 @@ public class TaskService {
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
public Boolean taskConfirm(String taskId) {
|
|
public Boolean taskConfirm(String taskId) {
|
|
// 查询 task 如果不是 pending 则不执行
|
|
// 查询 task 如果不是 pending 则不执行
|
|
String state = taskMapper.selectStateById(taskId);
|
|
String state = taskMapper.selectStateById(taskId);
|