LingxinMeng 1 년 전
부모
커밋
0556a6cacb

+ 2 - 2
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/adapter/consumer/ProjectConsumer.java

@@ -25,7 +25,7 @@ public class ProjectConsumer {
      */
     @KafkaListener(groupId = "simulation-resource-scheduler", topics = "${custom.mq-start-project-topic}")
     public void acceptMessage(ConsumerRecord<String, String> projectStartMessageRecord) {
-        log.info("消费者组 simulation-resource-scheduler 接收到项目开始消息:" + projectStartMessageRecord);
+        log.info("消费者组 simulation-resource-scheduler 接收到项目开始消息:{}", projectStartMessageRecord);
         projectApplicationService.runProject(JsonUtil.jsonToBean(projectStartMessageRecord.value(), ProjectStartMessageEntity.class));
     }
 
@@ -35,7 +35,7 @@ public class ProjectConsumer {
      */
     @KafkaListener(groupId = "simulation-resource-scheduler", topics = "${custom.mq-stop-project-topic}")
     public void stopProject(ConsumerRecord<String, String> projectStopMessageRecord) {
-        log.info("消费者组 simulation-resource-scheduler 接收到的项目终止消息:" + projectStopMessageRecord);
+        log.info("消费者组 simulation-resource-scheduler 接收到的项目终止消息:{}", projectStopMessageRecord);
         try {
             TimeUnit.SECONDS.sleep(10);
             projectApplicationService.stopProject(JsonUtil.jsonToBean(projectStopMessageRecord.value(), ProjectStopMessageEntity.class));

+ 5 - 5
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/app/service/TaskApplicationService.java

@@ -66,7 +66,7 @@ public class TaskApplicationService {
     public void state(String taskId, String state, String podName) {
         TaskEntity taskEntity = simulationManualProjectTaskMapper.selectById(taskId);
         if (taskEntity == null) {
-            log.info("收到不存在的任务的状态消息:" + taskId);
+            log.info("收到不存在的任务的状态消息:{}", taskId);
             return;
         }
         String projectId = taskEntity.getPId(); // 项目 id
@@ -87,7 +87,7 @@ public class TaskApplicationService {
             if (DictConstants.TASK_RUNNING.equals(state)) {  // 运行中的 pod 无需删除
                 // 将运行中的任务的 pod 名称放入 redis
                 stringRedisTemplate.opsForValue().set(redisPrefix.getTaskPodKey(), podName);
-                log.info("修改任务 " + taskId + " 的状态为 " + state + ",pod 名称为:" + podName);
+                log.info("修改任务 {} 的状态为 {},pod 名称为:{}", taskId, state, podName);
                 simulationManualProjectTaskMapper.updateStateWithStartTime(taskId, state, TimeUtil.getNowForMysql());
                 return;
             } else { // 结束的 pod 都直接删除,并判断项目是否完成
@@ -141,13 +141,13 @@ public class TaskApplicationService {
                 // -------------------------------- 判断项目是否结束 --------------------------------
                 isCompleted = projectDomainService.complete(redisPrefix, projectId);
                 if (isCompleted) {
-                    log.info("项目 " + projectId + " 已完成。");
+                    log.info("项目 {} 已完成。", projectId);
                     //如果项目已完成先把 pod 删除,并归还并行度
                     KubernetesUtil.deletePod2(apiClient, kubernetesConfiguration.getNamespace(), podName);
                     projectDomainService.incrementOneParallelism(isChoiceGpu, nodeName);
                     projectDomainService.releaseLicense(projectDomainService.getClusterUserIdByProjectUserId(projectUserId), projectDomainService.getModelTypeByProjectIdAndProjectType(projectId, projectType), 1);
                 } else {
-                    log.info("项目 " + projectId + " 还未运行完成。");
+                    log.info("项目 {} 还未运行完成。", projectId);
                     projectDomainService.createNextPod(projectUserId, projectId, projectType, nodeName, podName);
                 }
                 RedisUtil.deleteByPrefix(stringRedisTemplate, redisPrefix.getTaskMessageKey());
@@ -170,7 +170,7 @@ public class TaskApplicationService {
                 customRedisClient.unlock(lock2);
             }
         } catch (io.kubernetes.client.openapi.ApiException apiException) {
-            log.info("POD:" + podName + "已删除。");
+            log.info("POD:{}已删除。", podName);
         } catch (Exception e) {
             log.error("项目 {} 已结束。", projectId, e);
         } finally {

+ 3 - 4
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/domain/service/ProjectDomainService.java

@@ -245,13 +245,12 @@ public class ProjectDomainService {
         try {
             // 先删除 redis key
             KubernetesUtil.deletePod(apiClient, kubernetesConfiguration.getNamespace(), podName);
-            log.info("等待 pod " + podName + " 的资源释放完成。");
+            log.info("等待 pod {} 的资源释放完成。", podName);
             TimeUnit.SECONDS.sleep(3);
         } catch (ApiException apiException) {
-            log.info("pod " + podName + " 已删除。");
+            log.info("pod {} 已删除。", podName);
         } catch (Exception e) {
-            e.printStackTrace();
-            log.error("删除 pod " + podName + " 报错。", e);
+            log.error("删除 pod {} 报错。", podName, e);
         }
     }
 

+ 4 - 4
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/domain/service/TaskDomainService.java

@@ -322,18 +322,18 @@ public class TaskDomainService {
     @SneakyThrows
     public void evaluationLevel(String projectId) {
         String tokenUrl = customConfiguration.getTokenUri() + "?grant_type=client_credentials" + "&client_id=" + customConfiguration.getClientId() + "&client_secret=" + customConfiguration.getClientSecret();
-        log.debug("获取仿真云平台 token:" + tokenUrl);
+        log.debug("获取仿真云平台 token:{}", tokenUrl);
         String response = HttpUtil.get(tokenUrl);
         ObjectMapper objectMapper = new ObjectMapper();
         JsonNode jsonNode = objectMapper.readTree(response);
         String accessToken = jsonNode.path("access_token").asText();
-        log.debug("仿真云平台 token 为:" + accessToken);
+        log.debug("仿真云平台 token 为:{}", accessToken);
         Map<String, String> headers = new HashMap<>();
         headers.put("Authorization", "Bearer " + accessToken);
         Map<String, String> params = new HashMap<>();
         params.put("id", projectId);
         String post = HttpUtil.post(customConfiguration.getEvaluationLevelUri(), headers, params);
-        log.info("访问仿真云平台评价等级接口:" + customConfiguration.getEvaluationLevelUri() + ",请求头为:" + headers + ",请求体为:" + params + "结果为:" + post);
+        log.info("访问仿真云平台评价等级接口:{},请求头为:{},请求体为:{}结果为:{}", customConfiguration.getEvaluationLevelUri(), headers, params, post);
     }
 
     public Boolean taskConfirm(String taskId) {
@@ -342,7 +342,7 @@ public class TaskDomainService {
     }
 
     public void taskTick(String taskId) {
-        log.debug("收到任务 " + taskId + " 的心跳。");
+        log.debug("收到任务 {} 的心跳。", taskId);
         TaskEntity taskEntity = simulationManualProjectTaskMapper.selectById(taskId);
         if (taskEntity == null) {
             return;