|
@@ -4,10 +4,13 @@ import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
import com.fdkankan.modeling.constants.SysConstants;
|
|
import com.fdkankan.modeling.constants.SysConstants;
|
|
import com.fdkankan.modeling.entity.BuildLog;
|
|
import com.fdkankan.modeling.entity.BuildLog;
|
|
import com.fdkankan.modeling.service.IBuildLogService;
|
|
import com.fdkankan.modeling.service.IBuildLogService;
|
|
|
|
+import com.fdkankan.redis.util.RedisLockUtil;
|
|
|
|
+import com.fdkankan.redis.util.RedisUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.mybatis.spring.annotation.MapperScan;
|
|
import org.mybatis.spring.annotation.MapperScan;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -17,8 +20,13 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
import org.springframework.context.annotation.ComponentScan;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
import org.springframework.scheduling.annotation.EnableScheduling;
|
|
|
|
+import sun.applet.Main;
|
|
|
|
|
|
|
|
+import java.net.URL;
|
|
|
|
+import java.security.CodeSource;
|
|
|
|
+import java.security.ProtectionDomain;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
@@ -30,8 +38,11 @@ import javax.annotation.Resource;
|
|
@Slf4j
|
|
@Slf4j
|
|
public class ModelingApplication implements CommandLineRunner {
|
|
public class ModelingApplication implements CommandLineRunner {
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private IBuildLogService buildLogService;
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private RedisLockUtil redisLockUtil;
|
|
|
|
+
|
|
|
|
+ @Autowired(required = false)
|
|
|
|
+ private Optional<FYunFileServiceInterface> fYunFileService;
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
|
|
|
|
@@ -45,20 +56,19 @@ public class ModelingApplication implements CommandLineRunner {
|
|
@Override
|
|
@Override
|
|
public void run(String... args) throws Exception {
|
|
public void run(String... args) throws Exception {
|
|
|
|
|
|
-// String lockPath = null;
|
|
|
|
-// try {
|
|
|
|
-// if(StrUtil.isNotEmpty(SysConstants.hostName)){
|
|
|
|
-// List<BuildLog> list = buildLogService.list(new LambdaQueryWrapper<BuildLog>().eq(BuildLog::getHostName, SysConstants.hostName).eq(BuildLog::getStatus, 0).orderByDesc(BuildLog::getId));
|
|
|
|
-// if(CollUtil.isNotEmpty(list)){
|
|
|
|
-// BuildLog buildLog = list.get(0);
|
|
|
|
-// lockPath = buildLog.getDataSource() + "/.lockdirectory";
|
|
|
|
-// if(FileUtil.exist(lockPath)){
|
|
|
|
-// FileUtil.del(lockPath);
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }catch (Exception e){
|
|
|
|
-// log.warn("删除上一计算中场景文件锁失败,logPath:{}", lockPath, e);
|
|
|
|
-// }
|
|
|
|
|
|
+ log.info("fYunFileService.isPresent():{}", fYunFileService.isPresent());
|
|
|
|
+ if(fYunFileService.isPresent()){
|
|
|
|
+ //更新弹性伸缩jar包
|
|
|
|
+ boolean lock = redisLockUtil.lock("uploadModelingJar", 300);
|
|
|
|
+ if(lock){
|
|
|
|
+// fYunFileService.get().uploadFile()
|
|
|
|
+ ProtectionDomain domain = Main.class.getProtectionDomain();
|
|
|
|
+ CodeSource codeSource = domain.getCodeSource();
|
|
|
|
+ URL location = codeSource.getLocation();
|
|
|
|
+ String jarPath = location.getPath();
|
|
|
|
+ System.out.println("Jar file path: " + jarPath);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|