LingxinMeng 2 éve
szülő
commit
19a8d5bb5d

+ 2 - 1
api-common/src/main/java/api/common/pojo/po/home/SystemServerPO.java

@@ -3,10 +3,11 @@ package api.common.pojo.po.home;
 
 import api.common.pojo.common.CommonPO;
 import lombok.*;
+import lombok.experimental.SuperBuilder;
 
 @EqualsAndHashCode(callSuper = true)
 @Data
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
 public class SystemServerPO extends CommonPO {

+ 2 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/entity/LeafIndexEntity.java

@@ -2,10 +2,11 @@ package com.css.simulation.resource.scheduler.entity;
 
 import api.common.pojo.common.CommonPO;
 import lombok.*;
+import lombok.experimental.SuperBuilder;
 
 @EqualsAndHashCode(callSuper = true)
 @Data
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
 public class LeafIndexEntity extends CommonPO {

+ 2 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/entity/TaskEntity.java

@@ -2,10 +2,11 @@ package com.css.simulation.resource.scheduler.entity;
 
 import api.common.pojo.common.CommonPO;
 import lombok.*;
+import lombok.experimental.SuperBuilder;
 
 @EqualsAndHashCode(callSuper = true)
 @Data                                                                                                            
-@Builder
+@SuperBuilder
 @NoArgsConstructor
 @AllArgsConstructor
 public class TaskEntity extends CommonPO {

+ 20 - 12
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/util/KubernetesUtil.java

@@ -1,6 +1,6 @@
 package com.css.simulation.resource.scheduler.util;
 
-import api.common.util.SshUtil;
+import api.common.util.OsUtil;
 import io.kubernetes.client.openapi.ApiClient;
 import io.kubernetes.client.openapi.ApiException;
 import io.kubernetes.client.openapi.apis.BatchV1Api;
@@ -8,8 +8,6 @@ import io.kubernetes.client.openapi.apis.CoreV1Api;
 import io.kubernetes.client.openapi.models.*;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.sshd.client.SshClient;
-import org.apache.sshd.client.session.ClientSession;
 
 import java.util.List;
 import java.util.Objects;
@@ -39,21 +37,31 @@ public class KubernetesUtil {
         return result;
     }
 
+//    /**
+//     * 执行 yaml
+//     *
+//     * @param hostname 主机名
+//     * @param username 用户名
+//     * @param password 密码
+//     * @param yamlPath yaml 文件路径
+//     */
+//    @SneakyThrows
+//    public static void applyYaml(String hostname, String username, String password, String yamlPath) {
+//        SshClient client = SshUtil.getClient();
+//        ClientSession session = SshUtil.getSession(client, hostname, username, password);
+//        SshUtil.execute(session, "kubectl apply -f " + yamlPath);
+//        session.close();
+//        client.stop();
+//    }
+
     /**
      * 执行 yaml
      *
-     * @param hostname 主机名
-     * @param username 用户名
-     * @param password 密码
      * @param yamlPath yaml 文件路径
      */
     @SneakyThrows
-    public static void applyYaml(String hostname, String username, String password, String yamlPath) {
-        SshClient client = SshUtil.getClient();
-        ClientSession session = SshUtil.getSession(client, hostname, username, password);
-        SshUtil.execute(session, "kubectl apply -f " + yamlPath);
-        session.close();
-        client.stop();
+    public static void applyYaml(String yamlPath) {
+        OsUtil.exec("kubectl apply -f " + yamlPath);
     }
 
     /**

+ 5 - 12
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/util/ProjectUtil.java

@@ -6,7 +6,6 @@ import api.common.util.*;
 import com.css.simulation.resource.scheduler.configuration.esmini.EsminiConfiguration;
 import com.css.simulation.resource.scheduler.configuration.kubernetes.KubernetesConfiguration;
 import com.css.simulation.resource.scheduler.configuration.redis.CustomRedisClient;
-import com.css.simulation.resource.scheduler.controller.TaskController;
 import com.css.simulation.resource.scheduler.entity.*;
 import com.css.simulation.resource.scheduler.mapper.AutoSubProjectMapper;
 import com.css.simulation.resource.scheduler.mapper.ClusterMapper;
@@ -36,12 +35,6 @@ public class ProjectUtil {
 
     @Value("${scheduler.linux-path.pod-yaml-directory}")
     private String podYamlDirectory;
-    @Value("${scheduler.host.hostname}")
-    private String hostname;
-    @Value("${scheduler.host.username}")
-    private String username;
-    @Value("${scheduler.host.password}")
-    private String password;
 
     @Resource
     private ManualProjectMapper manualProjectMapper;
@@ -157,7 +150,7 @@ public class ProjectUtil {
             final String replace = read.replace("cpu-order", "\"" + cpuOrderString + "\"");
             FileUtil.writeStringToLocalFile(replace, absolutePath);
             // 创建 pod
-            createPod3(projectId, yamlPathCacheKey, cpuOrderString);
+            createPod(projectId, yamlPathCacheKey, cpuOrderString);
             log.info("创建项目 " + projectId + " 在节点 " + nodeName + " 的下一个 pod,使用 cpu 编号为 " + cpuOrderString);
         }
     }
@@ -174,14 +167,14 @@ public class ProjectUtil {
         String nodeName = new File(podYamlPath).getName().split("#")[0];
         String podName = podYamlPath.split("#")[1].split("\\.")[0];
         stringRedisTemplate.opsForValue().set("project:" + projectId + ":pod:" + podName + ":node", nodeName);    // 将 pod 运行在哪个 node 上记录到 redis
-        new Thread(() -> KubernetesUtil.applyYaml(hostname, username, password, podYamlPath), "apply-" + podName).start();
+        new Thread(() -> KubernetesUtil.applyYaml( podYamlPath), "apply-" + podName).start();
     }
 
 
     /**
      * @param redisKey yaml 地址的缓存 key
      */
-    public void createPod3(String projectId, String redisKey, String cpuOrderString) {
+    public void createPod(String projectId, String redisKey, String cpuOrderString) {
         final String podYamlPath = stringRedisTemplate.opsForValue().get(redisKey);
         if (podYamlPath == null) {
             throw new RuntimeException("根据缓存 key 获取 yaml 地址为 null:" + redisKey);
@@ -191,7 +184,7 @@ public class ProjectUtil {
         String podName = podYamlPath.split("#")[1].split("\\.")[0];
         stringRedisTemplate.opsForValue().set("project:" + projectId + ":pod:" + podName + ":node", nodeName);    // 将 pod 运行在哪个 node 上记录到 redis
         stringRedisTemplate.opsForValue().set("project:" + projectId + ":pod:" + podName + ":cpu", cpuOrderString);    // 将 pod 运行在哪个 node 上记录到 redis
-        new Thread(() -> KubernetesUtil.applyYaml(hostname, username, password, podYamlPath), "create-" + podName).start();
+        new Thread(() -> KubernetesUtil.applyYaml(podYamlPath), "create-" + podName).start();
     }
 
 
@@ -290,7 +283,7 @@ public class ProjectUtil {
                 restNodeList.add(kubernetesNodeCopy);
             }
         }
-        log.info("ProjectUtil--getRestParallelism 集群剩余并行度为:" + restNodeList);
+        log.info(" 集群剩余并行度为:" + restNodeList);
         return restNodeList.size() == 0 ? 0 : restNodeList.stream().mapToInt(GpuNodeEntity::getParallelism).sum();
     }