|
@@ -3,6 +3,8 @@ package com.css.simulation.resource.scheduler.dao.manager;
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
import api.common.pojo.common.ResponseBodyVO;
|
|
import api.common.pojo.constants.DictConstants;
|
|
import api.common.pojo.constants.DictConstants;
|
|
import api.common.util.*;
|
|
import api.common.util.*;
|
|
|
|
+import com.css.simulation.resource.scheduler.common.configuration.kubernetes.KubernetesConfiguration;
|
|
|
|
+import com.css.simulation.resource.scheduler.common.util.KubernetesUtil;
|
|
import com.css.simulation.resource.scheduler.dao.mapper.*;
|
|
import com.css.simulation.resource.scheduler.dao.mapper.*;
|
|
import com.css.simulation.resource.scheduler.service.feign.VideoService;
|
|
import com.css.simulation.resource.scheduler.service.feign.VideoService;
|
|
import com.css.simulation.resource.scheduler.dao.entity.IndexTemplatePO;
|
|
import com.css.simulation.resource.scheduler.dao.entity.IndexTemplatePO;
|
|
@@ -17,6 +19,7 @@ import com.css.simulation.resource.scheduler.common.util.ProjectUtil;
|
|
import com.css.simulation.resource.scheduler.common.util.RedisUtil;
|
|
import com.css.simulation.resource.scheduler.common.util.RedisUtil;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
|
+import io.kubernetes.client.openapi.ApiClient;
|
|
import io.minio.MinioClient;
|
|
import io.minio.MinioClient;
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -92,6 +95,10 @@ public class TaskManager {
|
|
private SqlSessionFactory sqlSessionFactory;
|
|
private SqlSessionFactory sqlSessionFactory;
|
|
@Resource
|
|
@Resource
|
|
private TaskLock taskLock;
|
|
private TaskLock taskLock;
|
|
|
|
+ @Resource
|
|
|
|
+ private KubernetesConfiguration kubernetesConfiguration;
|
|
|
|
+ @Resource
|
|
|
|
+ private ApiClient apiClient;
|
|
|
|
|
|
public void batchInsertTask(List<TaskPO> taskPOList) {
|
|
public void batchInsertTask(List<TaskPO> taskPOList) {
|
|
try (SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false)) {
|
|
try (SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false)) {
|
|
@@ -161,6 +168,10 @@ public class TaskManager {
|
|
if (!result) {
|
|
if (!result) {
|
|
log.info("isCompleted() 项目 " + projectId + " 还未运行完成。");
|
|
log.info("isCompleted() 项目 " + projectId + " 还未运行完成。");
|
|
projectUtil.createNextPod3(projectId, nodeName, podName);
|
|
projectUtil.createNextPod3(projectId, nodeName, podName);
|
|
|
|
+ } else {
|
|
|
|
+ //如果项目已完成先把 pod 删除,并归还并行度
|
|
|
|
+ KubernetesUtil.deletePod(apiClient, kubernetesConfiguration.getNamespace(), podName);
|
|
|
|
+ projectUtil.addOneParallelismToNode(nodeName);
|
|
}
|
|
}
|
|
} catch (Exception exception) {
|
|
} catch (Exception exception) {
|
|
log.info("isCompleted() 报错。", exception);
|
|
log.info("isCompleted() 报错。", exception);
|
|
@@ -503,16 +514,16 @@ public class TaskManager {
|
|
// SshUtil.stop(clientKafka, sessionKafka);
|
|
// SshUtil.stop(clientKafka, sessionKafka);
|
|
|
|
|
|
|
|
|
|
- // 归还并行度
|
|
|
|
- Set<String> nodeOfPodKeySet = RedisUtil.getKeySetByPrefix(stringRedisTemplate, "pod:project-" + projectId);
|
|
|
|
- for (String nodeOfPodKey : nodeOfPodKeySet) {
|
|
|
|
- String podName = nodeOfPodKey.split(":")[1];
|
|
|
|
- String nodeName = projectUtil.getNodeNameOfPod(podName);
|
|
|
|
- // 删除 pod
|
|
|
|
- projectUtil.deletePod(podName);
|
|
|
|
- // 节点并行度加一
|
|
|
|
- projectUtil.addOneParallelismToNode(nodeName);
|
|
|
|
- }
|
|
|
|
|
|
+// // 归还并行度
|
|
|
|
+// Set<String> nodeOfPodKeySet = RedisUtil.getKeySetByPrefix(stringRedisTemplate, "pod:project-" + projectId);
|
|
|
|
+// for (String nodeOfPodKey : nodeOfPodKeySet) {
|
|
|
|
+// String podName = nodeOfPodKey.split(":")[1];
|
|
|
|
+// String nodeName = projectUtil.getNodeNameOfPod(podName);
|
|
|
|
+// // 删除 pod
|
|
|
|
+// projectUtil.deletePod(podName);
|
|
|
|
+// // 节点并行度加一
|
|
|
|
+// projectUtil.addOneParallelismToNode(nodeName);
|
|
|
|
+// }
|
|
|
|
|
|
// 删除 redis 中的 项目运行信息 键值对
|
|
// 删除 redis 中的 项目运行信息 键值对
|
|
RedisUtil.deleteByPrefix(stringRedisTemplate, redisPrefix.getProjectRunningKey());
|
|
RedisUtil.deleteByPrefix(stringRedisTemplate, redisPrefix.getProjectRunningKey());
|