夜得朦胧 1 年之前
父节点
当前提交
5cf89e78c0

+ 3 - 0
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/adapter/entity/ProjectStartMessageEntity.java

@@ -24,6 +24,9 @@ public class ProjectStartMessageEntity {
     private String algorithmId;// 算法 id
     private String vehicleConfigId;// 车辆配置 id
     private String scenePackageId;// 场景包 id
+
+    private String simulationMageGroupId;// 仿真镜像组id
+
     private Integer maxSimulationTime;// 最大仿真时间(秒)
     private Integer parallelism = 1;// 期望并行度,页面上创建项目时指定的并行度
     private String modelType;// vtd carsim

+ 4 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/app/service/ProjectApplicationService.java

@@ -681,6 +681,9 @@ public class ProjectApplicationService {
         KafkaUtil.createTopic(kafkaAdminClient, projectId, finalParallelism, (short) 1);   // 创建主题
         TimeUnit.SECONDS.sleep(3);
         // 需要即时启动的任务(并行度的大小)
+        SimulationMageGroupPO groupPO = mageGroupMapper.selectSimulationMageGroupById(projectStartMessageEntity.getSimulationMageGroupId());
+        String connectorPath = groupPO.getConnectorPath();
+        String controllerPath = groupPO.getControllerPath();
         ArrayList<String> yamlToRunRedisKeyList = new ArrayList<>();
         for (String taskJsonPath : taskJsonList) {
             String taskId = FileUtil.getFilenameWithoutSuffix(taskJsonPath);
@@ -725,7 +728,7 @@ public class ProjectApplicationService {
             }
             // 只有准备启动(即 currentCount == 0)的时候才指定 cpu 编号
             log.info("创建任务 {} 的 yaml:是否使用 gpu (0是1否){},当前节点已创建 yaml 个数为:{},当前节点名称为:{},当前 cpu 编号为:{},镜像名:{}", taskId, isChoiceGpu, currentCount, currentNodeName, cpuOrder, algorithmDockerImage);
-            String yamlRedisKey = projectDomainService.createTempYaml(projectId, vehicleConfigId, modelType, algorithmDockerImage, currentNodeName, partition, offset, isChoiceGpu, cpuOrder);
+            String yamlRedisKey = projectDomainService.createTempYaml(projectId, vehicleConfigId, modelType, algorithmDockerImage, currentNodeName, partition, offset, isChoiceGpu, cpuOrder, connectorPath, controllerPath);
             if (currentCount == 0) {
                 yamlToRunRedisKeyList.add(yamlRedisKey);
             }

+ 11 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/domain/service/ProjectDomainService.java

@@ -114,7 +114,7 @@ public class ProjectDomainService {
      * 创建一个临时 yaml,node 在最后用 # 号隔开
      */
     @SneakyThrows
-    public String createTempYaml(String projectId, String vehicleConfigId, String modelType, String algorithmDockerImage, String nodeName, int kafkaPartition, long kafkaOffset, String isChoiceGpu, Integer cpuOrder) {
+    public String createTempYaml(String projectId, String vehicleConfigId, String modelType, String algorithmDockerImage, String nodeName, int kafkaPartition, long kafkaOffset, String isChoiceGpu, Integer cpuOrder, String connectorPath, String controllerPath) {
         String podName = getRandomPodName(projectId);   // 生成 podName
         String podYaml = getPodYamlName(nodeName, podName);     // 模板文件名称
         String yamlPath = podYamlDirectory + podYaml;
@@ -142,6 +142,11 @@ public class ProjectDomainService {
             String replace13 = replace12.replace("namespace-name", kubernetesConfiguration.getNamespace()); // pod 名称包括 projectId 和 随机字符串
             String replace14 = replace13.replace("node-name", nodeName);     // 指定 pod 运行节点
 
+            replace14 = replace14.replace("controller-container", "controller-" + projectId);
+            replace14 = replace14.replace("controller-image", controllerPath);
+            replace14 = replace14.replace("connector-container", "connector-" + projectId);
+            replace14 = replace14.replace("connector-image", connectorPath);
+
             String replace15;
             if (cpuOrder != null) {
                 replace15 = replace14.replace("cpu-order", "\"" + cpuOrder + "\"");     // 指定 cpu 编号
@@ -186,6 +191,11 @@ public class ProjectDomainService {
             String replace17 = replace16.replace("namespace-name", kubernetesConfiguration.getNamespace()); // pod 名称包括 projectId 和 随机字符串
             String replace18 = replace17.replace("node-name", nodeName);     // 指定 pod 运行节点
 
+            replace18 = replace18.replace("controller-container", "controller-" + projectId);
+            replace18 = replace18.replace("controller-image", controllerPath);
+            replace18 = replace18.replace("connector-container", "connector-" + projectId);
+            replace18 = replace18.replace("connector-image", connectorPath);
+
             String replace19;
             if (cpuOrder != null) {
                 replace19 = replace18.replace("cpu-order", "\"" + cpuOrder + "\"");     // 指定 cpu 编号