Quellcode durchsuchen

将项目运行节点拆分成GPU节点和CPU节点

LingxinMeng vor 2 Jahren
Ursprung
Commit
a7f2552a57

+ 0 - 15
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/configuration/esmini/EsminiConfiguration.java

@@ -1,15 +0,0 @@
-package com.css.simulation.resource.scheduler.configuration.esmini;
-
-import com.css.simulation.resource.scheduler.data.entity.CpuNodeEntity;
-import lombok.Data;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.List;
-
-@Data
-@Configuration
-@ConfigurationProperties(prefix = "esmini")
-public class EsminiConfiguration {
-    private List<CpuNodeEntity> nodeList;
-}

+ 1 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/service/FileService.java

@@ -24,7 +24,7 @@ public class FileService {
     public void uploadOsgb(MultipartFile file) {
         final String targetFilePath = constantConfiguration.getTemporaryDirectory() + "/esmini-osgb";
         FileUtil.writeInputStreamToLocalFile(file.getInputStream(), targetFilePath);
-        final List<NodeModel> nodeModels = kubernetesConfiguration.getCpuList();
+        final List<NodeModel> nodeModels = kubernetesConfiguration.getCpuNodeList();
         nodeModels.forEach(nodeModel -> HttpUtil.post(constantConfiguration.getUploadOsgbUrl().replace("simulation-resource-video", nodeModel.getIp()), new File(targetFilePath)));
     }
 }

+ 15 - 16
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/service/ProjectService.java

@@ -1,7 +1,6 @@
 package com.css.simulation.resource.scheduler.service;
 
 import api.common.pojo.constants.DictConstants;
-import api.common.pojo.dto.ProjectMessageDTO;
 import api.common.pojo.po.scheduler.SchedulerProjectPO;
 import api.common.util.*;
 import com.css.simulation.resource.scheduler.configuration.docker.DockerConfiguration;
@@ -97,19 +96,19 @@ public class ProjectService {
 
     // -------------------------------- Comment --------------------------------
 
-    /**
-     * @param projectMessageDTO 初始接收到的项目启动信息
-     * @param projectWaitingKey projectWaitingKey
-     * @param projectRunningKey projectRunningKey
-     */
-    @Transactional
-    public void prepare(ProjectMessageDTO projectMessageDTO, String projectWaitingKey, String projectRunningKey) {
-        String projectId = projectMessageDTO.getProjectId();
-
-        //2 将 redis 中该项目旧的信息则直接删除(包括 waitingKey)
-        RedisUtil.deleteByPrefix(stringRedisTemplate, projectWaitingKey);
-        RedisUtil.deleteByPrefix(stringRedisTemplate, projectRunningKey);
-    }
+//    /**
+//     * @param projectMessageDTO 初始接收到的项目启动信息
+//     * @param projectWaitingKey projectWaitingKey
+//     * @param projectRunningKey projectRunningKey
+//     */
+//    @Transactional
+//    public void prepare(ProjectMessageDTO projectMessageDTO, String projectWaitingKey, String projectRunningKey) {
+//        String projectId = projectMessageDTO.getProjectId();
+//
+//        //2 将 redis 中该项目旧的信息则直接删除(包括 waitingKey)
+//        RedisUtil.deleteByPrefix(stringRedisTemplate, projectWaitingKey);
+//        RedisUtil.deleteByPrefix(stringRedisTemplate, projectRunningKey);
+//    }
 
     @SneakyThrows
     @Transactional
@@ -123,7 +122,7 @@ public class ProjectService {
         stringRedisTemplate.opsForValue().set(allIndexPrefix, JsonUtil.listToJson(allIndexList));
         //2 查询场景包叶子指标
         List<IndexTemplateEntity> leafIndexList = allIndexList.stream().filter(index -> StringUtil.isNotEmpty(index.getRuleId())).collect(Collectors.toList());
-        log.info("getSceneList() 项目 " + projectId + " 的叶子指标为:" + leafIndexList);
+        log.debug("项目 " + projectId + " 的叶子指标为:" + leafIndexList);
 //        FileUtil.writeStringToLocalFile(JsonUtil.listToJson(allIndexList), projectPath + "leaf-index-list.json");
         stringRedisTemplate.opsForValue().set(leafIndexPrefix, JsonUtil.listToJson(leafIndexList));
         List<SceneEntity> sceneList = new ArrayList<>();
@@ -149,7 +148,7 @@ public class ProjectService {
                 sceneList.addAll(sceneMapper.selectGeneralizationByIdList(generalizationIdList));
             }
         });
-        log.info("getSceneList() 项目" + projectId + " 共有 " + sceneList.size() + " 个任务:" + sceneList);
+        log.info("项目" + projectId + " 共有 " + sceneList.size() + " 个任务:" + sceneList);
         return sceneList;
     }
 

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

@@ -3,7 +3,6 @@ package com.css.simulation.resource.scheduler.util;
 import api.common.pojo.constants.DictConstants;
 import api.common.pojo.dto.ProjectMessageDTO;
 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.data.entity.NodeEntity;
@@ -49,8 +48,6 @@ public class ProjectUtil {
     @Resource
     private ClusterMapper clusterMapper;
     @Resource
-    private EsminiConfiguration esminiConfiguration;
-    @Resource
     private KubernetesConfiguration kubernetesConfiguration;
     @Resource
     private ApiClient apiClient;
@@ -588,8 +585,14 @@ public class ProjectUtil {
     }
 
     public void resetNodeParallelism() {
-        kubernetesConfiguration.getGpuNodeList().forEach((node) -> customRedisClient.set("gpu-node:" + node.getHostname() + ":parallelism", String.valueOf(node.getParallelism())));
-        kubernetesConfiguration.getCpuNodeList().forEach((node) -> customRedisClient.set("cpu-node:" + node.getHostname() + ":parallelism", String.valueOf(node.getParallelism())));
+        //* -------------------------------- GPU节点 --------------------------------
+        final List<NodeModel> gpuNodeList = kubernetesConfiguration.getGpuNodeList();
+        log.info("GPU 节点:" + gpuNodeList);
+        gpuNodeList.forEach((node) -> customRedisClient.set("gpu-node:" + node.getHostname() + ":parallelism", String.valueOf(node.getParallelism())));
+        //* -------------------------------- CPU节点 --------------------------------
+        final List<NodeModel> cpuNodeList = kubernetesConfiguration.getCpuNodeList();
+        log.info("CPU 节点:" + cpuNodeList);
+        cpuNodeList.forEach((node) -> customRedisClient.set("cpu-node:" + node.getHostname() + ":parallelism", String.valueOf(node.getParallelism())));
     }
 
     /**

+ 1 - 4
simulation-resource-scheduler/src/main/resources/logback-spring.xml

@@ -7,10 +7,7 @@
     <springProfile name="private">
         <property name="LOG_HOME" value="./log"/>
     </springProfile>
-    <springProfile name="aliyun">
-        <property name="LOG_HOME" value="./log"/>
-    </springProfile>
-    <springProfile name="test">
+    <springProfile name="private2">
         <property name="LOG_HOME" value="./log"/>
     </springProfile>