|
@@ -6,6 +6,7 @@ import api.common.util.*;
|
|
|
import com.css.simulation.resource.scheduler.configuration.docker.DockerConfiguration;
|
|
|
import com.css.simulation.resource.scheduler.configuration.git.GitConfiguration;
|
|
|
import com.css.simulation.resource.scheduler.configuration.kubernetes.KubernetesConfiguration;
|
|
|
+import com.css.simulation.resource.scheduler.manager.ProjectManager;
|
|
|
import com.css.simulation.resource.scheduler.mapper.*;
|
|
|
import com.css.simulation.resource.scheduler.pojo.po.*;
|
|
|
import com.css.simulation.resource.scheduler.pojo.to.*;
|
|
@@ -102,6 +103,8 @@ public class ProjectService {
|
|
|
KubernetesConfiguration kubernetesConfiguration;
|
|
|
@Resource
|
|
|
GitConfiguration gitConfiguration;
|
|
|
+ @Resource
|
|
|
+ ProjectManager projectManager;
|
|
|
|
|
|
|
|
|
// -------------------------------- Comment --------------------------------
|
|
@@ -173,6 +176,9 @@ public class ProjectService {
|
|
|
* @param projectRunningPrefix
|
|
|
* @param userId
|
|
|
* @param projectId
|
|
|
+ * @param projectType
|
|
|
+ * @param nodeMap 节点
|
|
|
+ * @param algorithmDockerImage 算法
|
|
|
* @param videoTime 视频长度
|
|
|
* @param scenePOSet
|
|
|
* @param vehiclePO
|
|
@@ -180,8 +186,19 @@ public class ProjectService {
|
|
|
* @param ogtPOList
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
- public void sendTaskMessage(int parallelism, String projectRunningPrefix, String userId, String projectId, String projectType, Long videoTime, Set<ScenePO> scenePOSet, VehiclePO vehiclePO, List<CameraPO> cameraPOList, List<OgtPO> ogtPOList) {
|
|
|
-
|
|
|
+ public void sendTaskMessage(int parallelism,
|
|
|
+ String projectRunningPrefix,
|
|
|
+ String userId,
|
|
|
+ String projectId,
|
|
|
+ String projectType,
|
|
|
+ Map<String, Integer> nodeMap,
|
|
|
+ String algorithmDockerImage,
|
|
|
+ Long videoTime,
|
|
|
+ Set<ScenePO> scenePOSet,
|
|
|
+ VehiclePO vehiclePO,
|
|
|
+ List<CameraPO> cameraPOList,
|
|
|
+ List<OgtPO> ogtPOList) {
|
|
|
+ Map<String, Integer> nodeMapToCount = projectUtil.getNodeMapToCount(nodeMap);
|
|
|
final int[] messageNumber = CollectionUtil.createIntArray(0);
|
|
|
ApacheKafkaUtil.createTopic(kafkaAdminClient, projectId, parallelism, (short) 1); // 创建主题
|
|
|
log.info("ProjectService--sendTaskMessage 项目 " + projectId + " 获得的包括的场景信息为:" + scenePOSet);
|
|
@@ -227,14 +244,14 @@ public class ProjectService {
|
|
|
String osgbName = splitOsgb[splitOsgb.length - 1];
|
|
|
try {
|
|
|
String xodrPathOfLinux = linuxTempPath + "video/" + projectId + "/" + taskId + "/" + xodrName;
|
|
|
- String xodrPathOfMinio = projectResultPathOfMinio + projectId + "/" + taskId + "/" + taskId+".xodr";
|
|
|
+ String xodrPathOfMinio = projectResultPathOfMinio + projectId + "/" + taskId + "/" + taskId + ".xodr";
|
|
|
String osgbPathOfLinux = linuxTempPath + "video/" + projectId + "/" + taskId + "/" + osgbName;
|
|
|
- String osgbPathOfMinio = projectResultPathOfMinio + projectId + "/" + taskId + "/" + taskId+".osgb";
|
|
|
+ String osgbPathOfMinio = projectResultPathOfMinio + projectId + "/" + taskId + "/" + taskId + ".osgb";
|
|
|
MinioUtil.downloadToFile(minioClient, bucketName, scenarioOdr, xodrPathOfLinux);
|
|
|
- MinioUtil.downloadToFile(minioClient, bucketName, scenarioOsgb, osgbPathOfLinux);
|
|
|
MinioUtil.uploadFromFile(minioClient, xodrPathOfLinux, bucketName, xodrPathOfMinio);
|
|
|
- MinioUtil.uploadFromFile(minioClient, osgbPathOfLinux, bucketName, osgbPathOfMinio);
|
|
|
log.info("ProjectService--sendTaskMessage 已经将 xodr 上传到 minio 的结果文件目录:" + xodrPathOfMinio);
|
|
|
+ MinioUtil.downloadToFile(minioClient, bucketName, scenarioOsgb, osgbPathOfLinux);
|
|
|
+ MinioUtil.uploadFromFile(minioClient, osgbPathOfLinux, bucketName, osgbPathOfMinio);
|
|
|
log.info("ProjectService--sendTaskMessage 已经将 osgb 上传到 minio 的结果文件目录:" + osgbPathOfMinio);
|
|
|
} catch (IOException | ServerException | InsufficientDataException | ErrorResponseException |
|
|
|
NoSuchAlgorithmException | InvalidKeyException | InvalidResponseException |
|
|
@@ -305,8 +322,9 @@ public class ProjectService {
|
|
|
long offset = success.getRecordMetadata().offset();
|
|
|
log.info("------- ProjectConsumer 发送消息成功, 主题 topic 为:" + topic + " 分区 partition 为:" + partition + " 偏移量为:" + offset + " 消息体为:" + finalTaskJson);
|
|
|
//4-6 发送成功过的同时创建 pod.yaml 文件并把文件地址存到 redis
|
|
|
-
|
|
|
-
|
|
|
+ // 选一个count最少的node
|
|
|
+ String leastCountNodeName = projectUtil.getLeastCountNodeOfNodeMapToCount(nodeMapToCount);
|
|
|
+ projectManager.createTempYaml(projectId, algorithmDockerImage, leastCountNodeName, partition, offset);
|
|
|
|
|
|
|
|
|
}, failure -> log.error("------- 发送消息失败:" + failure.getMessage()));
|