소스 검색

传 partition 和 offset

root 2 년 전
부모
커밋
ce825a24de

+ 5 - 5
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/manager/TaskManager.java

@@ -1,6 +1,5 @@
 package com.css.simulation.resource.scheduler.manager;
 
-import api.common.pojo.common.ResponseBodyVO;
 import api.common.pojo.constants.DictConstants;
 import api.common.pojo.dto.ProjectMessageDTO;
 import api.common.util.*;
@@ -35,7 +34,6 @@ import org.springframework.transaction.annotation.Transactional;
 import javax.annotation.Resource;
 import java.io.IOException;
 import java.util.*;
-import java.util.concurrent.FutureTask;
 import java.util.concurrent.atomic.AtomicReference;
 import java.util.stream.Collectors;
 
@@ -134,9 +132,9 @@ public class TaskManager {
                     taskMapper.updateFailStateWithStopTime(taskId, state, TimeUtil.getNowForMysql(), DictConstants.TASK_ERROR_REASON_3);
                 } else if ("PendingAnalysis".equals(state)) {
                     taskMapper.updateSuccessStateWithStopTime(taskId, state, TimeUtil.getNowForMysql());
-                    // 多线程创建视频和生成
-                    FutureTask<ResponseBodyVO<String>> videoTask = new FutureTask<>(() -> videoService.generateVideo(projectId, projectType, maxSimulationTime, taskId));
-                    new Thread(videoTask, "video-" + StringUtil.getRandomEightBitUUID()).start();
+//                    // 多线程创建视频和生成
+//                    FutureTask<ResponseBodyVO<String>> videoTask = new FutureTask<>(() -> videoService.generateVideo(projectId, projectType, maxSimulationTime, taskId));
+//                    new Thread(videoTask, "video-" + StringUtil.getRandomEightBitUUID()).start();
                 }
                 // -------------------------------- 判断项目是否结束 --------------------------------
                 ProjectMessageDTO projectMessageDTO = JsonUtil.jsonToBean(stringRedisTemplate.opsForValue().get(redisPrefix.getProjectRunningKey()), ProjectMessageDTO.class);
@@ -489,6 +487,8 @@ public class TaskManager {
             log.info("TaskManager--done 自动运行子项目 " + projectId + " 执行完成!");
         }
 
+        // 删除剩余 yaml
+        projectUtil.deleteYamlByProjectId(projectId);
 
     }
 

+ 7 - 9
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/util/ProjectUtil.java

@@ -62,17 +62,16 @@ public class ProjectUtil {
     ApiClient apiClient;
 
     @SneakyThrows
-    public void deleteYamlByProjectId(String projectId){
+    public void deleteYamlByProjectId(String projectId) {
         List<String> absolutePathList = FileUtil.listAbsolutePath(podYamlDirectory);
         for (String absolutePath : absolutePathList) {
-            if(absolutePath.contains(projectId)){
+            if (absolutePath.contains(projectId)) {
                 boolean delete = new File(absolutePath).delete();
             }
         }
     }
 
 
-
     public List<NodeTO> getNodeListToCount(Map<String, Integer> nodeMap) {
         List<NodeTO> result = new ArrayList<>();
         nodeMap.forEach((nodeName, parallelism) -> {
@@ -169,7 +168,7 @@ public class ProjectUtil {
         deletePod(lastPodName);
         List<String> list = FileUtil.listAbsolutePath(podYamlDirectory);
         Iterator<String> iterator1 = list.iterator();
-        while (iterator1.hasNext()){
+        while (iterator1.hasNext()) {
             String absolutePath = iterator1.next();
             if (absolutePath.contains(nodeName) && absolutePath.contains(lastPodName)) {
                 FileUtil.rm(absolutePath);
@@ -179,7 +178,7 @@ public class ProjectUtil {
         }
         for (String absolutePath : list) {
             if (absolutePath.contains(nodeName) && absolutePath.contains(projectId)) {
-                createPod2(projectId, absolutePath);
+                createPod2(nodeName, absolutePath);
                 log.info("ProjectUtil--createNextPod 创建项目 " + projectId + " 的下一个 pod。");
                 return;
             }
@@ -208,11 +207,11 @@ public class ProjectUtil {
     }
 
     /**
-     * @param nodeName       节点名称
+     * @param nodeName    节点名称
      * @param podYamlPath pod 文件内容
      */
     @SneakyThrows
-    public void createPod2(String nodeName,  String podYamlPath) {
+    public void createPod2(String nodeName, String podYamlPath) {
         String podName = podYamlPath.split("#")[1].split("\\.")[0];
         stringRedisTemplate.opsForValue().set("pod:" + podName + ":node", nodeName);    // 将 pod 运行在哪个 node 上记录到 redis
         KubernetesUtil.createNs(apiClient, kubernetesConfiguration.getNamespace());
@@ -220,7 +219,6 @@ public class ProjectUtil {
     }
 
 
-
     public String getProjectTypeByProjectId(String projectId) {
         String projectType = null;
         ProjectPO manualProjectPO = manualProjectMapper.selectById(projectId);
@@ -559,7 +557,7 @@ public class ProjectUtil {
     public void addOneParallelismToNode(String nodeName) {
         String key = "node:" + nodeName + ":parallelism";
         String parallelismString = stringRedisTemplate.opsForValue().get(key);
-        if(StringUtil.isEmpty(parallelismString)){
+        if (StringUtil.isEmpty(parallelismString)) {
             throw new RuntimeException("ProjectUtil--addOneParallelismToNode redisKey " + key + " 为空。");
         }
         int parallelism = Integer.parseInt(parallelismString);

+ 12 - 3
simulation-resource-video/src/main/java/com/css/simulation/resource/video/service/VideoService.java

@@ -167,7 +167,12 @@ public class VideoService {
                                     Attribute vehicleCategory = node3.attribute("vehicleCategory");
                                     vehicleCategory.setText(po.getVehicleCategory());
                                     //node3.addAttribute("model3d", po.getModel3d());//自车渲染
-                                    node3.addAttribute("model3d", "/root/disk1/simulation-cloud/esmini/resources/models/car_red.osgb");//自车渲染
+                                    if(po.getModel3d().equals("")||po.getModel3d()==null){
+                                        node3.addAttribute("model3d", "/root/disk1/simulation-cloud/esmini/resources/models/car_red.osgb");//自车渲染
+                                    }else{
+                                        log.info(" 车辆类型为 为:"+po.getVehicleCategory()+" 渲染文件为:" + po.getModel3d());
+                                        node3.addAttribute("model3d",po.getModel3d());
+                                    }
                                     Iterator<Element> iterator4 = node3.elementIterator();
                                     while (iterator4.hasNext()) {
                                         Element node4 = iterator4.next();
@@ -254,7 +259,7 @@ public class VideoService {
                     }
                     if ("SceneGraphFile".equals(node2.getName())) {
                         Attribute name = node2.attribute("filepath");
-//                        name.setText(osgbPath);
+                        // name.setText(osgbPath);
                         name.setText("osgbPath");
                     }
                 }
@@ -309,8 +314,12 @@ public class VideoService {
             po.setVehicleCategory("bicycle");
         } else if (car.contains("train")) {
             po.setVehicleCategory("train");
-        } else {
+        } else if(car.contains("suv")) {
+            po.setVehicleCategory("suv");
+            po.setModel3d("/root/disk1/simulation-cloud/esmini/resources/models/audiq5.osgb");
+        }else {
             po.setVehicleCategory("car");
+            po.setModel3d("/root/disk1/simulation-cloud/esmini/resources/models/audia8.osgb");
         }
 
         //车前距