|
@@ -1,15 +1,15 @@
|
|
|
-package com.css.simulation.resource.monitor.scheduler;
|
|
|
+package com.css.simulation.resource.monitor.infrastructure.scheduler;
|
|
|
|
|
|
import api.common.pojo.dto.Host;
|
|
|
import api.common.pojo.po.home.SystemServerPO;
|
|
|
import api.common.util.SshUtil;
|
|
|
import api.common.util.StringUtil;
|
|
|
import api.common.util.TimeUtil;
|
|
|
-import com.css.simulation.resource.monitor.configuration.minio.MinioConfiguration;
|
|
|
-import com.css.simulation.resource.monitor.manager.SystemServerManager;
|
|
|
-import com.css.simulation.resource.monitor.mappper.ScenePackageSublistMapper;
|
|
|
-import com.css.simulation.resource.monitor.pojo.GeneralPO;
|
|
|
-import com.css.simulation.resource.monitor.util.MinioUtil;
|
|
|
+import com.css.simulation.resource.monitor.infrastructure.fs.minio.MinioConfiguration;
|
|
|
+import com.css.simulation.resource.monitor.domain.SystemServerDomainService;
|
|
|
+import com.css.simulation.resource.monitor.infrastructure.db.mysql.mapper.ScenePackageSublistMapper;
|
|
|
+import com.css.simulation.resource.monitor.infrastructure.db.entity.GeneralEntity;
|
|
|
+import com.css.simulation.resource.monitor.infrastructure.fs.minio.MinioUtil;
|
|
|
import io.minio.MinioClient;
|
|
|
import lombok.Data;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -30,13 +30,13 @@ import java.util.List;
|
|
|
@Data
|
|
|
@Slf4j
|
|
|
@ConfigurationProperties(prefix = "ssh")
|
|
|
-public class MyScheduler {
|
|
|
+public class ServerScheduler {
|
|
|
|
|
|
List<Host> hostList;
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
- private SystemServerManager systemServerManager;
|
|
|
+ private SystemServerDomainService systemServerDomainService;
|
|
|
@Resource
|
|
|
private ScenePackageSublistMapper scenePackageSublistMapper;
|
|
|
@Resource
|
|
@@ -95,7 +95,7 @@ public class MyScheduler {
|
|
|
sshClient.stop();
|
|
|
}
|
|
|
log.info("获取服务器信息。" + systemServerPOList);
|
|
|
- systemServerManager.deleteAndInsert(systemServerPOList);
|
|
|
+ systemServerDomainService.deleteAndInsert(systemServerPOList);
|
|
|
} catch (IOException | DocumentException | InterruptedException e) {
|
|
|
throw new RuntimeException(e);
|
|
|
}
|
|
@@ -116,20 +116,20 @@ public class MyScheduler {
|
|
|
sceneGeneralizationIdList.addAll(Arrays.asList(split));
|
|
|
});
|
|
|
//3 查询不在id列表中的所有泛化数据
|
|
|
- List<GeneralPO> generalPOS = scenePackageSublistMapper.selectGeneralDataNotIn(sceneGeneralizationIdList);
|
|
|
- log.info("准备删除:" + generalPOS);
|
|
|
- generalPOS.forEach(
|
|
|
- generalPO -> {
|
|
|
- if (StringUtil.isNotEmpty(generalPO.getOsgbAddress())) {
|
|
|
- MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalPO.getOsgbAddress());
|
|
|
+ List<GeneralEntity> generalEntities = scenePackageSublistMapper.selectGeneralDataNotIn(sceneGeneralizationIdList);
|
|
|
+ log.info("准备删除:" + generalEntities);
|
|
|
+ generalEntities.forEach(
|
|
|
+ generalEntity -> {
|
|
|
+ if (StringUtil.isNotEmpty(generalEntity.getOsgbAddress())) {
|
|
|
+ MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalEntity.getOsgbAddress());
|
|
|
}
|
|
|
- if (StringUtil.isNotEmpty(generalPO.getXodrAddress())) {
|
|
|
- MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalPO.getXodrAddress());
|
|
|
+ if (StringUtil.isNotEmpty(generalEntity.getXodrAddress())) {
|
|
|
+ MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalEntity.getXodrAddress());
|
|
|
}
|
|
|
- if (StringUtil.isNotEmpty(generalPO.getXoscAddress())) {
|
|
|
- MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalPO.getXoscAddress());
|
|
|
+ if (StringUtil.isNotEmpty(generalEntity.getXoscAddress())) {
|
|
|
+ MinioUtil.rm(minioClient, minioConfiguration.getBucketName(), generalEntity.getXoscAddress());
|
|
|
}
|
|
|
- scenePackageSublistMapper.deleteById(generalPO.getId());
|
|
|
+ scenePackageSublistMapper.deleteById(generalEntity.getId());
|
|
|
}
|
|
|
);
|
|
|
} catch (Exception e) {
|
|
@@ -139,15 +139,4 @@ public class MyScheduler {
|
|
|
|
|
|
}
|
|
|
|
|
|
-// @Scheduled(fixedDelay = 2 * 1000)
|
|
|
-// public void test() throws IOException, DocumentException {
|
|
|
-// SshClient client = SshUtil.getClient();
|
|
|
-// ClientSession session = SshUtil.getSession(client, "182.92.203.182", "root", "CICV2022test");
|
|
|
-// double gpuUsage = SshUtil.gpuUsage(session);
|
|
|
-// long gpuTotal = SshUtil.gpuTotal(session);
|
|
|
-// System.out.println(gpuUsage);
|
|
|
-// System.out.println(gpuTotal);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
}
|