martin 3 年 前
コミット
52471449b7

+ 4 - 3
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/configuration/kubernetes/KubernetesConfiguration.java

@@ -5,6 +5,7 @@ import io.kubernetes.client.util.ClientBuilder;
 import io.kubernetes.client.util.KubeConfig;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
+import org.springframework.util.ResourceUtils;
 
 import java.io.File;
 import java.io.FileReader;
@@ -15,12 +16,12 @@ public class KubernetesConfiguration {
 
     @Bean
     public ApiClient apiClient() throws IOException {
-//        File config = ResourceUtils.getFile("classpath:kubernetes/config");  // 开发环境可用,生产环境不行,无法从jar 包读取
+        File config = ResourceUtils.getFile("classpath:kubernetes/config");  // 开发环境可用,生产环境不行,无法从jar 包读取
 //        File config = new File("D:\\idea-project\\simulation-cloud\\simulation-resource-scheduler\\src\\main\\resources\\kubernetes\\config");  //windows
-        File config = new File("/root/.kube/config");   //linux
+//        File config = new File("/root/.kube/config");   //linux
 //
 //        ClassPathResource classPathResource = new ClassPathResource("kubernetes/config");
-//        InputStream inputStream =classPathResource.getInputStream();
+//        InputStream inputStream = classPathResource.getInputStream();
 //        FileUtil.writeInputStreamToLocalFile();
         FileReader fileReader = new FileReader(config);
         return ClientBuilder.kubeconfig(KubeConfig.loadKubeConfig(fileReader)).build();

ファイルの差分が大きいため隠しています
+ 34 - 22
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/consumer/ManualProjectConsumer.java


+ 15 - 2
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/controller/TaskController.java

@@ -1,7 +1,9 @@
 package com.css.simulation.resource.scheduler.controller;
 
 
+import api.common.pojo.dto.ProjectMessageDTO;
 import api.common.util.IoUtil;
+import com.css.simulation.resource.scheduler.consumer.ManualProjectConsumer;
 import com.css.simulation.resource.scheduler.service.TaskService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -18,9 +20,11 @@ import java.io.IOException;
 public class TaskController {
 
     @Autowired
-    private TaskService taskService;
+    TaskService taskService;
     @Value("${hello}")
-    private String hello;
+    String hello;
+    @Autowired
+    ManualProjectConsumer manualProjectConsumer;
 
     @RequestMapping("/hello")
     public String hello() {
@@ -36,6 +40,15 @@ public class TaskController {
         IoUtil.copyBytes(inputStream, response.getOutputStream(), 4096);
     }
 
+
+    /**
+     * Pod 的心跳接口
+     */
+    @PostMapping("/test")
+    public void test(@RequestBody ProjectMessageDTO projectMessageDTO) {
+        manualProjectConsumer.parseProject1(projectMessageDTO);
+    }
+
     /**
      * Pod 的心跳接口
      */

+ 2 - 2
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/mapper/TaskMapper.java

@@ -20,7 +20,7 @@ public interface TaskMapper {
             @Result(column = "scene_name", property = "sceneName", jdbcType = JdbcType.VARCHAR),
             @Result(column = "scene_type", property = "sceneType", jdbcType = JdbcType.VARCHAR),
             @Result(column = "run_state", property = "runState", jdbcType = JdbcType.VARCHAR),
-            @Result(column = "run_result", property = "runResult", jdbcType = JdbcType.VARCHAR),
+            @Result(column = "run_result_file_path", property = "runResultFilePath", jdbcType = JdbcType.VARCHAR),
             @Result(column = "max_simulation_time", property = "maxSimulationTime", jdbcType = JdbcType.VARCHAR),
     })
     @Select("select id,\n" +
@@ -29,7 +29,7 @@ public interface TaskMapper {
             "       scene_name,\n" +
             "       scene_type,\n" +
             "       run_state,\n" +
-            "       run_result\n" +
+            "       run_result_file_path\n" +
             "from simulation_manual_project_task\n" +
             "where p_id = #{projectId}")
     List<TaskPO> selectTaskListByProjectId(@Param("projectId") String projectId);

+ 1 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/pojo/po/TaskPO.java

@@ -15,7 +15,7 @@ public class TaskPO extends CommonPO {
     private String sceneName;
     private String sceneType;
     private String runState;
-    private String runResult;
+    private String runResultFilePath;
     private String returnSceneId;
     private Double score;
     private String targetEvaluate;

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

@@ -92,7 +92,7 @@ public class TaskService {
 
     @SneakyThrows
     public void taskState(String taskId, String state, String podName) {
-        log.info("------- /state 修改任务 " + taskId + "的状态:" + state);
+        log.info("------- /state 修改任务 " + taskId + "的状态:" + state + ",pod 名称为:" + podName);
         taskMapper.updateState(taskId, state);
         if ("Aborted".equals(state)
                 || "PendingAnalysis".equals(state)

この差分においてかなりの量のファイルが変更されているため、一部のファイルを表示していません