Compare commits
13 Commits
c15e4a8e3e
...
f235f2d111
Author | SHA1 | Date | |
---|---|---|---|
f235f2d111 | |||
d01f3bfcbf | |||
5af1b7a577 | |||
de32099ea9 | |||
ed38bb2600 | |||
3599a052a3 | |||
eee91c212a | |||
0b454413c0 | |||
19e6032ba7 | |||
47717399bd | |||
52ea1233e0 | |||
b7913f7a09 | |||
5654a5a05c |
doc/WorkReport
src/main
java
com
bipt
intelligentapplicationorchestrationservice
resources
@ -62,4 +62,32 @@ redis设计
|
||||
暂无
|
||||
|
||||
### 📅 明日计划
|
||||
完成redis设计,做完服务发布的逻辑开发
|
||||
完成redis设计,做完服务发布的逻辑开发
|
||||
|
||||
## 2025年5月21日
|
||||
### ✅ 今日完成
|
||||
redis的服务器配置
|
||||
|
||||
### 🚧 进行中
|
||||
开发服务发布的redis内容
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
如何把model_version表中的配置中相关GPU资源的内容提取出来。
|
||||
|
||||
### 📅 明日计划
|
||||
完成服务发布的开发
|
||||
|
||||
## 2025年5月22日
|
||||
### ✅ 今日完成
|
||||
服务发布,拦截器部分功能
|
||||
|
||||
### 🚧 进行中
|
||||
拦截器等待队列算法
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
不知道怎么优先分配等待队列中任务
|
||||
|
||||
### 📅 明日计划
|
||||
完成拦截器功能
|
||||
|
||||
|
||||
|
@ -5,14 +5,4 @@
|
||||
|
||||
|
||||
### 📅 明日计划
|
||||
- 实现需求文档功能
|
||||
|
||||
|
||||
## 2025年5月15日
|
||||
### ✅ 今日完成
|
||||
- 完成算法生命周期后端开发
|
||||
|
||||
|
||||
## 2025年5月19日
|
||||
### ✅ 今日完成
|
||||
- 完成算法创建后端开发
|
||||
- 实现需求文档功能
|
@ -25,4 +25,30 @@ _### 🚧 进行中
|
||||
- KingBase8数据库方言配置出错
|
||||
|
||||
### 📅 明日计划
|
||||
- 完成触发API请求调度缓存更新类
|
||||
- 完成触发API请求调度缓存更新类
|
||||
- ## 2025年5月19日
|
||||
### ✅ 今日完成
|
||||
- 完成缓存层设计与配置
|
||||
|
||||
_### 🚧 进行中
|
||||
- 实现缓存更新逻辑
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
- 暂无
|
||||
|
||||
### 📅 明日计划
|
||||
- 完成缓存更新逻辑
|
||||
- 设计模型部署类
|
||||
- ## 2025年5月20日
|
||||
### ✅ 今日完成
|
||||
- 完成缓存更新逻辑
|
||||
|
||||
_### 🚧 进行中
|
||||
- 设计模型部署类
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
- 暂无
|
||||
|
||||
### 📅 明日计划
|
||||
- 完成模型部署类的设计
|
||||
- 完成数据结构和基本配置
|
||||
|
@ -1,2 +0,0 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;public class ModelController {
|
||||
}
|
91
src/main/java/com/bipt/intelligentapplicationorchestrationservice/controller/publishController.java
91
src/main/java/com/bipt/intelligentapplicationorchestrationservice/controller/publishController.java
@ -1,17 +1,18 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.config.RedisConfiguration;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name ="服务发布相关接口")
|
||||
@RestController
|
||||
@ -21,6 +22,8 @@ public class publishController {
|
||||
@Autowired
|
||||
private PublishService publishService;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
/**
|
||||
* 新增请求发布
|
||||
* @param servicePublishDTO
|
||||
@ -28,14 +31,82 @@ public class publishController {
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary ="新增发布请求")
|
||||
public OptResult<ServicePublishVO> save(@RequestBody ServicePublishDTO servicePublishDTO){
|
||||
@Transactional
|
||||
public OptResult<List<ServicePublishVO>> save(@RequestBody ServicePublishDTO servicePublishDTO) {
|
||||
log.info("模型发布请求:{}", servicePublishDTO);
|
||||
publishService.save(servicePublishDTO);
|
||||
ServicePublishVO servicePublishVO = publishService.getByModelId(servicePublishDTO);
|
||||
return OptResult.success(servicePublishVO);
|
||||
Long modelId = servicePublishDTO.getModelId();
|
||||
String key = "Model_" + modelId;
|
||||
//查询redis是否存在GPU相关资源数据
|
||||
List<ServicePublishVO> list;
|
||||
list = (List<ServicePublishVO>) redisTemplate.opsForValue().get(key);
|
||||
//如果存在,直接返回,无须查询数据库
|
||||
if (list != null) {
|
||||
return OptResult.success(list);
|
||||
}else {
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
String modelConfig = publishService.getByModelId(modelId);
|
||||
if (modelConfig == null) {
|
||||
log.error("模型配置为空,modelId={}", modelId);
|
||||
}
|
||||
String[] keyValuePairs = modelConfig.split("\\|");
|
||||
String GPUMemorySize = null;
|
||||
String GPUModel = null;
|
||||
for (String pair : keyValuePairs) {
|
||||
pair = pair.trim();
|
||||
if (pair.startsWith("GPU")) {
|
||||
GPUModel = pair.split(";", 2)[1];
|
||||
} else if (pair.startsWith("Memory:")) {
|
||||
GPUMemorySize = pair.split(":", 2)[1];
|
||||
}
|
||||
}
|
||||
ServicePublishVO servicePublishVO = new ServicePublishVO();
|
||||
servicePublishVO.setIp(servicePublishDTO.getIp());
|
||||
servicePublishVO.setModelId(servicePublishDTO.getModelId());
|
||||
servicePublishVO.setGPUMemorySize(GPUMemorySize);
|
||||
servicePublishVO.setGPUModel(GPUModel);
|
||||
//todo 调用模型部署,传递信息
|
||||
|
||||
servicePublishVO.setApiUrl(servicePublishDTO.getApiUrl());
|
||||
list.add(servicePublishVO);
|
||||
redisTemplate.opsForValue().set(key,list);
|
||||
//一个ip上有多个机器
|
||||
// 假设从 Redis 获取的列表元素是 MachineInfo 类型
|
||||
String ip = servicePublishVO.getIp();
|
||||
String key1 = ip;
|
||||
List<MachineInfo> machineList = (List<MachineInfo>) redisTemplate.opsForValue().get(key1);
|
||||
|
||||
|
||||
// 模型所需的 GPU 资源
|
||||
String requiredGPUModel = servicePublishVO.getGPUModel();
|
||||
Integer requiredGPUMemory = Integer.valueOf(servicePublishVO.getGPUMemorySize());
|
||||
|
||||
if (machineList != null) {
|
||||
for (MachineInfo machine : machineList) {
|
||||
// 获取机器的 GPU 资源
|
||||
String machineGPUModel = machine.getGPUModel();
|
||||
Integer machineGPUMemory = machine.getGPUMemorySize();
|
||||
|
||||
// 判断机器是否满足模型需求
|
||||
if (requiredGPUModel.equals(machineGPUModel) &&
|
||||
machineGPUMemory >= requiredGPUMemory) {
|
||||
return OptResult.success(list);
|
||||
}
|
||||
}
|
||||
String key3 = "wait_queue";
|
||||
redisTemplate.opsForValue().set(key3,list);
|
||||
//todo资源释放时候优先分配等待队列中任务
|
||||
|
||||
}
|
||||
|
||||
return OptResult.success(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,2 +0,0 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;public interface ModelMapper {
|
||||
}
|
@ -14,8 +14,7 @@ public interface PublishMapper {
|
||||
void insert(ServicePublishDTO servicePublishDTO);
|
||||
|
||||
Long getByApiUrl(String apiUrl);
|
||||
@Select("select * from model_version where model_id=#{modelId} and status = 1")
|
||||
ModelVersion getById(Long modelId);
|
||||
@Select("select model_config from model_version where model_id=#{modelId} and status = 1")
|
||||
String getById(Long modelId);
|
||||
|
||||
ServicePublishVO getByModelId(Long modelId);
|
||||
}
|
||||
|
39
src/main/java/com/bipt/intelligentapplicationorchestrationservice/pojo/MachineInfo.java
Normal file
39
src/main/java/com/bipt/intelligentapplicationorchestrationservice/pojo/MachineInfo.java
Normal file
@ -0,0 +1,39 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 机器信息实体类
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class MachineInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String id; // 机器唯一标识
|
||||
private String ip; // IP 地址
|
||||
private String hostname; // 主机名
|
||||
private Integer cpuCoreNum; // CPU 核心数
|
||||
private Long memoryTotal; // 总内存 (MB)
|
||||
private Long memoryUsed; // 已用内存 (MB)
|
||||
private String GPUModel; // GPU 型号
|
||||
private Integer GPUMemorySize; // GPU 显存大小 (GB)
|
||||
private Integer GPUCount; // GPU 数量
|
||||
private Integer status; // 机器状态 (0: 离线, 1: 在线, 2: 繁忙)
|
||||
private String os; // 操作系统
|
||||
private String region; // 所属区域
|
||||
private String zone; // 可用区
|
||||
private Date createTime; // 创建时间
|
||||
private Date updateTime; // 更新时间
|
||||
private Map<String, String> labels; // 自定义标签
|
||||
}
|
@ -1,2 +0,0 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;public class ModelDTO {
|
||||
}
|
@ -16,8 +16,8 @@ import java.time.LocalDateTime;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServicePublish implements Serializable {
|
||||
private Long id;
|
||||
private Long modelId;
|
||||
private String apiUrl;
|
||||
private LocalDateTime createTime;
|
||||
private String GPUModel;
|
||||
private String ip;
|
||||
private String GPUMemorySize;
|
||||
}
|
||||
|
@ -19,4 +19,5 @@ public class ServicePublishDTO implements Serializable {
|
||||
private Long modelId;
|
||||
private String apiUrl;
|
||||
private LocalDateTime createTime;
|
||||
private String ip;
|
||||
}
|
||||
|
@ -17,13 +17,10 @@ import java.time.LocalDateTime;
|
||||
@AllArgsConstructor
|
||||
public class ServicePublishVO implements Serializable {
|
||||
private Long modelId;
|
||||
private String GPUModel;
|
||||
private String ip;
|
||||
private String GPUMemorySize;
|
||||
private String apiUrl;
|
||||
private String version;
|
||||
private Integer datasetId;
|
||||
private String modelConfig;
|
||||
private String modelPath;
|
||||
private Integer status;
|
||||
private LocalDateTime createTime;
|
||||
|
||||
|
||||
}
|
||||
|
2
src/main/java/com/bipt/intelligentapplicationorchestrationservice/service/Impl/ModelServiceImpl.java
2
src/main/java/com/bipt/intelligentapplicationorchestrationservice/service/Impl/ModelServiceImpl.java
@ -1,2 +0,0 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;public class ModelServiceImpl {
|
||||
}
|
@ -1,9 +1,7 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.PublishMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ModelVersion;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -31,19 +29,17 @@ public class PublishServiceImpl implements PublishService {
|
||||
if (id != null){
|
||||
throw new IllegalArgumentException("请求已存在: " + apiUrl);
|
||||
}
|
||||
Long modelId = servicePublishDTO.getModelId();
|
||||
ModelVersion modelVersion = publishMapper.getById(modelId);
|
||||
String modelConfig = modelVersion.getModelConfig();
|
||||
//todo 调用GPU分配
|
||||
|
||||
|
||||
publishMapper.insert(servicePublishDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查找配置信息
|
||||
* @param modelId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ServicePublishVO getByModelId(ServicePublishDTO servicePublishDTO) {
|
||||
Long modelId = servicePublishDTO.getModelId();
|
||||
return publishMapper.getByModelId(modelId);
|
||||
public String getByModelId(Long modelId) {
|
||||
return publishMapper.getById(modelId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +0,0 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
public interface ModelService {
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||
|
||||
public interface PublishService {
|
||||
|
||||
void save(ServicePublishDTO servicePublishDTO);
|
||||
|
||||
ServicePublishVO getByModelId(ServicePublishDTO servicePublishDTO);
|
||||
|
||||
|
||||
|
||||
String getByModelId(Long modelId);
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ spring.data.redis.port=6379
|
||||
# Redis密码(如果有)
|
||||
spring.data.redis.password=Jbjhhzstsl97@
|
||||
# Redis数据库索引(默认为0)
|
||||
spring.data.redis.database=0
|
||||
spring.data.redis.database = 0
|
||||
# 连接超时时间(毫秒)
|
||||
spring.data.redis.timeout=3000
|
||||
spring.data.redis.timeout = 3000
|
||||
|
@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bipt.intelligentapplicationorchestrationservice.mapper.EvaluationMapper">
|
||||
<!--查询模型日志详细信息-->
|
||||
<select id="selectLogDetail" resultType="modelLogVO">
|
||||
select m1.*,
|
||||
m2.model_name,
|
||||
m3.model_config, m3.version
|
||||
from model_log m1,
|
||||
model_info m2,
|
||||
model_version m3
|
||||
where m1.model_id=m2.id and m3.model_id=m2.id and m1.model_id = #{id}
|
||||
</select>
|
||||
|
||||
<!--更新模型信息(目前只更新模型是否上线,后续如果更多需求可优化>-->
|
||||
<update id="update">
|
||||
update model_version set
|
||||
<if test="status != null">
|
||||
status=#{status}
|
||||
</if>
|
||||
where model_id=#{id}
|
||||
</update>
|
||||
</mapper>
|
Reference in New Issue
Block a user