zishang 2 月之前
父节点
当前提交
905e021e35

+ 12 - 12
src/main/java/io/renren/dds/TestPublisher.java

@@ -39,18 +39,18 @@ public class TestPublisher {
     private final ExecutorService executor = Executors.newSingleThreadExecutor();
     private volatile boolean running = true;
     public TestPublisher() throws Exception {
-        String[] s = new String[6];
-//        String[] s = new String[4];
-        s[0] = "-DCPSBit";               // 启用Bit通信(保持原有配置)
-        s[1] = "0";                      // Bit值
-        s[2] = "-DCPSDefaultDiscovery";  // 指定发现机制为InfoRepo
-//        s[0] = "-DCPSBit";
-//        s[1] = "0";
-//        s[2] = "-DCPSConfigFile";
-//        s[3] = "C:/software/OpenDDS-3.16/java/tests/messenger/tcp.ini";
-        s[3] = "DEFAULT_REPO";           // 使用集中式InfoRepo
-        s[4] = "-DCPSInfoRepo";          // InfoRepo的corbaloc地址
-        s[5] = "corbaloc:iiop:192.168.5.22:12345/DCPSInfoRepo"; // 替换为实际IP和端口
+//        String[] s = new String[6];
+        String[] s = new String[4];
+//        s[0] = "-DCPSBit";               // 启用Bit通信(保持原有配置)
+//        s[1] = "0";                      // Bit值
+//        s[2] = "-DCPSDefaultDiscovery";  // 指定发现机制为InfoRepo
+        s[0] = "-DCPSBit";
+        s[1] = "0";
+        s[2] = "-DCPSConfigFile";
+        s[3] = "C:/software/OpenDDS-3.16/java/tests/messenger/tcp.ini";
+//        s[3] = "DEFAULT_REPO";           // 使用集中式InfoRepo
+//        s[4] = "-DCPSInfoRepo";          // InfoRepo的corbaloc地址
+//        s[5] = "corbaloc:iiop:192.168.5.22:12345/DCPSInfoRepo"; // 替换为实际IP和端口
         executor.submit(() -> initialize(s)); // 初始化放在后台线程
     }
     public static boolean checkReliable(String[] args) {

+ 14 - 8
src/main/java/io/renren/modules/sys/controller/algs/algTrainController.java

@@ -142,12 +142,17 @@ public class algTrainController {
         algTrain.setRemark(map.get("remark"));
         algTrain.setUid(Long.parseLong(map.get("uid")));
         algTrain.setAlgorithmId(Long.parseLong(map.get("algorithmId")));
+        algTrain.setPlatformId(Long.parseLong(map.get("platformId")));
         ValidatorUtils.validateEntity(algTrain, AddGroup.class);
 
-        if (algTrainService.selectByMissName(algTrain.getMissName()) != null) {
-            return R.error("已经存在重复名称的任务");
+//        if (algTrainService.selectByMissName(algTrain.getMissName()) != null) {
+//            return R.error("已经存在重复名称的任务");
+//        }
+        if (algTrainService.selectByMissNameAndPlatformId(algTrain.getPlatformId(), algTrain.getMissName()) != null) {
+            return R.error("已经存在相同平台和名称的任务");
         }
 
+
         // List<AlgTrain> list = algTrainService.list();
         // for(AlgTrain train : list){
         //     if(train.getMissName().equals(algTrain.getMissName())) return R.error("已经存在重复名称的任务");
@@ -164,7 +169,7 @@ public class algTrainController {
 
             algTrainService.save(algTrain);
             //重新获取,目的是获取algTrainId
-            algTrain=algTrainService.selectByMissName(map.get("missName"));
+//            algTrain=algTrainService.selectByMissName(map.get("missName"));
 
             //在服务器中创建存放算法文件的文件夹
             FTPUtils.mkdir("algTrain"+algTrain.getAlgorithmTrainingId());
@@ -216,15 +221,16 @@ public class algTrainController {
                 isPortUsing=PortUtils.isPortUsing(host,portInt);
             }
         }*/
+        AlgTrain algTrain1 = algTrainService.getById(algTrain.getAlgorithmTrainingId());
         //获取该算法在被创建时所选的算法框架
         String baseImageName=baseImageService.getById(alg.getFrameId()).getBaseImageName();
         String containerId=DockerClientUtils.createContainer("algTrain"+algTrain.getAlgorithmTrainingId(),String.valueOf(portInt),memoryByte,baseImageName,"1");
 
         //保存该训练任务所在容器id
-        algTrain.setContainerId(containerId);
+        algTrain1.setContainerId(containerId);
         //保存该容器对外暴露的tensorboard端口
-        algTrain.setIpAddress("http://"+remoteDocker+":"+portInt);
-        algTrainService.update(algTrain);
+        algTrain1.setIpAddress("http://"+remoteDocker+":"+portInt);
+        algTrainService.update(algTrain1);
         return R.ok();
 
 
@@ -318,7 +324,7 @@ public class algTrainController {
     @Async
     @Scheduled(fixedRate = 6000)//每6秒执行一次,获取消息
     public void checkAlgRequest() throws DockerException, InvalidBucketNameException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InterruptedException, InvalidResponseException, XmlParserException, InternalException, RegionConflictException {
-        if (subscriber.listener != null && subscriber.listener.isRequest == 0) {
+        if (subscriber.listener != null && subscriber.listener.isRequest == 0 ) {
             publisher.publishMessage(
                     "4",
                     "111",
@@ -356,7 +362,7 @@ public class algTrainController {
             for(Map.Entry<String, String> map : subscriber.listener.algMap.entrySet()){
                 String key = map.getKey();
                 String missName = map.getValue();
-                AlgTrain algTrain = algTrainService.selectByMissName(missName);
+                AlgTrain algTrain = algTrainService.selectByMissNameAndPlatformId(Long.valueOf(key), missName);
                 if (algTrain == null) {
                     continue;
                 }

+ 1 - 1
src/main/java/io/renren/modules/sys/controller/algs/algsController.java

@@ -226,7 +226,7 @@ public class algsController{
                 List<FileTest> algModelFiles=MinIoUtils.listFiles("algmodel","model"+algModelId);
                 for(FileTest algModelFile:algModelFiles){
                     if(algModelFile.getFilename().substring(algModelFile.getFilename().lastIndexOf(".")).equals(".py")){
-                        MinIoUtils.copyFile("algorithm","alg"+algId+"/version"+versionService.getMaxId()+"/"+algModelFile.getFilename(),"algmodel","model"+algModelId+"/"+algModelFile.getFilename());
+                        MinIoUtils.copyFile("algorithm","alg"+algId+"/version"+versionService.getMaxId()+"/"+algModelFile.getFilename(),"algmodel", algModelFile.getFilename());
                     }
                 }
             }

+ 1 - 0
src/main/java/io/renren/modules/sys/dao/algs/AlgTrainMapper.java

@@ -20,4 +20,5 @@ public interface AlgTrainMapper extends BaseMapper<AlgTrain> {
 
     AlgTrain selectByMissName(String missName);
 
+    AlgTrain selectByMissNameAndPlatformId(Long platformId, String missName);
 }

+ 4 - 5
src/main/java/io/renren/modules/sys/entity/algs/AlgTrain.java

@@ -1,9 +1,6 @@
 package io.renren.modules.sys.entity.algs;
 
-import com.baomidou.mybatisplus.annotation.FieldStrategy;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
 import lombok.Data;
 
 import java.util.Date;
@@ -11,7 +8,7 @@ import java.util.Date;
 @Data
 @TableName("algorithm_training")
 public class AlgTrain {
-    @TableId
+    @TableId(type = IdType.AUTO)
     private Long algorithmTrainingId;
 
     private String missName;
@@ -44,4 +41,6 @@ public class AlgTrain {
     private Integer hasRun;
 
     private String logFile;
+
+    private Long platformId;
 }

+ 2 - 0
src/main/java/io/renren/modules/sys/entity/algs/AlgTrain_Vo.java

@@ -45,4 +45,6 @@ public class AlgTrain_Vo {
     private Integer hasRun;
 
     private String logFile;
+
+    private Long platformId;
 }

+ 2 - 0
src/main/java/io/renren/modules/sys/service/AlgTrainService.java

@@ -24,4 +24,6 @@ public interface AlgTrainService extends IService<AlgTrain> {
     AlgTrain selectByMissName(String missName);
 
     AlgTrain selectByPrimaryKey(Long algorithmTrainingId);
+
+    AlgTrain selectByMissNameAndPlatformId(Long platformId, String missName);
 }

+ 5 - 0
src/main/java/io/renren/modules/sys/service/impl/AlgTrainServiceImpl.java

@@ -120,5 +120,10 @@ public class AlgTrainServiceImpl extends ServiceImpl<AlgTrainMapper, AlgTrain> i
         return algTrainMapper.selectByPrimaryKey(algorithmTrainingId);
     }
 
+    @Override
+    public AlgTrain selectByMissNameAndPlatformId(Long platformId, String missName) {
+        return algTrainMapper.selectByMissNameAndPlatformId(platformId, missName);
+    }
+
 
 }

+ 2 - 2
src/main/resources/application.yml

@@ -55,8 +55,8 @@ spring:
     date-format: yyyy-MM-dd HH:mm:ss
   servlet:
     multipart:
-      max-file-size: 100MB
-      max-request-size: 100MB
+      max-file-size: 1024MB
+      max-request-size: 1024MB
       enabled: true
   redis:
     open: false  # 是否开启redis缓存  true开启   false关闭

+ 26 - 8
src/main/resources/mapper/sys/algs/AlgTrainMapper.xml

@@ -18,10 +18,11 @@
     <result column="ip_address" jdbcType="VARCHAR" property="ipAddress" />
     <result column="has_run" jdbcType="INTEGER" property="hasRun" />
     <result column="log_file" jdbcType="VARCHAR" property="logFile" />
+    <result column="platform_id" jdbcType="VARCHAR" property="platformId" />
   </resultMap>
   <sql id="Base_Column_List">
     algorithm_training_id, miss_name, alg_frame_id, category_id, miss_status, miss_creation_time, miss_stop_time, remark,
-    uid, algorithm_id, version_id, container_id, runfile_name, ip_address, has_run, log_file
+    uid, algorithm_id, version_id, container_id, runfile_name, ip_address, has_run, log_file, platform_id
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     select 
@@ -35,21 +36,28 @@
     from algorithm_training
     where miss_name = #{missName,jdbcType=VARCHAR}
   </select>
+  <select id="selectByMissNameAndPlatformId" resultMap="BaseResultMap">
+    select
+    <include refid="Base_Column_List" />
+    from algorithm_training
+    where platform_id = #{platformId} and miss_name = #{missName,jdbcType=VARCHAR}
+  </select>
   <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     delete from algorithm_training
     where algorithm_training_id = #{algorithmTrainingId,jdbcType=BIGINT}
   </delete>
-  <insert id="insert" parameterType="io.renren.modules.sys.entity.algs.AlgTrain">
+  <insert id="insert" useGeneratedKeys="true" keyProperty="algorithmTrainingId" parameterType="io.renren.modules.sys.entity.algs.AlgTrain">
     insert into algorithm_training (algorithm_training_id, miss_name, alg_frame_id, category_id,
       miss_status, miss_creation_time, miss_stop_time, remark,
       uid, algorithm_id, version_id, 
-      container_id,runfile_name,ip_address, has_run, log_file)
+      container_id,runfile_name,ip_address, has_run, log_file, platform_id)
     values (#{algorithmTrainingId,jdbcType=BIGINT}, #{missName,jdbcType=VARCHAR}, #{algFrameId,jdbcType=BIGINT}, #{categoryId,jdbcType=BIGINT},
       #{missStatus,jdbcType=TINYINT}, #{missCreationTime,jdbcType=TIMESTAMP}, #{missStopTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR},
       #{uid,jdbcType=BIGINT}, #{algorithmId,jdbcType=BIGINT}, #{versionId,jdbcType=BIGINT}, 
-      #{containerId,jdbcType=VARCHAR},#{runfileName,jdbcType=VARCHAR},#{ipAddress,jdbcType=VARCHAR}, #{hasRun,jdbcType=INTEGER},#{logFile,jdbcType=VARCHAR})
+      #{containerId,jdbcType=VARCHAR},#{runfileName,jdbcType=VARCHAR},#{ipAddress,jdbcType=VARCHAR}, #{hasRun,jdbcType=INTEGER},#{logFile,jdbcType=VARCHAR},
+      #{platformId,jdbcType=BIGINT})
   </insert>
-  <insert id="insertSelective" parameterType="io.renren.modules.sys.entity.algs.AlgTrain">
+  <insert id="insertSelective"  useGeneratedKeys="true" keyProperty="algorithmTrainingId" parameterType="io.renren.modules.sys.entity.algs.AlgTrain">
     insert into algorithm_training
     <trim prefix="(" suffix=")" suffixOverrides=",">
       <if test="algorithmTrainingId != null">
@@ -100,6 +108,9 @@
       <if test="logFile != null">
         log_file,
       </if>
+      <if test="platformId != null">
+        platform_id,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
       <if test="algorithmTrainingId != null">
@@ -148,7 +159,10 @@
         #{hasRun,jdbcType=INTEGER},
       </if>
       <if test="logFile != null">
-        #{logFile,jdbcType=INTEGER},
+        #{logFile,jdbcType=VARCHAR},
+      </if>
+      <if test="platformId != null">
+        #{aplatformId,jdbcType=BIGINT},
       </if>
     </trim>
   </insert>
@@ -198,7 +212,10 @@
         has_run = #{hasRun,jdbcType=INTEGER},
       </if>
       <if test="logFile !=null">
-        log_file = #{logFile,jdbcType=INTEGER},
+        log_file = #{logFile,jdbcType=VARCHAR},
+      </if>
+      <if test="platformId !=null">
+        platform_id = #{platformId,jdbcType=BIGINT},
       </if>
     </set>
     where algorithm_training_id = #{algorithmTrainingId,jdbcType=BIGINT}
@@ -219,7 +236,8 @@
       runfile_name=#{runfileName,jdbcType=VARCHAR},
       ip_address = #{ipAddress,jdbcType=VARCHAR},
       has_run = #{hasRun,jdbcType=INTEGER},
-      log_file = #{logFile,jdbcType=VARCHAR}
+      log_file = #{logFile,jdbcType=VARCHAR},
+      platform_id = #{platformId,jdbcType=BIGINT},
     where algorithm_training_id = #{algorithmTrainingId,jdbcType=BIGINT}
   </update>
 </mapper>