|
@@ -1,17 +1,13 @@
|
|
|
package com.css.simulation.resource.scheduler.service;
|
|
|
|
|
|
-import api.common.util.SshUtil;
|
|
|
-import com.css.simulation.resource.scheduler.manager.TaskManager;
|
|
|
-import com.css.simulation.resource.scheduler.mapper.TaskMapper;
|
|
|
+import com.css.simulation.resource.scheduler.entity.PrefixEntity;
|
|
|
import com.css.simulation.resource.scheduler.entity.ProjectEntity;
|
|
|
import com.css.simulation.resource.scheduler.entity.TaskEntity;
|
|
|
-import com.css.simulation.resource.scheduler.entity.PrefixEntity;
|
|
|
+import com.css.simulation.resource.scheduler.manager.TaskManager;
|
|
|
+import com.css.simulation.resource.scheduler.mapper.TaskMapper;
|
|
|
import com.css.simulation.resource.scheduler.util.ProjectUtil;
|
|
|
import lombok.SneakyThrows;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.sshd.client.SshClient;
|
|
|
-import org.apache.sshd.client.session.ClientSession;
|
|
|
-import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -19,28 +15,21 @@ import javax.annotation.Resource;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class TaskService {
|
|
|
-
|
|
|
- @Value("${scheduler.host.hostname}")
|
|
|
- String hostname;
|
|
|
- @Value("${scheduler.host.username}")
|
|
|
- String username;
|
|
|
- @Value("${scheduler.host.password}")
|
|
|
- String password;
|
|
|
@Resource
|
|
|
- TaskManager taskManager;
|
|
|
+ private TaskManager taskManager;
|
|
|
@Resource
|
|
|
- TaskMapper taskMapper;
|
|
|
+ private TaskMapper taskMapper;
|
|
|
@Resource
|
|
|
- ProjectUtil projectUtil;
|
|
|
+ private ProjectUtil projectUtil;
|
|
|
|
|
|
// -------------------------------- Comment --------------------------------
|
|
|
|
|
|
@SneakyThrows
|
|
|
public void taskState(String taskId, String state, String podName) {
|
|
|
- log.info("接收到参数为:taskId=" + taskId + ",state=" + state + ",podName=" + podName);
|
|
|
+ log.info("接收到参数为:taskId={},state={},podName={}", taskId, state, podName);
|
|
|
TaskEntity taskEntity = taskMapper.selectById(taskId);
|
|
|
if (taskEntity == null) {
|
|
|
- log.error("接收到已删除但还在执行的任务:taskId=" + taskId + ",state=" + state + ",podName=" + podName);
|
|
|
+ log.info("接收到已删除但还在执行的任务:taskId={},state={},podName={}", taskId, state, podName);
|
|
|
return;
|
|
|
}
|
|
|
String projectId = taskEntity.getPId(); // 项目 id
|
|
@@ -54,17 +43,15 @@ public class TaskService {
|
|
|
if (!projectCompleted) {
|
|
|
return;
|
|
|
}
|
|
|
- SshClient sshClient = SshUtil.getClient();
|
|
|
- ClientSession clientSession = SshUtil.getSession(sshClient, hostname, username, password);
|
|
|
//2 准备打分
|
|
|
- log.info("项目 " + projectId + " 准备打分。");
|
|
|
+ log.info("项目 {} 准备打分。", projectId);
|
|
|
taskManager.prepareScore(redisPrefix.getProjectRunningKey());
|
|
|
//3 打分
|
|
|
taskManager.score(userId, projectId, projectType);
|
|
|
//4 调用 server 的接口,计算评价等级
|
|
|
taskManager.evaluationLevel(projectId);
|
|
|
//5 结束
|
|
|
- taskManager.done(redisPrefix, sshClient, clientSession, projectId, projectType);
|
|
|
+ taskManager.done(redisPrefix, projectId, projectType);
|
|
|
|
|
|
}
|
|
|
|