martin 3 سال پیش
والد
کامیت
04fc0c7401

+ 1 - 1
api-common/src/main/java/api/common/util/FileUtil.java

@@ -329,7 +329,7 @@ public class FileUtil {
 
 
         }
-        if (".tar.gz".equals(fileType)|| ".tgz".equals(fileType)) {
+        if (".tar.gz".equals(fileType)|| ".tgz".equals(fileType)|| ".gz".equals(fileType)) {
             TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream((new GzipCompressorInputStream(inputStream)));
             TarArchiveEntry entry;
             // 将 tar 文件解压到 extractPath 目录下

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

@@ -20,7 +20,7 @@ public class TaskManager {
 
         try (SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false)) {
             TaskMapper taskMapper = sqlSession.getMapper(TaskMapper.class);
-            taskMapper.updateFailStateWithStopTime(taskId, runState, runStopTime);
+            taskMapper.updateFailStateWithStopTime(taskId, runState, runStopTime,DictConstants.TASK_ERROR_REASON_2);
             taskMapper.updateProjectStateByTaskId(DictConstants.PROJECT_TERMINATED, taskId);
             sqlSession.commit();
         }

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

@@ -102,7 +102,7 @@ public class TickScheduler {
                 String key = manualProjectTopic + ":" + projectId + ":check";
                 String lastNowString = redisTemplate.opsForValue().get(manualProjectTopic + ":" + projectId + ":check");
                 String podList = SshUtil.execute(session, "kubectl get pod | grep project-" + projectId);
-                log.info("TickScheduler-------checkProject 项目 " + projectId + " 正在运行的 pod 为" + podList);
+                log.info("TickScheduler-------checkProject 项目 " + projectId + " 正在运行的 pod 为:\n" + podList);
                 int taskNumber = StringUtil.countSubString(podList, "project");
                 if (StringUtil.isEmpty(lastNowString) && taskNumber == 0) {
                     redisTemplate.opsForValue().set(key, TimeUtil.getNowString());
@@ -121,7 +121,7 @@ public class TickScheduler {
                         while (true) {
                             log.info("TickScheduler-------checkProject 准备重启项目 " + projectId);
                             String podList2 = SshUtil.execute(session, "kubectl get pod | grep project-" + projectId);
-                            log.info("TickScheduler-------checkProject 项目 " + projectId + " 剩余的 pod 信息为:" + podList2);
+                            log.info("TickScheduler-------checkProject 项目 " + projectId + " 剩余的 pod 信息为:\n" + podList2);
                             int taskNumber2 = StringUtil.countSubString(podList2, "project");
                             if (taskNumber2 == 0) {
                                 break;

+ 7 - 4
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/service/AlgorithmService.java

@@ -28,12 +28,15 @@ public class AlgorithmService {
     @SneakyThrows
     public ResponseBodyVO<String> check(String minioPath) {
 
+        String[] split = minioPath.split("\\.");
+        int length = split.length;
+        String s = split[length - 1];
 
         //1 根据 minio 路径获取输入流
         InputStream inputStream = MinioUtil.downloadToStream(minioClient, bucketName, minioPath);
         //2 将输入流解压到临时目录
-        String algorithmTarLinuxTempPath = linuxTempPath +  minioPath;
-        Set<String> pathList = FileUtil.decompress(inputStream, algorithmTarLinuxTempPath, ".tgz");
+        String algorithmTarLinuxTempPath = linuxTempPath + minioPath;
+        Set<String> pathList = FileUtil.decompress(inputStream, algorithmTarLinuxTempPath, "." + s);
         //3 获取文件列表中是否又 docker-entrypoint.sh
         boolean result = false;
         for (String path : pathList) {
@@ -45,9 +48,9 @@ public class AlgorithmService {
 
         FileUtil.rm(algorithmTarLinuxTempPath);
         if (result) {
-            return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS);
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.SUCCESS, "算法可用!", null);
         } else {
-            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE);
+            return new ResponseBodyVO<>(ResponseBodyVO.Response.CLIENT_FAILURE, "算法不可用!", null);
         }
 
     }

+ 7 - 4
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/util/MinioUtil.java

@@ -24,11 +24,14 @@ public class MinioUtil {
     /**
      * 判断 object 是否存在
      */
-    public static boolean isObjectExist(MinioClient minioClient, String bucket, String object) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, io.minio.errors.InternalException {
-        StatObjectResponse objectStat = minioClient.statObject(StatObjectArgs.builder().bucket(bucket).object(object).build());
-        return objectStat != null;
+    public static boolean isObjectExist(MinioClient minioClient, String bucket, String object) {
+        try {
+            StatObjectResponse objectStat = minioClient.statObject(StatObjectArgs.builder().bucket(bucket).object(object).build());
+            return objectStat != null;
+        } catch (Exception e) {
+            return false;
+        }
     }
-
     /**
      * 创建 bucket
      */