Compare commits
116 Commits
23be873a7c
...
main
Author | SHA1 | Date | |
---|---|---|---|
c7505179bb | |||
19e8d21620 | |||
671dc90b61 | |||
0ccef5f290 | |||
ae97005a7c | |||
fb2ee66b5b | |||
5ef521438a | |||
e6e1bee8df | |||
d3c81412b9 | |||
ed4cd0643a | |||
808d285888 | |||
02538ef4f4 | |||
a0680450e6 | |||
d219fbc92a | |||
86a64f205f | |||
9d25661743 | |||
957c5bc3e1 | |||
09424cf223 | |||
d11aaccb1e | |||
f18c4e4159 | |||
cf2eb689ca | |||
46331fcade | |||
99c291ca09 | |||
b926506ede | |||
0aff6e71ff | |||
94bfc4cc70 | |||
1cf3944744 | |||
64d21a574d | |||
05eb83d68d | |||
cc0b69362c | |||
43641b7d02 | |||
22547031cf | |||
caeb280396 | |||
158fdca6e0 | |||
0fe404b717 | |||
ee8e4709a6 | |||
92b470e001 | |||
49851384c8 | |||
0619c7d184 | |||
5dd1cfcf9e | |||
77a4b86cb4 | |||
df4ae86ea3 | |||
b218335558 | |||
987e5c30fe | |||
cae2a7786e | |||
9eef82b642 | |||
789108aaa3 | |||
3fb10b1e2f | |||
4a1e6013b3 | |||
c24d640de4 | |||
2aaf3d96f0 | |||
77fb43e95d | |||
bcf44161b5 | |||
5692cca3e7 | |||
60a71a121c | |||
12a9355bb8 | |||
9f348280ea | |||
999fd82ccc | |||
28b5ca1dfc | |||
c01e985256 | |||
73388da706 | |||
56bfdad0c0 | |||
f235f2d111 | |||
d01f3bfcbf | |||
5af1b7a577 | |||
de32099ea9 | |||
ed38bb2600 | |||
3599a052a3 | |||
eee91c212a | |||
0b454413c0 | |||
19e6032ba7 | |||
47717399bd | |||
52ea1233e0 | |||
b7913f7a09 | |||
5654a5a05c | |||
e706d8311f | |||
370a2d3ce0 | |||
4f9aed8965 | |||
038a16b428 | |||
f96e32816a | |||
9607f38965 | |||
35f12bc547 | |||
e1a59b64f3 | |||
b61f1bf151 | |||
8603aad8c5 | |||
33d96e0aec | |||
0813f0d99b | |||
c13ff70f6b | |||
d138f25e4c | |||
aaf265aeb0 | |||
84b9711c57 | |||
e096b52c7b | |||
64abd2d824 | |||
d14afaf3ca | |||
b1772bea6f | |||
220fdb1121 | |||
ec38f39a0e | |||
81353344da | |||
b6aa3959ce | |||
4b5206d1c0 | |||
be5ff6ff74 | |||
e7099f3a85 | |||
e3b2e24ba1 | |||
606d7cf728 | |||
84421e5ae5 | |||
272d1ea54d | |||
6943f38d1b | |||
d6625b52f4 | |||
e8eddb9c53 | |||
2f8c8940c0 | |||
f64e4062f0 | |||
8b42b760e6 | |||
91af52cf24 | |||
b953e85704 | |||
51e80031ba | |||
736590b3fa |
9
doc/DesignDocument/数据库文档-杜冲.md
Normal file
9
doc/DesignDocument/数据库文档-杜冲.md
Normal file
@ -0,0 +1,9 @@
|
||||
‌**<span style="font-size:14pt">TableName: Gpu_Resource</span>**‌
|
||||
|
||||
| <20>ֶ<EFBFBD><D6B6><EFBFBD> | <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | Լ<><D4BC> | <20>ֶ<EFBFBD><D6B6><EFBFBD><EFBFBD><EFBFBD> |
|
||||
|:-------------:|:-------------:|:--------:|:-------------:|
|
||||
| GPUId | BIGINT | <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> | GPU<50><55>ID<49><44>ȫ<EFBFBD><C8AB>Ψһ<CEA8><D2BB>ʶ |
|
||||
| GPUModel | VARCHAR(64) | NOT NULL | GPU<50><55><EFBFBD>ͺ<EFBFBD> |
|
||||
| GPUMemorySize | INT | NOT NULL | GPU<50>ڴ<EFBFBD><DAB4><EFBFBD>С |
|
||||
| Ip | VARCHAR(15) | NOT NULL | GPU<50><55><EFBFBD><EFBFBD>ip |
|
||||
| CreatedTime | DATETIME | NULL | GPU<50><55><EFBFBD><EFBFBD>ʱ<EFBFBD>䣬<EFBFBD><E4A3AC>Ϊ<EFBFBD><CEAA> |
|
16
doc/DesignDocument/模型服务表--hky.md
Normal file
16
doc/DesignDocument/模型服务表--hky.md
Normal file
@ -0,0 +1,16 @@
|
||||
# 数据库设计文档
|
||||
|
||||
## 服务发布
|
||||
|
||||
### 服务发布
|
||||
|
||||
#### 1.服务发布表(service_publish)
|
||||
|
||||
| 序号 | 数据表名 | 中文名称 |
|
||||
| ---- | -------- | ------------------ |
|
||||
| 1 | id | 发布表id(发布记录唯一标识) |
|
||||
| 2 | model_id | 模型id |
|
||||
| 3 | api_url | api路径 |
|
||||
| 4 | create_time | 发布请求创建时间 |
|
||||
|
||||
####
|
16
doc/DesignDocument/算法生命周期设计文档_孙一城.md
Normal file
16
doc/DesignDocument/算法生命周期设计文档_孙一城.md
Normal file
@ -0,0 +1,16 @@
|
||||
# 算法生命周期管理数据库设计文档
|
||||
|
||||
## 1. 数据表设计
|
||||
|
||||
### 1.1 algorithm_info(算法基础信息表)
|
||||
| 字段名 | 类型 | 是否为空 | 默认值 | 说明 |
|
||||
|--------|------|----------|--------|------|
|
||||
| id | BIGINT | NOT NULL | AUTO_INCREMENT | 算法ID |
|
||||
| algorithm_name | VARCHAR(100) | NOT NULL | | 算法名称(唯一) |
|
||||
| algorithm_file | VARCHAR(255) | NOT NULL | | 算法文件路径 |
|
||||
| algorithm_type | VARCHAR(50) | NOT NULL | | 算法分类 |
|
||||
| description | TEXT | NULL | | 算法描述 |
|
||||
| created_by | VARCHAR(50) | NOT NULL | | 创建人 |
|
||||
| create_time | DATETIME | NOT NULL | CURRENT_TIMESTAMP | 创建时间 |
|
||||
| update_time | DATETIME | NOT NULL | CURRENT_TIMESTAMP ON UPDATE | 更新时间 |
|
||||
| file_size | BIGINT | NULL | | 文件大小(字节) |
|
13
doc/WorkReport/2025-05-15-杜冲.md
Normal file
13
doc/WorkReport/2025-05-15-杜冲.md
Normal file
@ -0,0 +1,13 @@
|
||||
# 工作日报 - 2025年5月
|
||||
## 2025年5月15日
|
||||
### ✅ 今日完成
|
||||
- 完成删除和查询功能
|
||||
|
||||
_### 🚧 进行中
|
||||
- 设计触发服务API请求调度缓存更新类
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
- KingBase8数据库方言配置出错
|
||||
|
||||
### 📅 明日计划
|
||||
- 完成触发API请求调度缓存更新类
|
106
doc/WorkReport/2025-05-hky.md
Normal file
106
doc/WorkReport/2025-05-hky.md
Normal file
@ -0,0 +1,106 @@
|
||||
# 工作日报 - 2025年5月
|
||||
## 2025年5月14日
|
||||
### ✅ 今日完成
|
||||
完成分页查询
|
||||
|
||||
### 🚧 进行中
|
||||
删除操作
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
测试方法不知道怎么写
|
||||
|
||||
### 📅 明日计划
|
||||
写完删除代码,进行测试
|
||||
|
||||
## 2025年5月15日
|
||||
### ✅ 今日完成
|
||||
完成删除数据集增加数据集,部分测试
|
||||
|
||||
### 🚧 进行中
|
||||
测试(或添加具体异常处理)
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
暂无
|
||||
|
||||
### 📅 明日计划
|
||||
测试完毕,开下一个模块
|
||||
|
||||
## 2025年5月18日
|
||||
### ✅ 今日完成
|
||||
格式修改,增加了枚举等方便后续维护和开发,修改了删除的逻辑
|
||||
|
||||
### 🚧 进行中
|
||||
模型服务的数据库表设计
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
暂无
|
||||
|
||||
### 📅 明日计划
|
||||
完成模型服务的数据库表设计
|
||||
|
||||
## 2025年5月19日
|
||||
### ✅ 今日完成
|
||||
模型发布的数据库设计
|
||||
|
||||
### 🚧 进行中
|
||||
模型发布的逻辑开发
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
暂无
|
||||
|
||||
### 📅 明日计划
|
||||
完成模型发布的逻辑开发
|
||||
|
||||
## 2025年5月20日
|
||||
### ✅ 今日完成
|
||||
服务发布逻辑开发(无GPU版)
|
||||
|
||||
### 🚧 进行中
|
||||
redis设计
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
暂无
|
||||
|
||||
### 📅 明日计划
|
||||
完成redis设计,做完服务发布的逻辑开发
|
||||
|
||||
## 2025年5月21日
|
||||
### ✅ 今日完成
|
||||
redis的服务器配置
|
||||
|
||||
### 🚧 进行中
|
||||
开发服务发布的redis内容
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
如何把model_version表中的配置中相关GPU资源的内容提取出来。
|
||||
|
||||
### 📅 明日计划
|
||||
完成服务发布的开发
|
||||
|
||||
## 2025年5月23日
|
||||
### ✅ 今日完成
|
||||
服务发布,拦截器部分功能
|
||||
|
||||
### 🚧 进行中
|
||||
拦截器等待队列算法
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
不知道怎么优先分配等待队列中任务
|
||||
|
||||
### 📅 明日计划
|
||||
完成拦截器功能
|
||||
|
||||
## 2025年5月25日
|
||||
### ✅ 今日完成
|
||||
服务发布可注册到nacos上
|
||||
|
||||
### 🚧 进行中
|
||||
拦截器开发
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
模型api请求不知道是什么
|
||||
|
||||
### 📅 明日计划
|
||||
开发拦截器功能
|
||||
|
||||
|
178
doc/WorkReport/2025-05-nh.md
Normal file
178
doc/WorkReport/2025-05-nh.md
Normal file
@ -0,0 +1,178 @@
|
||||
# 工作日报 - 2025年5月
|
||||
## 2025年5月14日
|
||||
### ✅ 今日完成
|
||||
- 完成相关数据库表的创建
|
||||
- 模型评估部分实体类的定义
|
||||
- 新增了SpringBoot配置文件中的一些配置
|
||||
|
||||
### 🚧 进行中
|
||||
- 模型评估部分显示日志后端部分开发
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
- lombok注解出现问题,没法正常使用
|
||||
|
||||
### 📅 明日计划
|
||||
- 继续开发模型评估部分
|
||||
- 尽量解决lombok存在的问题
|
||||
|
||||
## 2025年5月15日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
* 基本完成模型评估部分开发
|
||||
* 引入了SpringDoc OpenAPI相关依赖和配置
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
* 继续优化模型评估部分
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
* 继续优化模型评估部分
|
||||
|
||||
## 2025年5月19日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 项目设计文档分析
|
||||
- 尝试项目前端页面开发(数据集管理页面)
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 项目设计文档分析
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 基本完成创建模型部分后端开发
|
||||
|
||||
## 2025年5月20日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 数据库表字段新增
|
||||
- 实体类定义与修改
|
||||
- 基本完成创建模型部分后端开发
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 创建模型部分后端优化
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型信息管理部分后端开发
|
||||
|
||||
## 2025年5月23日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 模型信息管理前端页面基础搭建
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 模型信息管理前端页面搭建
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型信息管理前端页面搭建
|
||||
|
||||
## 2025年5月24日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 模型信息管理前端页面部分数据与后端联调
|
||||
- 模型信息管理后端开发20%
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 模型信息管理后端开发
|
||||
- 模型信息管理前端页面部分数据与后端联调
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型信息管理后端开发
|
||||
- 模型信息管理前端页面部分数据与后端联调
|
||||
|
||||
## 2025年5月25日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 模型信息管理前端页面开发
|
||||
- 模型信息管理后端开发90%(后续可能还需要根据需求优化)
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 模型信息管理前端页面开发
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型信息管理前端页面开发
|
||||
|
||||
## 2025年5月26日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
## 2025年5月27日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
## 2025年5月28日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
## 2025年5月29日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
## 2025年5月30日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 增加了查询数据集列表和生命周期列表接口
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型信息管理前端页面开发与后端联调
|
8
doc/WorkReport/2025-05-孙一城.md
Normal file
8
doc/WorkReport/2025-05-孙一城.md
Normal file
@ -0,0 +1,8 @@
|
||||
# 工作日报 - 2025年5月
|
||||
## 2025年5月14日
|
||||
### ✅ 今日完成
|
||||
- 完成建表
|
||||
|
||||
|
||||
### 📅 明日计划
|
||||
- 实现需求文档功能
|
54
doc/WorkReport/2025-05-杜冲.md
Normal file
54
doc/WorkReport/2025-05-杜冲.md
Normal file
@ -0,0 +1,54 @@
|
||||
# 工作日报 - 2025年5月
|
||||
## 2025年5月14日
|
||||
### ✅ 今日完成
|
||||
- 完成删除和查询功能
|
||||
- 完成API请求调度缓存层设计(未实现)
|
||||
_
|
||||
_### 🚧 进行中
|
||||
- API请求调度缓存层实现
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
- KingBase8数据库方言配置出错
|
||||
|
||||
### 📅 明日计划
|
||||
-
|
||||
- 完成API请求调度缓存层
|
||||
|
||||
## 2025年5月15日
|
||||
### ✅ 今日完成
|
||||
- 完成删除和查询功能
|
||||
|
||||
_### 🚧 进行中
|
||||
- 设计触发服务API请求调度缓存更新类
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
- KingBase8数据库方言配置出错
|
||||
|
||||
### 📅 明日计划
|
||||
- 完成触发API请求调度缓存更新类
|
||||
- ## 2025年5月19日
|
||||
### ✅ 今日完成
|
||||
- 完成缓存层设计与配置
|
||||
|
||||
_### 🚧 进行中
|
||||
- 实现缓存更新逻辑
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
- 暂无
|
||||
|
||||
### 📅 明日计划
|
||||
- 完成缓存更新逻辑
|
||||
- 设计模型部署类
|
||||
- ## 2025年5月20日
|
||||
### ✅ 今日完成
|
||||
- 完成缓存更新逻辑
|
||||
|
||||
_### 🚧 进行中
|
||||
- 设计模型部署类
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
- 暂无
|
||||
|
||||
### 📅 明日计划
|
||||
- 完成模型部署类的设计
|
||||
- 完成数据结构和基本配置
|
60
doc/WorkReport/2025-06-nh .md
Normal file
60
doc/WorkReport/2025-06-nh .md
Normal file
@ -0,0 +1,60 @@
|
||||
# 工作日报 - 2025年5月
|
||||
## 2025年6月3日
|
||||
### ✅ 今日完成
|
||||
- 优化模型构建表单
|
||||
|
||||
### 🚧 进行中
|
||||
- 优化模型构建表单
|
||||
|
||||
### 📅 明日计划
|
||||
- 优化模型构建表单
|
||||
|
||||
## 2025年6月4日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
* 阿里云OSS文件上传后端接口开发
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
* 阿里云OSS文件上传后端接口开发(存在问题)
|
||||
* 模型管理前端页面开发
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
|
||||
- Spring MVC依赖被注释,和gateway冲突了,已经发现了问题
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
* 继续完善阿里云OSS文件上传后端接口开发,保证接口测试成功
|
||||
* 模型管理前端页面开发
|
||||
|
||||
## 2025年6月5日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 阿里云OSS文件上传后端接口开发调试成功
|
||||
- 基本完成了创建模型和修改模型的前后端联调
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 模型管理前端页面开发
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型管理前端页面开发
|
||||
|
||||
## 2025年6月6日
|
||||
|
||||
### ✅ 今日完成
|
||||
|
||||
- 基本完成了版本构建、修改生命周期、上下线、模型评估和详情功能
|
||||
- 修改了模型评估和生命周期更新的一些细节,便于和前端接口协调
|
||||
|
||||
### 🚧 进行中
|
||||
|
||||
- 模型管理页面前端细节优化
|
||||
|
||||
### 📅 明日计划
|
||||
|
||||
- 模型管理页面前端细节优化
|
@ -1,39 +0,0 @@
|
||||
# 算法生命周期管理数据库设计文档
|
||||
|
||||
## 1. 数据表设计
|
||||
|
||||
### 1.1 algorithm_info(算法基础信息表)
|
||||
| 字段名 | 类型 | 是否为空 | 默认值 | 说明 |
|
||||
|--------|------|----------|--------|------|
|
||||
| id | BIGINT | NOT NULL | AUTO_INCREMENT | 主键ID |
|
||||
| algorithm_name | VARCHAR(100) | NOT NULL | | 算法名称(唯一) |
|
||||
| algorithm_type | VARCHAR(50) | NOT NULL | | 算法分类 |
|
||||
| description | TEXT | NULL | | 算法描述 |
|
||||
| created_by | VARCHAR(50) | NOT NULL | | 创建人 |
|
||||
| create_time | DATETIME | NOT NULL | CURRENT_TIMESTAMP | 创建时间 |
|
||||
| update_time | DATETIME | NOT NULL | CURRENT_TIMESTAMP ON UPDATE | 更新时间 |
|
||||
| status | TINYINT | NOT NULL | 1 | 状态(1启用 0禁用 -1删除) |
|
||||
|
||||
### 1.2 algorithm_version(算法版本表)
|
||||
| 字段名 | 类型 | 是否为空 | 默认值 | 说明 |
|
||||
|--------|------|----------|--------|------|
|
||||
| id | BIGINT | NOT NULL | AUTO_INCREMENT | 版本ID |
|
||||
| algorithm_id | BIGINT | NOT NULL | | 关联算法ID |
|
||||
| version | VARCHAR(50) | NOT NULL | | 语义版本号 |
|
||||
| version_desc | TEXT | NULL | | 版本说明 |
|
||||
| storage_path | VARCHAR(255) | NOT NULL | | 存储路径 |
|
||||
| config_params | JSON | NULL | | 配置参数 |
|
||||
| creator | VARCHAR(50) | NOT NULL | | 创建人 |
|
||||
| create_time | DATETIME | NOT NULL | CURRENT_TIMESTAMP | 创建时间 |
|
||||
| status | TINYINT | NOT NULL | 0 | 状态(1发布 0开发 -1废弃) |
|
||||
|
||||
### 1.3 algorithm_dependency(算法依赖表)
|
||||
| 字段名 | 类型 | 是否为空 | 默认值 | 说明 |
|
||||
|--------|------|----------|--------|------|
|
||||
| id | BIGINT | NOT NULL | AUTO_INCREMENT | 依赖ID |
|
||||
| algorithm_id | BIGINT | NOT NULL | | 关联算法ID |
|
||||
| version_id | BIGINT | NOT NULL | | 关联版本ID |
|
||||
| dependency_type | VARCHAR(50) | NOT NULL | | 依赖类型 |
|
||||
| dep_name | VARCHAR(100) | NOT NULL | | 依赖名称 |
|
||||
| dep_version | VARCHAR(50) | NOT NULL | | 依赖版本 |
|
||||
| create_time | DATETIME | NULL | CURRENT_TIMESTAMP | 创建时间 |
|
412
lib/数据库存档文件.md
Normal file
412
lib/数据库存档文件.md
Normal file
@ -0,0 +1,412 @@
|
||||
### 零、数据库测试表(test_simple)
|
||||
|
||||
#### 1.基本信息
|
||||
|
||||
所属模块:仅供创建数据库时,测试是否连接成功
|
||||
|
||||
负责人:宁欢
|
||||
|
||||
创建时间:2025-05-13
|
||||
|
||||
#### 2.表结构
|
||||
|
||||
| 序号 | 字段名 | 中文名称 | 数据类型 |
|
||||
| ---- | ---------- | -------------- | ------------- |
|
||||
| 1 | id | id(唯一主键) | Int |
|
||||
| 2 | name | 名称 | VARCHAR(255) |
|
||||
| 3 | created_at | 创建时间 | LocalDateTime |
|
||||
|
||||
#### 3.SQL脚本
|
||||
|
||||
```
|
||||
-- 创建极简测试表
|
||||
CREATE TABLE IF NOT EXISTS `test_simple` (
|
||||
`id` INT PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` VARCHAR(20) NOT NULL,
|
||||
`created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
|
||||
-- 插入测试数据
|
||||
INSERT INTO `test_simple` (`name`) VALUES ('测试数据');
|
||||
|
||||
-- 查询验证
|
||||
SELECT * FROM `test_simple`;
|
||||
```
|
||||
|
||||
#### 4.变更记录
|
||||
|
||||
| 版本 | 变更时间 | 变更人 | 变更内容 |
|
||||
| ---- | ---------- | ------ | -------- |
|
||||
| v1.0 | 2025-05-13 | nh | 初始创建 |
|
||||
|
||||
### 一、模型信息表(model_info)
|
||||
|
||||
#### 1.基本信息
|
||||
|
||||
所属模块:智能应用服务管理
|
||||
|
||||
负责人:宁欢
|
||||
|
||||
创建时间: 2025-05-14
|
||||
|
||||
#### 2.表结构
|
||||
|
||||
| 序号 | 数据表名 | 中文名称 | 数据类型 |
|
||||
| ---- | ---------- | ------------------ | ------------ |
|
||||
| 1 | id | 模型id(唯一主键) | Long |
|
||||
| 2 | model_name | 模型名称 | VARCHAR(255) |
|
||||
|
||||
#### 3.SQL脚本
|
||||
|
||||
```
|
||||
CREATE TABLE model_info (
|
||||
id BIGINT PRIMARY KEY COMMENT '模型id(唯一主键)',
|
||||
model_name VARCHAR(255) COMMENT '模型名称'
|
||||
);
|
||||
|
||||
|
||||
-- 1. 删除现有主键约束
|
||||
ALTER TABLE model_info DROP CONSTRAINT IF EXISTS model_info_pkey;
|
||||
-- 2. 创建序列(如果不存在)
|
||||
CREATE SEQUENCE IF NOT EXISTS model_info_id_seq;
|
||||
-- 3. 将 id 字段设置为使用序列自增
|
||||
ALTER TABLE model_info
|
||||
ALTER COLUMN id SET DEFAULT nextval('model_info_id_seq');
|
||||
-- 4. 重新添加主键约束
|
||||
ALTER TABLE model_info ADD PRIMARY KEY (id);
|
||||
-- 5. 将序列的当前值设置为表中现有最大 id 值 +1(确保不自增冲突)
|
||||
SELECT setval('model_info_id_seq', COALESCE((SELECT MAX(id)+1 FROM model_info), 1), false);
|
||||
```
|
||||
|
||||
#### 4.变更记录
|
||||
|
||||
| 版本 | 变更时间 | 变更人 | 变更内容 |
|
||||
| ---- | ---------- | ------ | ---------------------- |
|
||||
| v1.0 | 2025-05-13 | 宁欢 | 初始创建 |
|
||||
| v1.1 | 2025-05-20 | 宁欢 | 将主键约束条件改为自增 |
|
||||
|
||||
### 二、日志表(model_log)
|
||||
|
||||
#### 1.基本信息
|
||||
|
||||
所属模块:智能应用服务管理
|
||||
|
||||
负责人:宁欢
|
||||
|
||||
创建时间:2025-05-14
|
||||
|
||||
#### 2.表结构
|
||||
|
||||
| 序号 | 数据表名 | 中文名称 | 数据类型 |
|
||||
| ---- | ---------------- | --------------------- | ------------- |
|
||||
| 1 | id | 日志id(唯一主键) | Long |
|
||||
| 2 | model_version_id | 关联模型版本id | Long |
|
||||
| 3 | log_type | 日志类型(1,2,3...) | Int |
|
||||
| 4 | log_path | 日志存储路径 | VARCHAR(255) |
|
||||
| 5 | log_time | 日志生成时间 | LocalDateTime |
|
||||
|
||||
#### 3.SQL脚本
|
||||
|
||||
```
|
||||
-- 创建model_log表
|
||||
CREATE TABLE model_log (
|
||||
id BIGINT PRIMARY KEY COMMENT '日志id(唯一主键)',
|
||||
model_id BIGINT COMMENT '关联模型id',
|
||||
log_type INT COMMENT '日志类型(1,2,3...)',
|
||||
log_path VARCHAR(255) COMMENT '日志存储路径',
|
||||
log_time TIMESTAMP COMMENT '日志生成时间'
|
||||
);
|
||||
```
|
||||
|
||||
#### 4.变更记录
|
||||
|
||||
| 版本 | 变更时间 | 变更人 | 变更内容 |
|
||||
| ---- | ---------- | ------ | ------------------------------------------ |
|
||||
| v1.0 | 2025-05-14 | 宁欢 | 初始创建 |
|
||||
| v2.0 | 2025-06-30 | 宁欢 | 模型日志修改成绑定模型版本id,而不是模型id |
|
||||
|
||||
### 三、模型评估记录表(model_evaluation)
|
||||
|
||||
#### 1.基本信息
|
||||
|
||||
所属模块:智能应用服务管理
|
||||
|
||||
负责人:宁欢
|
||||
|
||||
创建时间:2025-05-14
|
||||
|
||||
#### 2.表结构
|
||||
|
||||
| 序号 | 数据表名 | 中文名称 | 数据类型 |
|
||||
| ---- | ----------------- | ---------------------- | ------------- |
|
||||
| 1 | id | 评估记录id(唯一主键) | Long |
|
||||
| 2 | model_id | 关联模型id | Long |
|
||||
| 3 | evaluation_time | 评估时间 | LocalDateTime |
|
||||
| 4 | evaluation_result | 评估结果 | VARCHAR(255) |
|
||||
| 5 | operator | 评估操作人员 | VARCHAR(255) |
|
||||
|
||||
#### 3.SQL脚本
|
||||
|
||||
```
|
||||
-- 创建model_evaluation表
|
||||
CREATE TABLE model_evaluation (
|
||||
id BIGINT PRIMARY KEY COMMENT '评估记录id(唯一主键)',
|
||||
model_id BIGINT COMMENT '关联模型id',
|
||||
evaluation_time TIMESTAMP COMMENT '评估时间',
|
||||
evaluation_result VARCHAR(255) COMMENT '评估结果',
|
||||
operator VARCHAR(255) COMMENT '评估操作人员'
|
||||
);
|
||||
```
|
||||
|
||||
#### 4.变更记录
|
||||
|
||||
| 版本 | 变更时间 | 变更人 | 变更内容 |
|
||||
| ---- | ---------- | ------ | -------- |
|
||||
| v1.0 | 2025-05-14 | 宁欢 | 初始创建 |
|
||||
|
||||
### 四、模型版本信息(model_version)
|
||||
|
||||
#### 1.基本信息
|
||||
|
||||
所属模块:智能应用服务管理
|
||||
|
||||
负责人:宁欢
|
||||
|
||||
创建时间:2025-05-14
|
||||
|
||||
#### 2.表结构
|
||||
|
||||
| 序号 | 数据表名 | 中文名称 | 数据类型 |
|
||||
| ---- | --------------------- | ---------------------------------- | ------------- |
|
||||
| 1 | id | 版本信息表id(唯一主键) | Long |
|
||||
| 2 | model_id | 关联模型id | Long |
|
||||
| 3 | version | 模型版本 | VARCHAR(255) |
|
||||
| 4 | dataset_id | 数据集id | Int |
|
||||
| 5 | model_config | 模型配置信息 | VARCHAR(255) |
|
||||
| 6 | model_path | 模型存储路径 | VARCHAR(255) |
|
||||
| 7 | status | 模型状态(1代表上线,0代表不上线) | Int |
|
||||
| 8 | create_time | 创建时间 | LocalDateTime |
|
||||
| 9 | update_time | 更新时间 | LocalDateTime |
|
||||
| 10 | model_size | 模型大小 | Integer |
|
||||
| 11 | data_pre_handle_file | 数据预处理文件存储路径 | VARCHAR(255) |
|
||||
| 12 | model_super_args | 模型超参数 | VARCHAR(255) |
|
||||
| 13 | model_args_size | 模型参数量 | VARCHAR(255) |
|
||||
| 14 | model_source_code_url | 模型源代码路径 | VARCHAR(255) |
|
||||
| 15 | model_file | 模型文件存储路径 | VARCHAR(255) |
|
||||
| 16 | model_design_document | 模型设计文档存储路径 | VARCHAR(255) |
|
||||
| 17 | life_cycle | 模型生命周期 | VARCHAR(255) |
|
||||
|
||||
#### 3.SQL脚本
|
||||
|
||||
```
|
||||
-- 创建model_version表
|
||||
CREATE TABLE model_version (
|
||||
id BIGINT PRIMARY KEY COMMENT '版本信息表id(唯一主键)',
|
||||
model_id BIGINT COMMENT '关联模型id',
|
||||
version VARCHAR(255) COMMENT '模型版本',
|
||||
dataset_id INT COMMENT '数据集id',
|
||||
model_config VARCHAR(255) COMMENT '模型配置信息',
|
||||
model_path VARCHAR(255) COMMENT '模型存储路径',
|
||||
status INT COMMENT '模型状态(1代表上线,0代表不上线)',
|
||||
create_time TIMESTAMP COMMENT '创建时间'
|
||||
);
|
||||
|
||||
-- 添加更新时间字段,类型为TIMESTAMP与Java的LocalDateTime对应
|
||||
ALTER TABLE model_version ADD COLUMN update_time TIMESTAMP COMMENT '更新时间';
|
||||
-- 添加模型大小字段,类型用INT与Java的Integer对应
|
||||
ALTER TABLE model_version ADD COLUMN model_size INT COMMENT '模型大小';
|
||||
-- 数据预处理文件存储路径,用VARCHAR存储路径信息
|
||||
ALTER TABLE model_version ADD COLUMN data_pre_handle_file VARCHAR(255) COMMENT '数据预处理文件存储路径';
|
||||
-- 模型超参数,用VARCHAR存储文本信息
|
||||
ALTER TABLE model_version ADD COLUMN model_super_args VARCHAR(255) COMMENT '模型超参数';
|
||||
-- 模型参数量,用VARCHAR存储文本格式的数量信息
|
||||
ALTER TABLE model_version ADD COLUMN model_args_size VARCHAR(255) COMMENT '模型参数量';
|
||||
-- 模型源代码路径,用VARCHAR存储路径信息
|
||||
ALTER TABLE model_version ADD COLUMN model_source_code_url VARCHAR(255) COMMENT '模型源代码路径';
|
||||
-- 模型文件存储路径,用VARCHAR存储路径信息
|
||||
ALTER TABLE model_version ADD COLUMN model_file VARCHAR(255) COMMENT '模型文件存储路径';
|
||||
-- 模型设计文档存储路径,用VARCHAR存储路径信息
|
||||
ALTER TABLE model_version ADD COLUMN model_design_document VARCHAR(255) COMMENT '模型设计文档存储路径';
|
||||
-- 模型生命周期,用VARCHAR存储文本信息
|
||||
ALTER TABLE model_version ADD COLUMN life_cycle VARCHAR(255) COMMENT '模型生命周期';
|
||||
|
||||
-- 1. 删除现有主键约束
|
||||
ALTER TABLE model_version DROP CONSTRAINT IF EXISTS model_version_pkey;
|
||||
-- 2. 创建序列(如果不存在)
|
||||
CREATE SEQUENCE IF NOT EXISTS model_version_id_seq;
|
||||
-- 3. 将 id 字段设置为使用序列自增
|
||||
ALTER TABLE model_version
|
||||
ALTER COLUMN id SET DEFAULT nextval('model_version_id_seq');
|
||||
-- 4. 重新添加主键约束
|
||||
ALTER TABLE model_version ADD PRIMARY KEY (id);
|
||||
-- 5. 将序列的当前值设置为表中现有最大 id 值 +1(确保不自增冲突)
|
||||
SELECT setval('model_version_id_seq', COALESCE((SELECT MAX(id)+1 FROM model_version), 1), false);
|
||||
```
|
||||
|
||||
#### 4.变更记录
|
||||
|
||||
| 版本 | 变更时间 | 变更人 | 变更内容 |
|
||||
| ---- | ---------- | ------ | -------------------------------------------------- |
|
||||
| v1.0 | 2025-05-14 | 宁欢 | 初始创建 |
|
||||
| v1.1 | 2025-05-20 | 宁欢 | 新增了一些字段(从update_time到life_cycle共9个字段) |
|
||||
| v1.3 | 2025-05-20 | 宁欢 | 将主键约束条件改为自增 |
|
||||
|
||||
### 五、数据集表(dataset )
|
||||
|
||||
#### 1.基本信息
|
||||
|
||||
所属模块:智能应用服务管理
|
||||
|
||||
负责人:胡楷沅
|
||||
|
||||
创建时间:2025-05-13
|
||||
|
||||
#### 2.表结构
|
||||
|
||||
| 序号 | 数据表名 | 中文名称 | 数据类型 |
|
||||
| ---- | -------------- | ---------------------------------------------------- | ------------ |
|
||||
| 1 | dataset_id | 数据集id(唯一主键) | Int |
|
||||
| 2 | dataset_name | 数据集名称 | VARCHAR(255) |
|
||||
| 3 | dataset_type | 数据集类型(0 表示用户上传,1 表示来源于数据库) | Int |
|
||||
| 4 | dataset_status | 数据集状态(0 表示停用,1 表示启用) | Int |
|
||||
| 5 | ds_path | 分布式存储路径(存入分布式文件系统的路径) | VARCHAR(255) |
|
||||
| 6 | args | 过滤参数(存储为 JSON 格式对应 Map<String, String>) | JSON |
|
||||
| 7 | create_time | 创建时间 | TIMESTAMP |
|
||||
| 8 | update_time | 更新时间 | TIMESTAMP |
|
||||
|
||||
#### 3.SQL脚本
|
||||
|
||||
```
|
||||
CREATE TABLE dataset (
|
||||
dataset_id INT PRIMARY KEY AUTO_INCREMENT COMMENT '数据集ID',
|
||||
dataset_name VARCHAR(255) COMMENT '数据集名称',
|
||||
dataset_type INT COMMENT '数据集类型,0表示用户上传,1表示来源于数据库',
|
||||
dataset_status INT COMMENT '数据集状态,0表示停用,1表示启用',
|
||||
ds_path VARCHAR(255) COMMENT '分布式存储路径,存入分布式文件系统的路径',
|
||||
args JSON COMMENT '过滤参数,存储为JSON格式对应Map<String, String>',
|
||||
create_time TIMESTAMP COMMENT '创建时间',
|
||||
update_time TIMESTAMP COMMENT '更新时间'
|
||||
);
|
||||
```
|
||||
|
||||
#### 4.变更记录
|
||||
|
||||
| 版本 | 变更时间 | 变更人 | 变更内容 |
|
||||
| ---- | ---------- | ------ | -------- |
|
||||
| v1.0 | 2025-05-13 | 胡楷沅 | 初始创建 |
|
||||
|
||||
### 六、GPU资源表(gpu_resource)
|
||||
|
||||
#### 1.基本信息
|
||||
|
||||
所属模块:智能应用服务管理
|
||||
|
||||
负责人:杜冲
|
||||
|
||||
创建时间:2025-05-14
|
||||
|
||||
#### 2.表结构
|
||||
|
||||
| 字段名 | 数据类型 | 约束 | 字段描述 |
|
||||
| :-----------: | :---------: | :--------: | :-------------------: |
|
||||
| GPUId | BIGINT | 主键,自增 | GPU的ID,全局唯一标识 |
|
||||
| GPUModel | VARCHAR(64) | NOT NULL | GPU的型号 |
|
||||
| GPUMemorySize | INT | NOT NULL | GPU内存大小 |
|
||||
| Ip | VARCHAR(15) | NOT NULL | GPU所在ip |
|
||||
| CreatedTime | DATETIME | NULL | GPU添加时间,可为空 |
|
||||
|
||||
#### 3.SQL脚本
|
||||
|
||||
```
|
||||
-- 创建gpu_resource表
|
||||
CREATE TABLE gpu_resource (
|
||||
|
||||
GPUId BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
|
||||
|
||||
GPUModel VARCHAR(64) NOT NULL,
|
||||
|
||||
GPUMemorySize INT NOT NULL,
|
||||
|
||||
Ip VARCHAR(15) NOT NULL CHECK (Ip ~ '^\\d+\\.\\d+\\.\\d+\\.\\d+$'),
|
||||
|
||||
CreatedTime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||
);
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### 4.变更记录
|
||||
|
||||
| 版本 | 变更时间 | 变更人 | 变更内容 |
|
||||
| ---- | ---------- | ------ | -------- |
|
||||
| v1.0 | 2025-05-14 | 杜冲 | 初始创建 |
|
||||
|
||||
### 七、算法基础信息表(algorithm_info)
|
||||
|
||||
#### 1.基本信息
|
||||
|
||||
所属模块:智能应用服务管理
|
||||
|
||||
负责人:孙一城
|
||||
|
||||
创建时间:2025-05-14
|
||||
|
||||
#### 2.表结构
|
||||
|
||||
| 字段名 | 类型 | 是否为空 | 默认值 | 说明 |
|
||||
| -------------- | ------------ | -------- | --------------------------- | -------------- |
|
||||
| id | BIGINT | NOT NULL | AUTO_INCREMENT | 算法ID |
|
||||
| algorithm_name | VARCHAR(100) | NOT NULL | | 算法名称(唯一) |
|
||||
| algorithm_file | VARCHAR(255) | NOT NULL | | 算法文件路径 |
|
||||
| algorithm_type | VARCHAR(50) | NOT NULL | | 算法分类 |
|
||||
| description | TEXT | NULL | | 算法描述 |
|
||||
| created_by | VARCHAR(50) | NOT NULL | | 创建人 |
|
||||
| create_time | DATETIME | NOT NULL | CURRENT_TIMESTAMP | 创建时间 |
|
||||
| update_time | DATETIME | NOT NULL | CURRENT_TIMESTAMP ON UPDATE | 更新时间 |
|
||||
| file_size | BIGINT | NULL | | 文件大小(字节) |
|
||||
|
||||
#### 3.SQL脚本
|
||||
|
||||
```
|
||||
-- 创建算法信息表(Kingbase 兼容版)
|
||||
CREATE TABLE algorithm_info (
|
||||
id BIGSERIAL PRIMARY KEY, -- 自增主键
|
||||
algorithm_name VARCHAR(100) NOT NULL, -- 算法名称
|
||||
algorithm_file VARCHAR(255) NOT NULL, -- 算法文件路径
|
||||
algorithm_type VARCHAR(50) NOT NULL, -- 算法分类
|
||||
description TEXT, -- 算法描述
|
||||
created_by VARCHAR(50) NOT NULL, -- 创建人
|
||||
create_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- 创建时间
|
||||
update_time TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, -- 更新时间(需触发器自动更新)
|
||||
file_size BIGINT -- 文件大小(字节)
|
||||
);
|
||||
|
||||
-- 添加唯一约束
|
||||
ALTER TABLE algorithm_info ADD CONSTRAINT uk_algorithm_name UNIQUE (algorithm_name);
|
||||
|
||||
-- 这部份没有成功运行,存在问题
|
||||
-- 为 update_time 添加自动更新触发器
|
||||
CREATE OR REPLACE FUNCTION update_modified_column()
|
||||
RETURNS TRIGGER AS $$
|
||||
BEGIN
|
||||
NEW.update_time = NOW(); -- 语句以分号结尾
|
||||
RETURN NEW;
|
||||
END;
|
||||
$$ LANGUAGE plpgsql; -- 美元引号正确闭合
|
||||
|
||||
-- 创建触发器
|
||||
CREATE TRIGGER update_algorithm_info_modtime
|
||||
BEFORE UPDATE ON algorithm_info
|
||||
FOR EACH ROW EXECUTE FUNCTION update_modified_column();
|
||||
|
||||
-- 创建索引(语法与 MySQL 相同,无需修改)
|
||||
CREATE INDEX idx_algorithm_type ON algorithm_info(algorithm_type);
|
||||
CREATE INDEX idx_created_by ON algorithm_info(created_by);
|
||||
CREATE INDEX idx_create_time ON algorithm_info(create_time);
|
||||
```
|
||||
|
||||
#### 4.变更记录
|
||||
|
||||
| 版本 | 变更时间 | 变更人 | 变更内容 |
|
||||
| ---- | ---------- | ------ | -------- |
|
||||
| v1.0 | 2025-05-14 | 孙一城 | 初始创建 |
|
188
pom.xml
188
pom.xml
@ -1,35 +1,52 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>3.4.5</version>
|
||||
<version>3.1.5</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
<groupId>com.bipt</groupId>
|
||||
<artifactId>intelligent-application-orchestration-service</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>intelligent-application-orchestration-service</name>
|
||||
<description>intelligent-application-orchestration-service</description>
|
||||
<url/>
|
||||
<licenses>
|
||||
<license/>
|
||||
</licenses>
|
||||
<developers>
|
||||
<developer/>
|
||||
</developers>
|
||||
<scm>
|
||||
<connection/>
|
||||
<developerConnection/>
|
||||
<tag/>
|
||||
<url/>
|
||||
</scm>
|
||||
|
||||
<properties>
|
||||
<java.version>24</java.version>
|
||||
<java.version>17</java.version>
|
||||
<!-- 添加 Spring Cloud 版本控制 -->
|
||||
<spring-cloud.version>2022.0.4</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
<!-- 依赖管理:统一控制 Spring Cloud 和 Alibaba 版本 -->
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<!-- Spring Cloud 依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- Spring Cloud Alibaba 依赖 -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||
<version>2022.0.0.0-RC2</version> <!-- 适配 Spring Boot 3.1.x 的正确版本 -->
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring Boot 基础依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-jdbc</artifactId>
|
||||
@ -38,22 +55,136 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 数据库驱动 -->
|
||||
<dependency>
|
||||
<groupId>org.postgresql</groupId>
|
||||
<artifactId>postgresql</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.kingbase8</groupId>
|
||||
<artifactId>kingbase8</artifactId>
|
||||
<version>9.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-aop</artifactId>
|
||||
</dependency>
|
||||
<!-- 工具类依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.38</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.pagehelper</groupId>
|
||||
<artifactId>pagehelper-spring-boot-starter</artifactId>
|
||||
<version>1.4.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
<!-- Nacos 配置依赖(移除手动版本,由上方依赖管理控制) -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||
</dependency>
|
||||
<!-- Spring Boot 3.x 必须的 Bootstrap 依赖(无需版本号) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
<!-- 测试依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter-test</artifactId>
|
||||
<version>3.0.4</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>1.5.5.Final</version> <!-- 确保版本 ≥1.2.0 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
<exclusions>
|
||||
<!-- 排除 RabbitMQ 自动配置 -->
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
<version>3.5.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||
<version>3.5.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--阿里OSS依赖-->
|
||||
<dependency>
|
||||
<groupId>com.aliyun.oss</groupId>
|
||||
<artifactId>aliyun-sdk-oss</artifactId>
|
||||
<version>3.15.1</version>
|
||||
</dependency>
|
||||
<!--如果使用的是Java 9及以上的版本,则需要添加JAXB相关依赖。添加JAXB相关依赖-->
|
||||
<dependency>
|
||||
<groupId>javax.xml.bind</groupId>
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>2.3.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.activation</groupId>
|
||||
<artifactId>activation</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<!-- no more than 2.3.3-->
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jaxb</groupId>
|
||||
<artifactId>jaxb-runtime</artifactId>
|
||||
<version>2.3.3</version> <!-- 注意:版本不超过2.3.3 -->
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
@ -62,27 +193,28 @@
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- 显式指定 Java 21 编译 -->
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.38</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>1.5.5.Final</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -1,13 +1,26 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.config.IpConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@MapperScan("com.bipt.intelligentapplicationorchestrationservice.mapper")//指定扫描Mapper接口的包
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
@EnableDiscoveryClient
|
||||
@EnableConfigurationProperties(IpConfig.class)
|
||||
//@Slf4j
|
||||
public class IntelligentApplicationOrchestrationServiceApplication {
|
||||
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(IntelligentApplicationOrchestrationServiceApplication.class);
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(IntelligentApplicationOrchestrationServiceApplication.class, args);
|
||||
log.info("server started");
|
||||
}
|
||||
|
||||
}
|
||||
|
37
src/main/java/com/bipt/intelligentapplicationorchestrationservice/cache/CacheInitTask.java
vendored
Normal file
37
src/main/java/com/bipt/intelligentapplicationorchestrationservice/cache/CacheInitTask.java
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.cache;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.CacheManager;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CacheInitTask {
|
||||
|
||||
private final CacheManager cacheManager;
|
||||
|
||||
@Value("${cache.init-batch-size:500}")
|
||||
private int batchSize;
|
||||
|
||||
@Autowired
|
||||
public CacheInitTask(CacheManager cacheManager) {
|
||||
this.cacheManager = cacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 应用启动后执行全量缓存加载
|
||||
* 使用@EventListener替代@PostConstruct确保数据库连接就绪
|
||||
*/
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
public void initCacheOnStartup() {
|
||||
try {
|
||||
cacheManager.loadFullCache(batchSize);
|
||||
System.out.println("✅ 缓存全量初始化完成 | Total loaded: " + cacheManager.getCacheCount());
|
||||
} catch (Exception e) {
|
||||
System.err.println("❌ 缓存初始化失败: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
63
src/main/java/com/bipt/intelligentapplicationorchestrationservice/cache/CacheSyncTask.java
vendored
Normal file
63
src/main/java/com/bipt/intelligentapplicationorchestrationservice/cache/CacheSyncTask.java
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.cache;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.CacheManager;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
//@Slf4j
|
||||
@Component
|
||||
public class CacheSyncTask {
|
||||
private final GpuResourceDao gpuResourceDao;
|
||||
private final CacheManager cacheManager;
|
||||
private LocalDateTime lastSyncTime = LocalDateTime.MIN;
|
||||
private static final Logger log = LoggerFactory.getLogger(CacheSyncTask.class);
|
||||
|
||||
@Autowired
|
||||
public CacheSyncTask(GpuResourceDao gpuResourceDao, CacheManager cacheManager) {
|
||||
this.gpuResourceDao = gpuResourceDao;
|
||||
this.cacheManager = cacheManager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时同步缓存(默认每10分钟)
|
||||
*/
|
||||
@Scheduled(fixedDelayString = "${cache.sync-interval:600000}")
|
||||
public void syncCache() {
|
||||
try {
|
||||
LocalDateTime currentSyncTime = LocalDateTime.now();
|
||||
log.info("🔄 开始缓存同步 | 时间范围: {} - {}", lastSyncTime, currentSyncTime);
|
||||
|
||||
// 1. 查询增量数据
|
||||
List<GpuResource> modifiedGpus = gpuResourceDao.findModifiedSince(lastSyncTime);
|
||||
if (modifiedGpus.isEmpty()) {
|
||||
log.info("✅ 无数据变更,跳过本次同步");
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 处理数据变更
|
||||
modifiedGpus.forEach(gpu -> {
|
||||
if (gpu.getIsDeleted()) {
|
||||
cacheManager.evictCache(gpu.getGPUId());
|
||||
log.debug("🗑️ 删除缓存 | GPU ID: {}", gpu.getGPUId());
|
||||
} else {
|
||||
cacheManager.refreshCache(gpu.getGPUId());
|
||||
log.debug("🔄 更新缓存 | GPU ID: {}", gpu.getGPUId());
|
||||
}
|
||||
});
|
||||
|
||||
// 3. 更新同步时间戳
|
||||
lastSyncTime = currentSyncTime;
|
||||
log.info("✅ 缓存同步完成 | 共处理 {} 条记录", modifiedGpus.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("❌ 缓存同步失败: {}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.CacheManager;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterReturning;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.support.TransactionSynchronization;
|
||||
import org.springframework.transaction.support.TransactionSynchronizationManager;
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
public class CacheAopConfig {
|
||||
private final CacheManager cacheManager;
|
||||
|
||||
public CacheAopConfig(CacheManager cacheManager) {
|
||||
this.cacheManager = cacheManager;
|
||||
}
|
||||
|
||||
// 定义写操作切点
|
||||
@Pointcut("@annotation(org.springframework.transaction.annotation.Transactional) && " +
|
||||
"execution(* com.bipt.intelligentapplicationorchestrationservice.service..*.*(..))")
|
||||
public void writeOperation() {}
|
||||
|
||||
// 事务提交后操作
|
||||
@AfterReturning(pointcut = "writeOperation()", returning = "result")
|
||||
public void afterWriteCommit(JoinPoint joinPoint, Object result) {
|
||||
TransactionSynchronizationManager.registerSynchronization(
|
||||
new TransactionSynchronization() {
|
||||
@Override
|
||||
public void afterCommit() {
|
||||
processCacheUpdate(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void processCacheUpdate(Object result) {
|
||||
if (result instanceof GpuResource) {
|
||||
GpuResource gpu = (GpuResource) result;
|
||||
cacheManager.refreshCache(gpu.getGPUId());
|
||||
} else if (result instanceof Long) { // 处理删除操作返回ID的情况
|
||||
cacheManager.evictCache((Long) result);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "available")
|
||||
public class IpConfig {
|
||||
private List<String> ips;
|
||||
|
||||
public List<String> getIps() {
|
||||
return ips;
|
||||
}
|
||||
|
||||
public void setIps(String ips) {
|
||||
this.ips = Arrays.asList(ips.split(","));
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.properties.AliOssProperties;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.util.AliOssUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/*
|
||||
* 配置类,用于创建阿里云文件上传工具类对象
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class OssConfiguration {
|
||||
private final AliOssProperties aliOssProperties;
|
||||
public OssConfiguration(AliOssProperties aliOssProperties) {
|
||||
this.aliOssProperties = aliOssProperties;
|
||||
}
|
||||
@Bean
|
||||
public AliOssUtil aliOssUtil(){
|
||||
log.info("开始创建阿里云文件上传工具类对象...");
|
||||
return new AliOssUtil(
|
||||
aliOssProperties.getEndpoint(),
|
||||
aliOssProperties.getAccessKeyId(),
|
||||
aliOssProperties.getAccessKeySecret(),
|
||||
aliOssProperties.getBucketName());
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import io.lettuce.core.ClientOptions;
|
||||
import io.lettuce.core.SocketOptions;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.RedisPassword;
|
||||
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
@Value("${spring.data.redis.host}")
|
||||
private String redisHost;
|
||||
|
||||
@Value("${spring.data.redis.port}")
|
||||
private int redisPort;
|
||||
|
||||
@Value("${spring.data.redis.username}")
|
||||
private String redisUsername;
|
||||
|
||||
@Value("${spring.data.redis.password}")
|
||||
private String redisPassword;
|
||||
|
||||
@Value("${spring.data.redis.ssl:false}")
|
||||
private boolean useSsl;
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate() {
|
||||
return new RestTemplate();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisConnectionFactory redisConnectionFactory() {
|
||||
// 1. 创建 SocketOptions
|
||||
SocketOptions socketOptions = SocketOptions.builder()
|
||||
.connectTimeout(Duration.ofSeconds(15)) // 连接超时
|
||||
.keepAlive(true) // 启用 TCP Keep-Alive
|
||||
.build();
|
||||
|
||||
// 2. 构建 ClientOptions
|
||||
ClientOptions clientOptions = ClientOptions.builder()
|
||||
.socketOptions(socketOptions)
|
||||
.autoReconnect(true) // 启用自动重连
|
||||
.build();
|
||||
|
||||
// 3. 集成到 Lettuce 配置
|
||||
LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
|
||||
.clientOptions(clientOptions) // 注入 ClientOptions
|
||||
.commandTimeout(Duration.ofSeconds(30)) // 全局命令超时
|
||||
.build();
|
||||
|
||||
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
|
||||
config.setHostName(redisHost);
|
||||
config.setPort(redisPort);
|
||||
config.setUsername(redisUsername); // Redis 6.0+ 支持用户名
|
||||
config.setPassword(RedisPassword.of(redisPassword));
|
||||
|
||||
return new LettuceConnectionFactory(config, clientConfig);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate() {
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
Logger log = (Logger) LoggerFactory.getLogger(RedisConfig.class);
|
||||
log.info("开始创建redis模板对象...");
|
||||
template.setConnectionFactory(redisConnectionFactory());
|
||||
|
||||
// 创建自定义的ObjectMapper并注册JavaTimeModule
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
// 禁用将日期序列化为时间戳
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
// 注册Java 8日期时间模块
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
|
||||
// 使用自定义的ObjectMapper创建JSON序列化器
|
||||
GenericJackson2JsonRedisSerializer jsonSerializer =
|
||||
new GenericJackson2JsonRedisSerializer(mapper);
|
||||
|
||||
// 设置键和值的序列化方式
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(jsonSerializer);
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
template.setHashValueSerializer(jsonSerializer);
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class RedisConfiguration {
|
||||
@Bean
|
||||
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){
|
||||
log.info("开始创建redis模板对象...");
|
||||
RedisTemplate redisTemplate = new RedisTemplate();
|
||||
//设置redis的连接工厂对象
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
//设置redis key的序列化器
|
||||
redisTemplate.setKeySerializer(new StringRedisSerializer());
|
||||
|
||||
return redisTemplate;
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import io.swagger.v3.oas.models.servers.Server;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class WebMvcConfiguration implements WebMvcConfigurer {
|
||||
|
||||
/**
|
||||
* 配置OpenAPI信息
|
||||
*/
|
||||
@Bean
|
||||
public OpenAPI customOpenAPI() {
|
||||
// 设置服务器信息(可选)
|
||||
List<Server> servers = new ArrayList<>();
|
||||
servers.add(new Server().url("/").description("本地服务器"));
|
||||
|
||||
return new OpenAPI()
|
||||
.info(new Info()
|
||||
.title("智能应用服务管理")
|
||||
.version("2.0")
|
||||
.description("智能应用服务管理接口文档"))
|
||||
.servers(servers);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.constant;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ConfigConstants {
|
||||
@Value("${model.deploy.port:8080}")
|
||||
public int MODEL_PORT;
|
||||
|
||||
@Value("${model.deploy.url-template:http://%s:%d/model/%s/%s}")
|
||||
public String URL_TEMPLATE;
|
||||
|
||||
@Value("${model.deploy.script-timeout:300}")
|
||||
public int SCRIPT_TIMEOUT_SECONDS;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.constant;
|
||||
|
||||
public class MessageConstant {
|
||||
public static final String UNKNOWN_ERROR = "未知错误";
|
||||
public static final String ALREADY_EXISTS = "已存在";
|
||||
|
||||
//生命周期相关常量
|
||||
public static final String LifeCycle_No_Exist = "生命周期不存在";
|
||||
public static final String LifeCycle_Undefined = "生命周期未定义";
|
||||
public static final String ERROR_DEPLOYED_TO_DESIGNING = "已部署的模型不能直接调整成设计,需先下线再设计";
|
||||
public static final String ERROR_ABANDONED_CANNOT_UPDATE = "已废弃的模型只能查看信息,不能更新生命周期";
|
||||
public static final String ERROR_TRAINING_INVALID_TRANSITION = "训练中的模型只能调整成设计和评估";
|
||||
public static final String LIFECYCLE_UPDATE_FAILURE = "更新模型生命周期失败";
|
||||
public static final String LIFECYCLE_UPDATE_SUCCESS = "生命周期更新成功";
|
||||
|
||||
//文件上传常量
|
||||
public static final String UPLOAD_FAILURE = "上传文件失败";
|
||||
public static final String FILE_EMPTY= "文件为空";
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.constant;
|
||||
|
||||
/**
|
||||
* 状态常量,启用或者禁用
|
||||
* @author hky
|
||||
*/
|
||||
public class StatusConstant {
|
||||
//启用
|
||||
public static final Integer ENABLE = 1;
|
||||
|
||||
//禁用
|
||||
public static final Integer DISABLE = 0;
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.AlgorithmInfo;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.AlgorithmInfoService;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
@Tag(name ="算法创建相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/api/algorithm")
|
||||
@Slf4j
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
public class AlgorithmInfoController {
|
||||
|
||||
@Autowired
|
||||
private AlgorithmInfoService algorithmInfoService;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper;
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<AlgorithmInfo> getById(@PathVariable Long id) {
|
||||
AlgorithmInfo algorithmInfo = algorithmInfoService.getById(id);
|
||||
return algorithmInfo != null ?
|
||||
ResponseEntity.ok(algorithmInfo) :
|
||||
ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
@GetMapping("/name/{algorithmName}")
|
||||
public ResponseEntity<AlgorithmInfo> getByName(@PathVariable String algorithmName) {
|
||||
AlgorithmInfo algorithmInfo = algorithmInfoService.getByName(algorithmName);
|
||||
return algorithmInfo != null ?
|
||||
ResponseEntity.ok(algorithmInfo) :
|
||||
ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
@GetMapping("/type/{algorithmType}")
|
||||
public ResponseEntity<List<AlgorithmInfo>> getByType(@PathVariable String algorithmType) {
|
||||
List<AlgorithmInfo> algorithmInfos = algorithmInfoService.getByType(algorithmType);
|
||||
return ResponseEntity.ok(algorithmInfos);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<String> update(@PathVariable Long id, @RequestBody AlgorithmInfo algorithmInfo) {
|
||||
algorithmInfo.setId(id);
|
||||
if (!algorithmInfoService.validateAlgorithmInfo(algorithmInfo)) {
|
||||
return ResponseEntity.badRequest().body("Invalid algorithm information");
|
||||
}
|
||||
|
||||
boolean success = algorithmInfoService.update(algorithmInfo);
|
||||
return success ?
|
||||
ResponseEntity.ok("Update successful") :
|
||||
ResponseEntity.badRequest().body("Update failed");
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<String> delete(@PathVariable Long id) {
|
||||
boolean success = algorithmInfoService.delete(id);
|
||||
return success ?
|
||||
ResponseEntity.ok("Delete successful") :
|
||||
ResponseEntity.badRequest().body("Delete failed");
|
||||
}
|
||||
|
||||
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@Operation(summary ="算法创建")
|
||||
public OptResult save(@RequestParam("algorithm") String algorithmJson,
|
||||
@RequestPart(value = "algorithmFile") MultipartFile file) {
|
||||
try {
|
||||
AlgorithmInfo algorithmInfo = objectMapper.readValue(algorithmJson, AlgorithmInfo.class);
|
||||
log.info("新增算法: {}, 文件: {}", algorithmInfo, (file != null ? file.getOriginalFilename() : "无文件"));
|
||||
algorithmInfoService.save(algorithmInfo, file);
|
||||
return OptResult.success("算法创建成功");
|
||||
} catch (IOException e) {
|
||||
log.error("JSON转换失败", e);
|
||||
return OptResult.error("新增算法失败: " + e.getMessage());
|
||||
} catch (Exception e) {
|
||||
log.error("新增算法失败", e);
|
||||
return OptResult.error("新增算法失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据算法名称模糊查询算法信息
|
||||
* @param keyword 模糊查询关键词
|
||||
* @return 符合条件的算法信息列表
|
||||
*/
|
||||
@GetMapping("/search")
|
||||
public ResponseEntity<List<AlgorithmInfo>> searchByName(@RequestParam String keyword) {
|
||||
List<AlgorithmInfo> algorithmInfos = algorithmInfoService.getByNameLike(keyword);
|
||||
return ResponseEntity.ok(algorithmInfos);
|
||||
}
|
||||
/**
|
||||
* 算法运行
|
||||
*/
|
||||
@PostMapping("/run/{id}")
|
||||
@Operation(summary = "运行")
|
||||
public OptResult run(@PathVariable Long id,@RequestBody String param){
|
||||
log.info("运行",id);
|
||||
String result = algorithmInfoService.run(id,param);
|
||||
return OptResult.success("运行成功"+result);
|
||||
}
|
||||
/**
|
||||
* 前端列表返回算法名称
|
||||
*/
|
||||
@GetMapping("/names")
|
||||
@Operation(summary = "列表返回算法名称")
|
||||
public List<String> getNames(){
|
||||
return algorithmInfoService.getAllNames();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.MessageConstant;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.util.AliOssUtil;
|
||||
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.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/common")
|
||||
@Tag(name = "通用接口")
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
public class CommonController {
|
||||
@Autowired
|
||||
private AliOssUtil aliOssUtil;
|
||||
// 默认上传的文件夹
|
||||
private static final String DEFAULT_FOLDER= "File/";
|
||||
|
||||
/**
|
||||
* 文件上传
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "文件上传")
|
||||
@PostMapping("/upload")
|
||||
public OptResult uploadFile(@RequestParam("file") MultipartFile file) throws IOException {
|
||||
log.info("收到上传请求");
|
||||
if (file.isEmpty()){
|
||||
return OptResult.error(MessageConstant.FILE_EMPTY);
|
||||
}
|
||||
try {
|
||||
// 1.生成唯一文件名
|
||||
String originalFilename = file.getOriginalFilename(); // 原始文件名
|
||||
log.info("原始文件名:{}", originalFilename);
|
||||
String fileSuffix = originalFilename.substring(originalFilename.lastIndexOf(".")); // 文件后缀
|
||||
log.info("文件后缀:{}", fileSuffix);
|
||||
String fileName = UUID.randomUUID().toString() + fileSuffix; // 唯一文件名
|
||||
log.info("唯一文件名:{}", fileName);
|
||||
// 2.构建oss存储路径
|
||||
String objectName = DEFAULT_FOLDER + fileName;
|
||||
// 3.调用工具类上传文件
|
||||
String fileUrl = aliOssUtil.upload(file.getInputStream(), objectName);
|
||||
// 4.返回文件URL
|
||||
return OptResult.success(fileUrl);
|
||||
} catch (Exception e) {
|
||||
log.error(MessageConstant.UPLOAD_FAILURE +":{}", e.getMessage(), e);
|
||||
return OptResult.error(MessageConstant.UPLOAD_FAILURE);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,121 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.DatasetService;
|
||||
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.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
@Tag(name ="数据集相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/dataset")
|
||||
@Slf4j
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
public class DatasetController {
|
||||
@Autowired
|
||||
private DatasetService datasetService;
|
||||
|
||||
/**
|
||||
* 新增数据集(整合文件上传)
|
||||
* @param datasetDTO
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "新增数据集")
|
||||
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public OptResult save(
|
||||
@ModelAttribute("dataset") DatasetDTO datasetDTO,
|
||||
@RequestPart(value = "file", required = false) MultipartFile file) {
|
||||
log.info("新增数据集: {}, 文件: {}", datasetDTO, (file != null ? file.getOriginalFilename() : "无文件"));
|
||||
try {
|
||||
datasetService.save(datasetDTO, file);
|
||||
return OptResult.success();
|
||||
} catch (Exception e) {
|
||||
log.error("新增数据集失败", e);
|
||||
return OptResult.error("新增数据集失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param dataSetPageQueryDTO
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary ="分页查询")
|
||||
@GetMapping("/page")
|
||||
public OptResult<PageResult> page(DatasetPageQueryDTO dataSetPageQueryDTO) {
|
||||
log.info("数据集分页查询:{}", dataSetPageQueryDTO);
|
||||
PageResult pageResult = datasetService.pageQuery(dataSetPageQueryDTO);
|
||||
return OptResult.success(pageResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据集
|
||||
* @param datasetDTO
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary ="修改数据集")
|
||||
@PutMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
public OptResult update(@ModelAttribute("dataset") DatasetDTO datasetDTO,
|
||||
@RequestPart(value = "file", required = false) MultipartFile file){
|
||||
log.info("修改数据集{}, 文件: {}", datasetDTO, (file != null ? file.getOriginalFilename() : "无文件"));
|
||||
datasetService.update(datasetDTO,file);
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除数据集
|
||||
* @param datasetIds 数据集ID列表
|
||||
* @return 操作结果
|
||||
*/
|
||||
@Operation(summary ="删除数据集")
|
||||
@DeleteMapping
|
||||
public OptResult<String> deleteBatch(@RequestBody List<Long> datasetIds) {
|
||||
log.info("批量删除数据集,ID列表:{}", datasetIds);
|
||||
datasetService.deleteBatch(datasetIds);
|
||||
return OptResult.success("批量删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载数据集
|
||||
* @param datasetId 数据集ID
|
||||
* @return 数据集文件
|
||||
*/
|
||||
@Operation(summary = "下载数据集")
|
||||
@GetMapping("/download/{datasetId}")
|
||||
public ResponseEntity<byte[]> downloadDataset(@PathVariable Long datasetId) {
|
||||
log.info("下载数据集,ID:{}", datasetId);
|
||||
try {
|
||||
// TODO: 调用分布式存储系统的接口获取数据集文件的输入流
|
||||
InputStream inputStream = datasetService.downloadDataset(datasetId);
|
||||
if (inputStream == null) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
byte[] fileBytes = inputStream.readAllBytes();
|
||||
inputStream.close();
|
||||
|
||||
// 设置响应头
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
||||
headers.setContentDispositionFormData("attachment", "dataset_" + datasetId + ".zip");
|
||||
|
||||
return new ResponseEntity<>(fileBytes, headers, HttpStatus.OK);
|
||||
} catch (IOException e) {
|
||||
log.error("下载数据集失败", e);
|
||||
return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ModelLogVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.EvaluationService;
|
||||
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.*;
|
||||
|
||||
@Tag(name = "模型评估相关接口")
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
@RestController
|
||||
@RequestMapping("/evaluation")
|
||||
@Slf4j
|
||||
public class EvaluationController {
|
||||
@Autowired
|
||||
private EvaluationService evaluationService;
|
||||
|
||||
/**
|
||||
* 获取日志详情
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "模型日志信息显示")
|
||||
@GetMapping("/detail")
|
||||
public OptResult detail(Long id){
|
||||
log.info("模型日志信息显示id:{}", id);
|
||||
ModelLogVO modelLogVO = evaluationService.detail(id);
|
||||
return OptResult.success(modelLogVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型评估状态,评估通过则上线(1.上线,0.下线)
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "模型评估接口")
|
||||
@PutMapping("/evaluate")
|
||||
public OptResult evaluate(Long id, Integer status){
|
||||
log.info("模型上线状态修改:id:{}, status:{}", id, status);
|
||||
evaluationService.startOrStop(id, status);
|
||||
return OptResult.success();
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuCreateDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuResponseDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuUpdateDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ResponseVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.GpuManageService;
|
||||
import jakarta.validation.Valid;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/gpu")
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
public class GpuResourceController {
|
||||
@Autowired
|
||||
private GpuManageService gpuManageService;
|
||||
@PostMapping(value = "/add", produces = "application/json")
|
||||
public ResponseVO addGpu(@Valid @RequestBody GpuCreateDTO dto){
|
||||
return gpuManageService.createGpuResource(dto);
|
||||
}
|
||||
@DeleteMapping("/{gpuId}")
|
||||
public ResponseVO removeGpu(@PathVariable("gpuId") Long gpuId){
|
||||
return gpuManageService.deleteGpuResource(gpuId);
|
||||
}
|
||||
@PutMapping("/{gpuId}")
|
||||
public void updateGpuResource(
|
||||
@PathVariable Long gpuId,
|
||||
@Valid @RequestBody GpuUpdateDTO dto){
|
||||
dto.setGPUId(gpuId);
|
||||
gpuManageService.updateGpuResource(dto);
|
||||
}
|
||||
@GetMapping("/search")
|
||||
public ResponseVO<List<GpuResponseDTO>> searchGpuResources(
|
||||
@RequestParam(required = false) String model,
|
||||
@RequestParam(required = false) Integer memorySize,
|
||||
@RequestParam(required = false) String ip){
|
||||
List<GpuResponseDTO> resources = gpuManageService.searchByCriteria(model, memorySize,ip);
|
||||
return ResponseVO.success(resources);
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.MessageConstant;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.ModelService;
|
||||
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.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/model")
|
||||
@Tag(name = "模型部分相关接口")
|
||||
@CrossOrigin(origins = "http://localhost:3000") // 生产环境指定具体域名
|
||||
public class ModelController {
|
||||
@Autowired
|
||||
private ModelService modelService;
|
||||
@Operation(summary = "创建模型")
|
||||
@PostMapping("/createModel")
|
||||
public OptResult creatModel(@RequestBody ModelDTO dto){
|
||||
log.info("创建模型");
|
||||
modelService.createModel(dto);
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "新增模型版本")
|
||||
@PostMapping("/createModelVersion")
|
||||
public OptResult createModelVersion(@RequestBody ModelDTO dto){
|
||||
log.info("新增模型版本");
|
||||
modelService.createModelVersion(dto);
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "查询模型列表")
|
||||
@GetMapping("list")
|
||||
public OptResult list(){
|
||||
log.info("查询模型列表");
|
||||
List<ModelVO> modelVOList = modelService.list();
|
||||
return OptResult.success(modelVOList);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询模型详情")
|
||||
@GetMapping("detail")
|
||||
public OptResult detail(Long id){
|
||||
log.info("查询模型详情");
|
||||
ModelVersion modelVersion = modelService.detail(id);
|
||||
return OptResult.success(modelVersion);
|
||||
}
|
||||
|
||||
@Operation(summary = "模型更新")
|
||||
@PutMapping("/updateModel/{id}")
|
||||
public OptResult updateModel(@PathVariable("id") Long id, @RequestBody ModelVersionDTO dto) {
|
||||
log.info("模型更新,id: {}", id);
|
||||
dto.setId(id);
|
||||
modelService.updateModel(dto);
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Operation(summary = "模型版本删除")
|
||||
@DeleteMapping("/deleteModelVersion")
|
||||
public OptResult deleteModelVersion(Long id){
|
||||
log.info("模型版本删除");
|
||||
modelService.deleteModelVersion(id);
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "更新生命周期")
|
||||
@PutMapping("/updateLifeCycle")
|
||||
public OptResult updateLifeCycle(@RequestParam Long id, @RequestParam String lifeCycle){
|
||||
log.info("更新生命周期");
|
||||
try {
|
||||
modelService.updateLifeCycle(id,lifeCycle);
|
||||
return OptResult.success(MessageConstant.LIFECYCLE_UPDATE_SUCCESS);
|
||||
} catch (IllegalArgumentException e) {
|
||||
return OptResult.error(e.getMessage());
|
||||
} catch (RuntimeException e) {
|
||||
return OptResult.error(e.getMessage());
|
||||
} catch (Exception e){
|
||||
return OptResult.error(MessageConstant.UNKNOWN_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Operation(summary = "查询生命周期列表")
|
||||
@GetMapping("/listLifeCycle")
|
||||
public OptResult listLifeCycle(){
|
||||
log.info("查询生命周期列表");
|
||||
List<Map<String, String>> lifeCycleList = modelService.listLifeCycle();
|
||||
return OptResult.success(lifeCycleList);
|
||||
}
|
||||
|
||||
@Operation(summary = "查询数据集列表")
|
||||
@GetMapping("/listDataset")
|
||||
public OptResult listDataset(){
|
||||
List<DatasetEntity> datasetList = modelService.listDataset();
|
||||
return OptResult.success(datasetList);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取模型训练信息")
|
||||
@GetMapping("/getModelTrainInfo")
|
||||
public OptResult getModelTrainInfo(Long id){
|
||||
log.info("获取模型训练信息");
|
||||
ModelTrainInfoVO modelTrainInfo = modelService.getModelTrainInfo(id);
|
||||
return OptResult.success(modelTrainInfo);
|
||||
}
|
||||
|
||||
@Operation(summary = "模型修改成训练中")
|
||||
@PutMapping("/updateModelTrain")
|
||||
public OptResult updateModelTrain(Long id){
|
||||
log.info("模型修改成训练中");
|
||||
modelService.updateModelTrain(id);
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
@Operation(summary = "模型更新小版本")
|
||||
@PutMapping("/updateModelVersionMinor")
|
||||
public OptResult updateModelVersionMinor(@RequestBody ModelVersionDTO dto){
|
||||
log.info("模型更新小版本");
|
||||
modelService.updateModelVersionMinor(dto);
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.config.IpConfig;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.DeployRequest;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.ModelSelectVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.ModelMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.ModelDeployer;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.util.NacosServiceUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name ="服务发布相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/publish")
|
||||
@Slf4j
|
||||
@CrossOrigin(origins = "http://localhost:3000") // 生产环境指定具体域名
|
||||
|
||||
public class PublishController {
|
||||
@Autowired
|
||||
private PublishService publishService;
|
||||
|
||||
@Autowired
|
||||
private NacosServiceUtil nacosServiceUtil;
|
||||
|
||||
@Autowired
|
||||
private ModelMapper modelMapper;
|
||||
@Autowired
|
||||
private IpConfig ipConfig;
|
||||
|
||||
@Autowired
|
||||
private ModelDeployer modelDeployer;
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary ="新增发布请求")
|
||||
@Transactional
|
||||
public OptResult<List<ServicePublishVO>> save(@RequestBody ServicePublishDTO servicePublishDTO) {
|
||||
log.info("模型发布请求:{}", servicePublishDTO);
|
||||
publishService.save(servicePublishDTO);
|
||||
//调用模型部署
|
||||
DeployRequest request = new DeployRequest();
|
||||
Long modelId = servicePublishDTO.getModelId();
|
||||
ModelVersion modelVersion = modelMapper.selectByModelId(modelId);
|
||||
String modelConfig = modelVersion.getModelConfig();
|
||||
//假设modelConfig只存GPU数据
|
||||
request.setModelId(String.valueOf(modelId));
|
||||
request.setRequiredMemory(Integer.parseInt(modelConfig));
|
||||
modelDeployer.deploy(request);
|
||||
// 获取前端传来的IP字符串
|
||||
String ipListStr = servicePublishDTO.getIp();
|
||||
if (ipListStr == null || ipListStr.trim().isEmpty()) {
|
||||
log.warn("IP列表为空,不进行Nacos注册");
|
||||
return OptResult.success();
|
||||
}
|
||||
try {
|
||||
// 使用逗号分割IP字符串
|
||||
String[] ipArray = ipListStr.split(",");
|
||||
// 循环注册每个IP到Nacos
|
||||
for (String ip : ipArray) {
|
||||
String trimmedIp = ip.trim();
|
||||
if (!trimmedIp.isEmpty()) {
|
||||
nacosServiceUtil.registerService(
|
||||
servicePublishDTO.getModelId().toString(),
|
||||
trimmedIp,
|
||||
8080,
|
||||
servicePublishDTO.getApiUrl()
|
||||
);
|
||||
log.info("Nacos服务注册成功: {}", trimmedIp);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Nacos服务注册失败", e);
|
||||
return OptResult.error("Nacos服务注册失败"); // 根据业务需求返回错误
|
||||
}
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已发布的服务列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary ="获取已发布服务列表")
|
||||
public OptResult<List<ServicePublishVO>> listPublishedServices() {
|
||||
log.info("获取已发布服务列表接口被调用");
|
||||
List<ServicePublishVO> services = publishService.listPublishedServices();
|
||||
log.info("返回的数据: {}", services);
|
||||
return OptResult.success(services);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取IP列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/config/ips")
|
||||
@Operation(summary = "获取可用IP地址列表")
|
||||
public OptResult<List<String>> getAvailableIps() {
|
||||
List<String> ips = ipConfig.getIps();
|
||||
log.info("返回列表;{}",ips);
|
||||
return OptResult.success(ips);
|
||||
}
|
||||
@GetMapping("/config/ids")
|
||||
public OptResult<List<ModelSelectVO>> getModelNames(){
|
||||
List<ModelSelectVO> modelSelectVOS = publishService.getModelNames();
|
||||
log.info("获取到模型列表:{}",modelSelectVOS);
|
||||
return OptResult.success(modelSelectVOS);
|
||||
}
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.ServiceAPIService;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.util.NacosServiceUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.models.security.SecurityScheme;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Tag(name ="服务API相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/API")
|
||||
@Slf4j
|
||||
public class ServiceAPIController {
|
||||
|
||||
@Autowired
|
||||
private ServiceAPIService serviceAPIService;
|
||||
|
||||
@Autowired
|
||||
private NacosServiceUtil nacosServiceUtil;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@PostMapping("/release")
|
||||
@Operation(summary = "结束访问")
|
||||
@Transactional
|
||||
public OptResult releaseResource(@PathVariable Long modelId) {
|
||||
String key = "modelId:" + modelId;
|
||||
String modelConfig = (String) redisTemplate.opsForValue().get(key);
|
||||
int userMemorySize = parseGpuMemorySize(modelConfig);
|
||||
List<String> instanceIps;
|
||||
try {
|
||||
instanceIps = nacosServiceUtil.getServiceInstances(modelId.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("获取Nacos实例失败", e);
|
||||
return OptResult.error("获取实例失败");
|
||||
}
|
||||
int memorySize;
|
||||
for (String ip : instanceIps) {
|
||||
String ipKey = "ip:" + ip;
|
||||
Integer nowMemorySizeOBJ = (Integer) redisTemplate.opsForValue().get(ipKey);
|
||||
int nowMemorySize = nowMemorySizeOBJ;
|
||||
memorySize = nowMemorySize + userMemorySize;
|
||||
// 更新IP对应的资源值
|
||||
redisTemplate.opsForValue().set(ipKey, memorySize);
|
||||
// 设置缓存过期时间(3600秒)
|
||||
redisTemplate.expire(ipKey, 3600, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
// 处理等待队列(先来先服务)
|
||||
String waitQueueKey = "waitQueue:" + modelId;
|
||||
// 取出队列头部的任务(最早加入的)
|
||||
Long waitModelId = (Long) redisTemplate.opsForList().leftPop(waitQueueKey);
|
||||
if (waitModelId != null) {
|
||||
log.info("检测到等待队列任务,尝试调度模型ID: {}", waitModelId);
|
||||
return schedule(waitModelId); // 重新调度最早的任务
|
||||
} else {
|
||||
log.info("等待队列为空,无任务需要处理");
|
||||
}
|
||||
|
||||
return OptResult.success("资源释放成功");
|
||||
}
|
||||
|
||||
@PostMapping("/request/{modelId}")
|
||||
@Operation(summary = "请求调度")
|
||||
@Transactional
|
||||
public OptResult schedule(@PathVariable Long modelId) {
|
||||
// 1. 存储modelConfig到缓存
|
||||
String modelConfig = serviceAPIService.getByModelId(modelId);
|
||||
int requestMemorySize = parseGpuMemorySize(modelConfig);
|
||||
if (requestMemorySize == -1){
|
||||
return OptResult.error("解析配置失败,请检查模型:" + modelId +"是否存在");
|
||||
}
|
||||
String modelConfigKey = "modelConfig:" + modelId;
|
||||
redisTemplate.opsForValue().set(modelConfigKey, modelConfig);
|
||||
// 2. 获取Nacos实例IP列表
|
||||
List<String> instanceIps;
|
||||
try {
|
||||
instanceIps = nacosServiceUtil.getServiceInstances(modelId.toString());
|
||||
} catch (Exception e) {
|
||||
log.error("获取Nacos实例失败", e);
|
||||
return OptResult.error("获取实例失败");
|
||||
}
|
||||
Set<String> gpuKeys = redisTemplate.keys("gpu:*");
|
||||
//根据IP列表查找资源
|
||||
for (String instanceIp : instanceIps) {
|
||||
for (String gpuKey : gpuKeys) {
|
||||
String GPUConfig = (String) redisTemplate.opsForValue().get(gpuKey);
|
||||
if (GPUConfig != null) {
|
||||
// 分割键值对
|
||||
String[] pairs = GPUConfig.split(",");
|
||||
String ip = null;
|
||||
int memorySize = 0;
|
||||
for (String pair : pairs) {
|
||||
String[] keyValue = pair.split(":", 2);
|
||||
if (keyValue.length == 2) {
|
||||
String key = keyValue[0].trim();
|
||||
String value = keyValue[1].trim();
|
||||
if ("IP".equalsIgnoreCase(key)) {
|
||||
ip = value;
|
||||
} else if ("GPUMemorySize".equalsIgnoreCase(key)) {
|
||||
memorySize = Integer.parseInt(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检查解析出的 IP 是否在 Nacos 实例列表中
|
||||
if (instanceIp.equals(ip)) {
|
||||
log.info("找到 IP {} 对应的 GPU 内存: {} ", ip, memorySize);
|
||||
if (memorySize>=requestMemorySize){
|
||||
int newMemorySize = memorySize - requestMemorySize;
|
||||
String ipKey = "ip:" + ip;
|
||||
redisTemplate.opsForValue().set(ipKey,newMemorySize);
|
||||
//访问请求最大时间为3600s
|
||||
redisTemplate.expire(ipKey, 3600, TimeUnit.SECONDS);
|
||||
}
|
||||
return OptResult.success("资源分配成功,使用ip:" + ip);
|
||||
}else {
|
||||
log.info("资源不足");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 所有实例检查完毕未找到足够资源
|
||||
String waitQueueKey = "waitQueue:" + modelId;
|
||||
// 改为右插入,保证队列顺序为FIFO(最早的任务在列表头部)
|
||||
redisTemplate.opsForList().rightPush(waitQueueKey, modelId);
|
||||
log.info("未找到足够资源,任务 {} 加入等待队列", modelId);
|
||||
return OptResult.error("资源不足,等待中");
|
||||
}
|
||||
/**
|
||||
* 从模型配置字符串中解析GPU内存需求
|
||||
* @param modelConfig 模型配置字符串,格式如 "GPUMemorySize:8000,version:1"
|
||||
* @return 解析到的GPU内存大小(MB),若解析失败返回-1
|
||||
*/
|
||||
private int parseGpuMemorySize(String modelConfig) {
|
||||
if (modelConfig == null || modelConfig.isEmpty()) {
|
||||
log.error("模型配置为空,无法解析GPU内存需求");
|
||||
return -1;
|
||||
}
|
||||
int requestMemorySize = 0;
|
||||
String[] config = modelConfig.split(",");
|
||||
for (String pair : config) {
|
||||
// 按冒号分割键值对
|
||||
String[] keyValue = pair.split(":", 2);
|
||||
if (keyValue.length == 2) {
|
||||
String key = keyValue[0].trim();
|
||||
String value = keyValue[1].trim();
|
||||
// 匹配 GPUMemorySize 字段(忽略大小写)
|
||||
if ("GPUMemorySize".equalsIgnoreCase(key)) {
|
||||
try {
|
||||
requestMemorySize = Integer.parseInt(value);
|
||||
log.info("模型GPU内存: {} MB", requestMemorySize);
|
||||
break; // 找到后即可退出循环
|
||||
} catch (NumberFormatException e) {
|
||||
log.error("解析GPUMemorySize失败,值: {}", value, e);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (requestMemorySize <= 0) {
|
||||
log.error("模型需求GPU内存未配置或无效");
|
||||
return -1;
|
||||
}
|
||||
return requestMemorySize;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.deploy.entity;
|
||||
|
||||
public class DeployRequest {
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DeployRequest {
|
||||
private String modelId;
|
||||
private int requiredMemory;
|
||||
private DeployType deployType;
|
||||
private ModelInfo modelInfo;
|
||||
|
||||
// 部署类型枚举
|
||||
public enum DeployType {
|
||||
NORMAL,
|
||||
GRAY
|
||||
}
|
||||
// 默认构造函数
|
||||
public DeployRequest() {
|
||||
}
|
||||
|
||||
public DeployRequest(String modelId, int requiredMemory, DeployType deployType, ModelInfo modelInfo) {
|
||||
this.modelId = modelId;
|
||||
this.requiredMemory = requiredMemory;
|
||||
this.deployType = deployType;
|
||||
this.modelInfo = modelInfo;
|
||||
}
|
||||
|
||||
// Getter & Setter 方法
|
||||
public String getModelId() {
|
||||
return modelId;
|
||||
}
|
||||
|
||||
public void setModelId(String modelId) {
|
||||
this.modelId = modelId;
|
||||
}
|
||||
|
||||
public int getRequiredMemory() {
|
||||
return requiredMemory;
|
||||
}
|
||||
|
||||
public void setRequiredMemory(int requiredMemory) {
|
||||
this.requiredMemory = requiredMemory;
|
||||
}
|
||||
|
||||
public DeployType getDeployType() {
|
||||
return deployType;
|
||||
}
|
||||
|
||||
public void setDeployType(DeployType deployType) {
|
||||
this.deployType = deployType;
|
||||
}
|
||||
|
||||
public ModelInfo getModelInfo() {
|
||||
return modelInfo;
|
||||
}
|
||||
|
||||
public void setModelInfo(ModelInfo modelInfo) {
|
||||
this.modelInfo = modelInfo;
|
||||
}
|
||||
|
||||
// Equals 和 HashCode 方法
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
DeployRequest that = (DeployRequest) o;
|
||||
return requiredMemory == that.requiredMemory &&
|
||||
Objects.equals(modelId, that.modelId) &&
|
||||
deployType == that.deployType &&
|
||||
Objects.equals(modelInfo, that.modelInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(modelId, requiredMemory, deployType, modelInfo);
|
||||
}
|
||||
|
||||
// toString 方法
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DeployRequest{" +
|
||||
"modelId='" + modelId + '\'' +
|
||||
", requiredMemory=" + requiredMemory +
|
||||
", deployType=" + deployType +
|
||||
", modelInfo=" + modelInfo +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||
|
||||
public class DeployResponse<T> {
|
||||
private boolean isSuccess;
|
||||
private String errorInfo;
|
||||
private int status;
|
||||
private T data;
|
||||
|
||||
public DeployResponse(boolean b, String s, int i, T data) {
|
||||
isSuccess = b;
|
||||
errorInfo = s;
|
||||
status = i;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
// 成功响应
|
||||
public static <T> DeployResponse<T> success(T data) {
|
||||
return new DeployResponse<>(true, "", 200, data);
|
||||
}
|
||||
|
||||
// 失败响应
|
||||
public static <T> DeployResponse<T> fail(int status, String error) {
|
||||
return new DeployResponse<>(false, error, status, null);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
//@AllArgsConstructor
|
||||
public class DeploymentResource {
|
||||
private final GpuResource gpu;
|
||||
private final String url;
|
||||
|
||||
public DeploymentResource(GpuResource gpu, String url) {
|
||||
this.gpu = gpu;
|
||||
this.url = url;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuCreateDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuResponseDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuUpdateDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface GpuMapper {
|
||||
GpuResource toEntity(GpuCreateDTO dto);
|
||||
GpuResource toEntity(GpuUpdateDTO dto);
|
||||
GpuResource toEntity(GpuResponseDTO dto);
|
||||
GpuResponseDTO toDTO(GpuResource entity);
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Setter
|
||||
@Getter
|
||||
public class GpuResource {
|
||||
@TableField("GPUId")
|
||||
private Long GPUId;
|
||||
|
||||
@TableField("GPUModel")
|
||||
private String GPUModel;
|
||||
|
||||
@TableField("GPUMemorySize")
|
||||
private Integer GPUMemorySize;
|
||||
|
||||
@TableField("is_deleted")
|
||||
private Integer isDeleted = 0;
|
||||
|
||||
@TableField("Ip")
|
||||
private String Ip;
|
||||
|
||||
@TableField("created_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField("update_time")
|
||||
private LocalDateTime UpdateTime;
|
||||
|
||||
@TableField("GPUMaxMemory")
|
||||
private Integer GPUMaxMemory;
|
||||
|
||||
public GpuResource(long l, String s, boolean b) {
|
||||
this.GPUId = l;
|
||||
this.GPUModel = s;
|
||||
this.isDeleted = b ? 1 : 0;
|
||||
}
|
||||
// public @Pattern(regexp = "^((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$") String getIp() {
|
||||
// return Ip;
|
||||
// }
|
||||
|
||||
public Boolean getIsDeleted() {
|
||||
return isDeleted != 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public GpuResource(Long Id, String GPUModel, Integer GPUMemorySize, String ip, LocalDateTime create_time) {
|
||||
this.GPUId = Id;
|
||||
this.GPUModel = GPUModel;
|
||||
this.GPUMemorySize = GPUMemorySize;
|
||||
this.Ip = ip;
|
||||
this.createTime = create_time;
|
||||
}
|
||||
|
||||
public GpuResource() {}
|
||||
|
||||
public Integer getGPUMemorySize() {
|
||||
return GPUMemorySize;
|
||||
}
|
||||
|
||||
public Long getGPUId() {
|
||||
return GPUId;
|
||||
}
|
||||
|
||||
public String getGPUModel() {
|
||||
return GPUModel;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return Ip;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public Integer getGPUMaxMemory() {
|
||||
return GPUMaxMemory;
|
||||
}
|
||||
|
||||
public void setGPUId(Long GPUId) {
|
||||
this.GPUId = GPUId;
|
||||
}
|
||||
|
||||
public void setGPUModel(String GPUModel) {
|
||||
this.GPUModel = GPUModel;
|
||||
}
|
||||
|
||||
public void setGPUMemorySize(Integer GPUMemorySize) {
|
||||
this.GPUMemorySize = GPUMemorySize;
|
||||
}
|
||||
|
||||
public void setIsDeleted(Integer isDeleted) {
|
||||
this.isDeleted = isDeleted;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
Ip = ip;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.RedisCacheService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Repository
|
||||
public class GpuResourceRepository {
|
||||
// Redis键定义
|
||||
// Redis键模式定义
|
||||
private static final String GPU_KEY_PREFIX = "gpu:";
|
||||
|
||||
private final RedisCacheService redisCacheService;
|
||||
|
||||
@Autowired
|
||||
public GpuResourceRepository(RedisCacheService redisCacheService) {
|
||||
this.redisCacheService = redisCacheService;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存或更新GPU资源
|
||||
* @param resource GPU资源对象
|
||||
*/
|
||||
public void save(GpuResource resource) {
|
||||
redisCacheService.put(resource.getGPUId().toString(), resource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按ID查询GPU资源
|
||||
* @param id GPU资源ID
|
||||
* @return GPU资源对象(可能为null)
|
||||
*/
|
||||
public GpuResource findById(Long id) {
|
||||
return redisCacheService.get(id.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
public List<GpuResource> findByStatus(Status status) {
|
||||
// 由于Redis存储结构不支持直接按属性查询,需要通过keys + 过滤方式实现
|
||||
// 注意:生产环境中应考虑使用RedisSCAN替代KEYS(此处为简写)
|
||||
Set<String> keys = redisCacheService.scanKeys(GPU_KEY_PREFIX + "*");
|
||||
|
||||
List<GpuResource> result = new ArrayList<>();
|
||||
keys.forEach(key -> {
|
||||
String gpuId = key.substring(GPU_KEY_PREFIX.length());
|
||||
GpuResource resource = redisCacheService.get(gpuId);
|
||||
if (resource != null && resource.getStatus() == status) {
|
||||
result.add(resource);
|
||||
}
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public void updateStatus(Long gpuId, Status newStatus) {
|
||||
GpuResource resource = findById(gpuId);
|
||||
if (resource != null) {
|
||||
resource.setStatus(newStatus);
|
||||
save(resource);
|
||||
}
|
||||
}
|
||||
*/
|
||||
public List<GpuResource> findAll() {
|
||||
Set<String> keys = redisCacheService.scanKeys("gpu:*");
|
||||
return keys.stream()
|
||||
.map(key -> {
|
||||
String gpuId = key.substring(4); // 去除"gpu:"前缀
|
||||
return redisCacheService.get(gpuId);
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,102 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class ModelInfo {
|
||||
private String modelId;
|
||||
private String modelName;
|
||||
private String modelType;
|
||||
private String preprocessScript;
|
||||
private String modelFilePath;
|
||||
private String storageLocation;
|
||||
|
||||
public String getModelId() {
|
||||
return modelId;
|
||||
}
|
||||
|
||||
public void setModelId(String modelId) {
|
||||
this.modelId = modelId;
|
||||
}
|
||||
|
||||
// Getter & Setter 方法
|
||||
public String getModelName() {
|
||||
return modelName;
|
||||
}
|
||||
|
||||
public void setModelName(String modelName) {
|
||||
this.modelName = modelName;
|
||||
}
|
||||
|
||||
public String getModelType() {
|
||||
return modelType;
|
||||
}
|
||||
|
||||
public void setModelType(String modelType) {
|
||||
this.modelType = modelType;
|
||||
}
|
||||
|
||||
public String getPreprocessScript() {
|
||||
return preprocessScript;
|
||||
}
|
||||
|
||||
public void setPreprocessScript(String preprocessScript) {
|
||||
this.preprocessScript = preprocessScript;
|
||||
}
|
||||
|
||||
public String getModelFilePath() {
|
||||
return modelFilePath;
|
||||
}
|
||||
|
||||
public void setModelFilePath(String modelFilePath) {
|
||||
this.modelFilePath = modelFilePath;
|
||||
}
|
||||
|
||||
public void setStorageLocation(String storageLocation) {
|
||||
// 验证路径格式
|
||||
if (storageLocation != null && !isValidStoragePath(storageLocation)) {
|
||||
throw new IllegalArgumentException("无效的存储路径: " + storageLocation);
|
||||
}
|
||||
this.storageLocation = storageLocation;
|
||||
}
|
||||
|
||||
private boolean isValidStoragePath(String path) {
|
||||
// 1. 基本非空检查
|
||||
if (path == null || path.trim().isEmpty()) return false;
|
||||
|
||||
// 2. 防止路径遍历攻击
|
||||
if (path.contains("..")) return false;
|
||||
|
||||
// 3. 仅允许合法路径格式
|
||||
return path.startsWith("/") ||
|
||||
path.startsWith("s3://") ||
|
||||
path.matches("[a-zA-Z]:\\\\"); // Windows 路径
|
||||
}
|
||||
|
||||
// Equals 和 HashCode 方法
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
ModelInfo modelInfo = (ModelInfo) o;
|
||||
return Objects.equals(modelName, modelInfo.modelName) &&
|
||||
Objects.equals(modelType, modelInfo.modelType) &&
|
||||
Objects.equals(preprocessScript, modelInfo.preprocessScript) &&
|
||||
Objects.equals(modelFilePath, modelInfo.modelFilePath);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(modelName, modelType, preprocessScript, modelFilePath);
|
||||
}
|
||||
|
||||
// toString 方法
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ModelInfo{" +
|
||||
"modelName='" + modelName + '\'' +
|
||||
", modelType='" + modelType + '\'' +
|
||||
", preprocessScript='" + preprocessScript + '\'' +
|
||||
", modelFilePath='" + modelFilePath + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class ModelSelectVO {
|
||||
private Long modelId; // 模型ID(即modelId,对应ModelVersion的id)
|
||||
private String modelName; // 模型名称(如"图像识别模型")
|
||||
private String version; // 版本信息(如"v1.0.0")
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.enumeration;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
|
||||
@Getter
|
||||
public enum DatasetType {
|
||||
UPLOAD(0,"用户上传"),
|
||||
FROM_DATABASE(1,"来源于数据库");
|
||||
|
||||
private final Integer code;
|
||||
private final String description;
|
||||
|
||||
DatasetType(Integer code, String description) {
|
||||
this.code = code;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据状态码获取对应的枚举值
|
||||
* @param code 状态码
|
||||
* @return 对应的枚举值
|
||||
*/
|
||||
public static DatasetType fromCode(Integer code) {
|
||||
for (DatasetType datasetType : DatasetType.values()) {
|
||||
if (datasetType.getCode().equals(code)) {
|
||||
return datasetType;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("无效的数据集状态码: " + code);
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.enumeration;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ErrorCodeEnum {
|
||||
SUCCESS(200, "操作成功"),
|
||||
SYSTEM_ERROR(500, "系统错误"),
|
||||
|
||||
PARAM_INVALID(400, "参数无效"),
|
||||
PARAM_MISSING(401, "缺少参数"),
|
||||
IP_FORMAT_ERROR(402, "IP地址格式错误"),
|
||||
GPU_MODEL_ERROR(403, "GPU型号格式应为[厂商]-[型号]"),
|
||||
|
||||
PERMISSION_DENIED(501, "无操作权限"),
|
||||
|
||||
GPU_NOT_FOUND(601, "GPU资源不存在"),
|
||||
|
||||
DB_CONNECTION_FAILED(701, "数据库连接错误"),
|
||||
VALIDATION_ERROR(801,"参数校验异常" ),
|
||||
|
||||
CACHE_INIT_ERROR(901, "缓存初始化失败"),
|
||||
INTERNAL_SERVER_ERROR(201,"内部服务出错" );
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
private final int code;
|
||||
private final String message;
|
||||
ErrorCodeEnum(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "ErrorCodeEnum{" +
|
||||
"code=" + code +
|
||||
", message='" + message + '\''+
|
||||
'}';
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.enumeration;
|
||||
|
||||
/**
|
||||
* 日志类型
|
||||
*/
|
||||
public enum LogType {
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.enumeration;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.MessageConstant;
|
||||
|
||||
/**
|
||||
* 模型生命周期状态枚举
|
||||
*/
|
||||
public enum ModelLifecycle {
|
||||
DESIGNING("设计中"),
|
||||
TRAINING("训练中"),
|
||||
EVALUATING("评估中"),
|
||||
DEPLOYED("已部署"),
|
||||
OFFLINE("已下线"),
|
||||
ABANDONED("已废弃");
|
||||
|
||||
private final String description;
|
||||
|
||||
private ModelLifecycle(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
// 将枚举名称转换成数据库存储的字符串
|
||||
public String getDbValue() {
|
||||
return name();
|
||||
}
|
||||
|
||||
// 将数据库存储的字符串转换为枚举实例
|
||||
public static ModelLifecycle getDbValueFromDb(String dbValue) {
|
||||
if(dbValue == null) return null;
|
||||
try {
|
||||
return ModelLifecycle.valueOf(dbValue);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new IllegalArgumentException(MessageConstant.LifeCycle_No_Exist + ":" + dbValue);
|
||||
}
|
||||
}
|
||||
|
||||
// 从前端传的中文描述 -> 转换为枚举
|
||||
public static ModelLifecycle fromDescription(String description) {
|
||||
for (ModelLifecycle lifecycle : ModelLifecycle.values()) {
|
||||
if (lifecycle.getDescription().equals(description)) {
|
||||
return lifecycle;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("生命周期描述非法: " + description);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.enumeration;
|
||||
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
|
||||
/**
|
||||
* 数据库操作类型
|
||||
*/
|
||||
public enum OperationType {
|
||||
/**
|
||||
* 更新操作
|
||||
*/
|
||||
UPDATE,
|
||||
|
||||
/**
|
||||
* 插入操作
|
||||
*/
|
||||
INSERT,
|
||||
|
||||
/**
|
||||
* 删除操作
|
||||
*/
|
||||
DELETE,
|
||||
/**
|
||||
* 查询操作
|
||||
*/
|
||||
SELECT
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.exception;
|
||||
|
||||
public class CacheInitException extends RuntimeException{
|
||||
public CacheInitException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public CacheInitException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.exception;
|
||||
|
||||
public class DeployException extends RuntimeException{
|
||||
// 错误代码
|
||||
private int errorCode = 500;
|
||||
|
||||
public DeployException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public DeployException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
public DeployException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public DeployException(String message, int errorCode) {
|
||||
super(message);
|
||||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
public int getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.exception;
|
||||
|
||||
public class EvaluationFailedException extends DeployException{
|
||||
public EvaluationFailedException(String message) {
|
||||
super(message);
|
||||
}
|
||||
public EvaluationFailedException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
public EvaluationFailedException() {
|
||||
super("模型评估未通过,无法部署");
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.exception;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.enumeration.ErrorCodeEnum;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ResponseVO;
|
||||
import org.springframework.dao.DataAccessResourceFailureException;
|
||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
@RestControllerAdvice
|
||||
public class GpuGlobalException {
|
||||
@ExceptionHandler(DataAccessResourceFailureException.class)
|
||||
public ResponseVO handleDBConnectionError() {
|
||||
return ResponseVO.error(ErrorCodeEnum.DB_CONNECTION_FAILED);
|
||||
}
|
||||
|
||||
@ExceptionHandler(MethodArgumentNotValidException.class)
|
||||
public ResponseVO handleValidationError(MethodArgumentNotValidException e) {
|
||||
return ResponseVO.error(ErrorCodeEnum.VALIDATION_ERROR);
|
||||
}
|
||||
|
||||
@ExceptionHandler(PermissionDeniedException.class)
|
||||
public ResponseVO handlePermissionDenied(PermissionDeniedException ex) {
|
||||
return ResponseVO.error(ex.getCode(), ex.getMessage());
|
||||
}
|
||||
|
||||
@ExceptionHandler(CacheInitException.class)
|
||||
public ResponseVO<?> handleCacheInitException(CacheInitException ex) {
|
||||
return ResponseVO.error(
|
||||
ErrorCodeEnum.CACHE_INIT_ERROR.getCode(),
|
||||
"缓存初始化失败: " + ex.getMessage()
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.exception;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.enumeration.ErrorCodeEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class PermissionDeniedException extends RuntimeException {
|
||||
private final Integer code;
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
private final String message;
|
||||
|
||||
public PermissionDeniedException(ErrorCodeEnum errorCode) {
|
||||
super(errorCode.getMessage());
|
||||
this.code = errorCode.getCode();
|
||||
this.message = errorCode.getMessage();
|
||||
}
|
||||
|
||||
public PermissionDeniedException(ErrorCodeEnum errorCode, String appendMessage) {
|
||||
super(errorCode.getMessage()+": "+appendMessage);
|
||||
this.code = errorCode.getCode();
|
||||
this.message = errorCode.getMessage()+": "+appendMessage;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.filter;
|
||||
|
||||
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
|
||||
import org.springframework.cloud.gateway.filter.GlobalFilter;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.server.ServerWebExchange;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
@Component
|
||||
public class ApiRequestGlobalFilter implements GlobalFilter, Ordered {
|
||||
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
// 检查请求路径和方法
|
||||
if (request.getURI().getPath().equals("/request/{id}") &&
|
||||
request.getMethod() == HttpMethod.POST) {
|
||||
// 在此处添加拦截逻辑
|
||||
System.out.println("拦截到POST /request请求");
|
||||
}
|
||||
// 继续处理请求
|
||||
return chain.filter(exchange);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 1; // 过滤器执行顺序,数值越小越先执行
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.handler;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.MessageConstant;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RestControllerAdvice;
|
||||
|
||||
import java.sql.SQLIntegrityConstraintViolationException;
|
||||
|
||||
/**
|
||||
* 全局异常处理器,处理项目中抛出的业务异常
|
||||
*/
|
||||
@RestControllerAdvice
|
||||
@Slf4j
|
||||
public class GlobalExceptionHandler {
|
||||
/*
|
||||
* 捕获SQL异常
|
||||
* */
|
||||
@ExceptionHandler
|
||||
public OptResult exceptionHandler(SQLIntegrityConstraintViolationException ex){
|
||||
String message = ex.getMessage();
|
||||
if(message.contains("Duplicate entry")) {
|
||||
String[] split = message.split(" ");
|
||||
String username = split[2];
|
||||
String msg = username + MessageConstant.ALREADY_EXISTS;
|
||||
return OptResult.error(msg);
|
||||
}else {
|
||||
return OptResult.error(MessageConstant.UNKNOWN_ERROR);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.AlgorithmInfo;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface AlgorithmInfoMapper {
|
||||
|
||||
@Select("SELECT * FROM algorithm_info WHERE id = #{id}")
|
||||
AlgorithmInfo selectById(Long id);
|
||||
|
||||
@Select("SELECT * FROM algorithm_info WHERE algorithm_name = #{algorithmName}")
|
||||
AlgorithmInfo selectByName(String algorithmName);
|
||||
|
||||
@Select("SELECT * FROM algorithm_info WHERE algorithm_type = #{algorithmType}")
|
||||
List<AlgorithmInfo> selectByType(String algorithmType);
|
||||
|
||||
@Insert("INSERT INTO algorithm_info(algorithm_name, algorithm_file, algorithm_type, description, created_by, file_size) " +
|
||||
"VALUES(#{algorithmName}, #{algorithmFile}, #{algorithmType}, #{description}, #{createdBy}, #{fileSize})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id")
|
||||
int insert(AlgorithmInfo algorithmInfo);
|
||||
|
||||
@Update("UPDATE algorithm_info SET algorithm_name = #{algorithmName}, algorithm_file = #{algorithmFile}, " +
|
||||
"algorithm_type = #{algorithmType}, description = #{description}, file_size = #{fileSize} " +
|
||||
"WHERE id = #{id}")
|
||||
int update(AlgorithmInfo algorithmInfo);
|
||||
|
||||
@Delete("DELETE FROM algorithm_info WHERE id = #{id}")
|
||||
int deleteById(Long id);
|
||||
@Select("select description from algorithm_info where id = #{id}")
|
||||
String getDescriptionById(Long id);
|
||||
@Select("select algorithm_file from algorithm_info where id = #{id}")
|
||||
String getFileById(Long id);
|
||||
@Select("select algorithm_name from algorithm_info")
|
||||
List<String> getAllNames();
|
||||
|
||||
List<AlgorithmInfo> selectByNameLike(String keyword);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetEntity;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetPageQueryDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetVO;
|
||||
import com.github.pagehelper.Page;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface DatasetMapper {
|
||||
|
||||
void updata(DatasetEntity datasetEntity);
|
||||
|
||||
void insert(DatasetEntity datasetEntity);
|
||||
|
||||
Page<DatasetVO> pageQuery(DatasetPageQueryDTO dataSetPageQueryDTO);
|
||||
|
||||
@Select("select * from dataset where dataset_id=#{datasetId}")
|
||||
DatasetEntity getById(Long datasetId);
|
||||
|
||||
void deleteBatch(@Param("datasetIds") List<Long> datasetIds);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ModelLogVO;
|
||||
|
||||
public interface EvaluationMapper {
|
||||
/*
|
||||
* 查询模型评估日志详情
|
||||
* @param id 模型版本id
|
||||
* @return 模型评估日志详情
|
||||
*/
|
||||
ModelLogVO selectLogDetail(Long id);
|
||||
|
||||
/*
|
||||
* 更新模型评估日志状态(评估通过则上线)
|
||||
* @param id 模型版本id
|
||||
* @param status 模型评估日志状态
|
||||
*/
|
||||
void update(Long id, Integer status);
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.apache.ibatis.jdbc.SQL;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Mapper
|
||||
public interface GpuResourceDao {
|
||||
//---------------------- 基础CRUD ------------------------
|
||||
@Insert("INSERT INTO Ipz.public.gpu_resource (GPUModel, GPUMemorySize, Ip) " +
|
||||
"VALUES (#{GPUModel}, #{GPUMemorySize}, #{Ip})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "GPUId")
|
||||
Integer insert(GpuResource entity);
|
||||
|
||||
//物理删除
|
||||
@Delete("DELETE FROM Ipz.public.gpu_resource WHERE GPUId = #{gpuId}")
|
||||
Integer deleteById(@Param("gpuId") Long gpuId);
|
||||
|
||||
// 逻辑删除
|
||||
@Update("UPDATE Ipz.public.gpu_resource" +
|
||||
" SET is_deleted = 1, update_time = NOW() " +
|
||||
" WHERE GPUId = #{gpuId}")
|
||||
Integer isDeleted(@Param("gpuId") Long gpuId);
|
||||
|
||||
@Update("UPDATE Ipz.public.gpu_resource " +
|
||||
"SET GPUModel = #{GPUModel}, GPUMemorySize = #{GPUMemorySize}, Ip = #{Ip} " +
|
||||
"WHERE GPUId = #{GPUId}")
|
||||
Integer updateById(GpuResource entity);
|
||||
|
||||
@Select("SELECT * FROM Ipz.public.gpu_resource WHERE GPUId = #{gpuId} AND is_deleted = 0")
|
||||
GpuResource selectById(@Param("gpuId") Long gpuId);
|
||||
|
||||
//---------------------- 缓存相关扩展 ------------------------
|
||||
|
||||
/**
|
||||
* 分页全量查询(缓存初始化用)
|
||||
* @param offset 起始位置
|
||||
* @param limit 每页数量
|
||||
*/
|
||||
// @Select("SELECT * FROM ipz.gpu_resource " +
|
||||
// "ORDER BY GPUId ASC LIMIT #{limit} OFFSET #{offset}")
|
||||
List<GpuResource> findByPage(@Param("offset") int offset,
|
||||
@Param("limit") int limit);
|
||||
|
||||
/**
|
||||
* 增量数据查询(缓存同步用)
|
||||
* @param since 起始时间
|
||||
*/
|
||||
// @Select("SELECT *, is_deleted FROM ipz.gpu_resource " +
|
||||
// "WHERE update_time > #{since} " +
|
||||
// "ORDER BY update_time ASC")
|
||||
List<GpuResource> findModifiedSince(@Param("since") LocalDateTime since);
|
||||
|
||||
/**
|
||||
* 带锁查询(防缓存击穿)
|
||||
*/
|
||||
// @Select("SELECT * FROM ipz.gpu_resource " +
|
||||
// "WHERE GPUId = #{gpuId} FOR UPDATE NOWAIT")
|
||||
GpuResource selectByIdWithLock(@Param("gpuId") Long gpuId);
|
||||
|
||||
/**
|
||||
* 动态条件查询(管理界面筛选用)
|
||||
*/
|
||||
// @SelectProvider(type = GpuSqlBuilder.class, method = "buildDynamicQuery")
|
||||
List<GpuResource> selectByFields(@Param("params") Map<String, Object> params);
|
||||
}
|
||||
|
||||
// 动态SQL构造器
|
||||
class GpuSqlBuilder {
|
||||
public static String buildDynamicQuery(Map<String, Object> params) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM("Ipz.public.gpu_resource");
|
||||
if (params.containsKey("model")) {
|
||||
WHERE("GPUModel LIKE #{params.model}");
|
||||
}
|
||||
if (params.containsKey("memoryMin")) {
|
||||
WHERE("GPUMemorySize >= #{params.memoryMin}");
|
||||
}
|
||||
if (params.containsKey("ip")) {
|
||||
WHERE("Ip = #{params.ip}");
|
||||
}
|
||||
if (params.containsKey("isDeleted")) {
|
||||
WHERE("is_deleted = #{params.isDeleted}");
|
||||
}
|
||||
}}.toString();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ModelMapper {
|
||||
|
||||
/**
|
||||
* 插入模型基本信息
|
||||
* @param modelInfo
|
||||
*/
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id") //能够拿到主键值,并设置给modelInfo对象
|
||||
@Insert("insert into model_info(model_name) values(#{modelName})")
|
||||
void insertModelInfo(ModelInfo modelInfo);
|
||||
|
||||
/**
|
||||
* 插入模型版本信息
|
||||
* @param modelVersion
|
||||
*/
|
||||
void insertModelVersion(ModelVersion modelVersion);
|
||||
|
||||
/*
|
||||
* 查询模型列表
|
||||
*/
|
||||
List<ModelVO> list();
|
||||
|
||||
/**
|
||||
* 根据id查询模型详情
|
||||
* @param id 版本表id
|
||||
* @return
|
||||
*/
|
||||
ModelVersion selectById(Long id);
|
||||
|
||||
/**
|
||||
* 更新模型信息
|
||||
* @param dto
|
||||
*/
|
||||
void update(ModelVersionDTO dto);
|
||||
|
||||
/**
|
||||
* 删除模型版本
|
||||
* @param id 版本表id
|
||||
*/
|
||||
@Delete("delete from model_version where id=#{id}")
|
||||
void deleteModelVersion(Long id);
|
||||
|
||||
/**
|
||||
* 删除模型
|
||||
* @param id 模型id
|
||||
*/
|
||||
@Delete("delete from model_info where id= #{id}")
|
||||
void deleteModel(Long id);
|
||||
|
||||
/**
|
||||
* 查询模型生命周期
|
||||
* @param id 模型版本表id
|
||||
* 返回模型生命周期
|
||||
*/
|
||||
@Select("select life_cycle from model_version where id=#{id}")
|
||||
String selectLifeCycleById(Long id);
|
||||
|
||||
/**
|
||||
* 更新模型生命周期
|
||||
* @param id 模型版本表id
|
||||
* @param dbValue 数据库中存储的生命周期
|
||||
* @return
|
||||
*/
|
||||
@Update("update model_version set life_cycle=#{dbValue} where id=#{id}")
|
||||
int updateLifeCycleById(Long id, String dbValue);
|
||||
|
||||
/**
|
||||
* 查询数据集列表
|
||||
* @return
|
||||
*/
|
||||
@Select("select dataset_id,dataset_name from dataset")
|
||||
List<DatasetEntity> listDataset();
|
||||
|
||||
|
||||
/**
|
||||
* 获取模型训练信息
|
||||
* @param id 模型版本表id
|
||||
* 返回模型训练信息
|
||||
*/
|
||||
ModelTrainInfoVO getModelTrainInfo(Long id);
|
||||
|
||||
|
||||
ModelVersion selectByModelId(Long modelId);
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.ModelSelectVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PublishMapper {
|
||||
|
||||
|
||||
|
||||
void insert(ServicePublishDTO servicePublishDTO);
|
||||
|
||||
Long getByApiUrl(String apiUrl);
|
||||
|
||||
@Select("SELECT model_id,api_url,ip FROM service_publish")
|
||||
List<ServicePublishVO> listPublishedServices();
|
||||
@Select("SELECT " +
|
||||
"mv.model_id AS modelId, " +
|
||||
"m.model_name AS modelName, " +
|
||||
"mv.version AS version " +
|
||||
"FROM model_version mv " +
|
||||
"LEFT JOIN model_info m ON mv.model_id = m.id")
|
||||
List<ModelSelectVO> selectModelSelectList();
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
||||
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface ServiceAPIMapper {
|
||||
@Select("select model_config from model_version where model_id=#{modelId} and status = 1")
|
||||
String getById(Long modelId);
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AlgorithmInfo {
|
||||
private Long id;
|
||||
private String algorithmName;
|
||||
private String algorithmFile;
|
||||
private String algorithmType;
|
||||
private String description;
|
||||
private String createdBy;
|
||||
private LocalDateTime createTime;
|
||||
private Long fileSize;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAlgorithmName() {
|
||||
return algorithmName;
|
||||
}
|
||||
|
||||
public void setAlgorithmName(String algorithmName) {
|
||||
this.algorithmName = algorithmName;
|
||||
}
|
||||
|
||||
public String getAlgorithmFile() {
|
||||
return algorithmFile;
|
||||
}
|
||||
|
||||
public void setAlgorithmFile(String algorithmFile) {
|
||||
this.algorithmFile = algorithmFile;
|
||||
}
|
||||
|
||||
public String getAlgorithmType() {
|
||||
return algorithmType;
|
||||
}
|
||||
|
||||
public void setAlgorithmType(String algorithmType) {
|
||||
this.algorithmType = algorithmType;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getCreatedBy() {
|
||||
return createdBy;
|
||||
}
|
||||
|
||||
public void setCreatedBy(String createdBy) {
|
||||
this.createdBy = createdBy;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
public Long getFileSize() {
|
||||
return fileSize;
|
||||
}
|
||||
|
||||
public void setFileSize(Long fileSize) {
|
||||
this.fileSize = fileSize;
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DatasetDTO implements Serializable {
|
||||
private Long datasetId;
|
||||
private String datasetName;
|
||||
private int datasetType;
|
||||
private int datasetStatus;
|
||||
private String dsPath;
|
||||
// private Map<String,String> args;
|
||||
private String args;
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DatasetEntity implements Serializable {
|
||||
private Long datasetId;
|
||||
private String datasetName;
|
||||
private int datasetType;
|
||||
private int datasetStatus;
|
||||
private String dsPath;
|
||||
// private Map<String,String> args;
|
||||
private String args;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DatasetPageQueryDTO implements Serializable{
|
||||
private int page;
|
||||
private int pageSize;
|
||||
private String datasetName;
|
||||
/* private int datasetType;
|
||||
private int datasetStatus;
|
||||
private String dsPath;
|
||||
private String args;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;*/
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DatasetVO implements Serializable {
|
||||
private Long datasetId;
|
||||
private String datasetName;
|
||||
private Integer datasetType;
|
||||
private Integer datasetStatus;
|
||||
private String dsPath;
|
||||
// private Map<String,String> args;
|
||||
private String args;
|
||||
private LocalDateTime createTime;
|
||||
private LocalDateTime updateTime;
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Setter
|
||||
@Getter
|
||||
public class GpuCreateDTO {
|
||||
@NotBlank(message = "GPU型号不能为空")
|
||||
@Pattern(regexp = "^([A-Z][A-Z0-9-]+)-\\w+",
|
||||
message = "型号格式应为 [厂商(大写字母开头)]-[型号],如 Intel-Xe_GPU")
|
||||
@JsonProperty("GPUModel") // 显示指定JSON映射名称
|
||||
private String GPUModel;
|
||||
|
||||
@NotNull(message = "显存容量不能为空")
|
||||
@JsonProperty("GPUMemorySize")
|
||||
private Integer GPUMemorySize;
|
||||
|
||||
@NotBlank(message = "IP地址不能为空")
|
||||
@Pattern(regexp = "^(\\d{1,3}\\.){3}\\d{1,3}$",
|
||||
message = "IP地址格式无效")
|
||||
@JsonProperty("Ip") // 显示指定JSON映射名称
|
||||
private String Ip;
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class GpuResponseDTO {
|
||||
@JsonView
|
||||
private Long GPUId;
|
||||
private String GPUModel;
|
||||
private Integer GPUMemorySize;
|
||||
private String Ip;
|
||||
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
// Builder类
|
||||
public static class Builder {
|
||||
private Long id;
|
||||
private String model;
|
||||
private Integer memory;
|
||||
private String ip;
|
||||
private LocalDateTime createTime = LocalDateTime.now(); // 统一命名为createTime
|
||||
|
||||
public Builder id(Long id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder model(String model) {
|
||||
this.model = model;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder memory(Integer memory) {
|
||||
this.memory = memory;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder ip(String ip) {
|
||||
this.ip = ip;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder createTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GpuResponseDTO build() {
|
||||
// 必填字段校验
|
||||
if (id == null) {
|
||||
throw new IllegalArgumentException("GPU ID必须填写");
|
||||
}
|
||||
|
||||
GpuResponseDTO dto = new GpuResponseDTO();
|
||||
dto.setGPUId(id);
|
||||
dto.setGPUModel(model);
|
||||
dto.setGPUMemorySize(memory);
|
||||
dto.setIp(ip);
|
||||
dto.setCreateTime(createTime); // 正确赋值createTime
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
||||
public String getCreateTimeStr() {
|
||||
return "GPU创建时间:" + (createTime != null ? createTime.toString() : "未设置");
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.*;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Setter
|
||||
@Getter
|
||||
public class GpuUpdateDTO {
|
||||
|
||||
private Long GPUId;
|
||||
|
||||
public @Pattern(regexp = "^([A-Z][A-Z0-9-]+)-\\w+",
|
||||
message = "型号格式应为 [厂商(大写字母开头)]-[型号],如 Intel-Xe_GPU") String getGPUModel() {
|
||||
return GPUModel;
|
||||
}
|
||||
|
||||
public @Pattern(regexp = "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$",
|
||||
message = "IP地址格式无效") String getIp() {
|
||||
return Ip;
|
||||
}
|
||||
|
||||
@Pattern(regexp = "^([A-Z][A-Z0-9-]+)-\\w+",
|
||||
message = "型号格式应为 [厂商(大写字母开头)]-[型号],如 Intel-Xe_GPU")
|
||||
@JsonProperty("GPUModel") // 显示指定JSON映射名称
|
||||
private String GPUModel;
|
||||
|
||||
@JsonProperty("GPUMemorySize") // 显示指定JSON映射名称
|
||||
private Integer GPUMemorySize;
|
||||
|
||||
@Pattern(regexp = "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$",
|
||||
message = "IP地址格式无效")
|
||||
@JsonProperty("Ip") // 显示指定JSON映射名称
|
||||
private String Ip;
|
||||
|
||||
public void setGPUId(Long GPUId) {
|
||||
this.GPUId = GPUId;
|
||||
}
|
||||
|
||||
public void setGPUModel(@Pattern(regexp = "^([A-Z][A-Z0-9-]+)-\\w+",
|
||||
message = "型号格式应为 [厂商(大写字母开头)]-[型号],如 Intel-Xe_GPU") String GPUModel) {
|
||||
this.GPUModel = GPUModel;
|
||||
}
|
||||
|
||||
public void setIp(@Pattern(regexp = "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$",
|
||||
message = "IP地址格式无效") String ip) {
|
||||
Ip = ip;
|
||||
}
|
||||
public Long getGPUId() {
|
||||
return GPUId;
|
||||
}
|
||||
|
||||
public Integer getGPUMemorySize() {
|
||||
return GPUMemorySize;
|
||||
}
|
||||
|
||||
public void setGPUMemorySize(Integer GPUMemorySize) {
|
||||
this.GPUMemorySize = GPUMemorySize;
|
||||
}
|
||||
}
|
@ -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; // 自定义标签
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelDTO {
|
||||
private Long id; // 模型id
|
||||
private String modelName; // 模型名称
|
||||
private String version; // 模型版本
|
||||
private Integer datasetId; // 数据集id
|
||||
private String modelConfig; // 模型配置信息
|
||||
private String modelPath; // 模型存储路径
|
||||
private Integer status; // 模型状态(1代表上线,0代表不上线)D
|
||||
private Integer modelSize; // 模型大小
|
||||
private String dataPreHandleFile; // 数据预处理文件存储路径
|
||||
private String modelSuperArgs; // 模型超参数
|
||||
private String modelArgsSize; // 模型参数量
|
||||
private String modelSourceCodeUrl; // 模型源代码路径
|
||||
private String modelFile; // 模型文件存储路径
|
||||
private String modelDesignDocument; // 模型设计文档存储路径
|
||||
private String lifeCycle; // 模型生命周期
|
||||
private String operateUser; // 操作人
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
/**
|
||||
* @author nh
|
||||
* @description:模型评估记录实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelEvaluation implements Serializable {
|
||||
private Long id; // 评估记录id
|
||||
private Long modelVersionId; // 关联模型id,后续修改成了模型版本id
|
||||
private LocalDateTime evaluationTime; // 评估时间
|
||||
private String evaluationResult; // 评估结果
|
||||
private String operator; // 评估操作人员
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
/**
|
||||
* @author nh
|
||||
* @description:模型实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelInfo implements Serializable {
|
||||
private Long id; // 模型id
|
||||
private String modelName; // 模型名称
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
/**
|
||||
* @author :nh
|
||||
* @description:模型日志实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelLog implements Serializable {
|
||||
private Long id; // 日志id
|
||||
private Long modelId; // 关联模型id
|
||||
private Integer logType; // 日志类型(1,2,3...)
|
||||
private String logPath; // 日志存储路径
|
||||
private LocalDateTime logTime; // 日志生成时间
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
/**
|
||||
* @author nh
|
||||
* @description:模型日志视图对象
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelLogVO {
|
||||
private Long id; // 日志id
|
||||
private Long modelId; // 关联模型id
|
||||
private String modelName; // 模型名称
|
||||
private String version; // 模型版本
|
||||
private String modelConfig; // 模型配置
|
||||
private Integer logType; // 日志类型(1,2,3...)
|
||||
private String logPath; // 日志存储路径
|
||||
private LocalDateTime logTime; // 日志生成时间
|
||||
}
|
||||
|
@ -0,0 +1,18 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class ModelTrainInfoVO {
|
||||
private Long id;
|
||||
private Integer datasetId; // 数据集id
|
||||
private String modelConfig; // 模型配置信息
|
||||
private String dsPath;// 版本信息表id
|
||||
private String dataPreHandleFile; // 数据预处理文件存储路径
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelVO {
|
||||
private Long id; // 模型id
|
||||
private Long versionId; // 用于保证react的map中key的唯一性
|
||||
private String modelName; // 模型名称
|
||||
private String version; // 模型版本
|
||||
private String dataPreHandleFile; // 数据预处理文件存储路径
|
||||
private String operateUser; // 操作人
|
||||
private LocalDateTime updateTime; // 修改时间
|
||||
private Integer status; // 模型状态(1代表上线,0代表不上线)
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
/**
|
||||
* @author :nh
|
||||
* @description:模型版本信息实体类
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelVersion implements Serializable {
|
||||
private Long id; // 版本信息表id
|
||||
private Long modelId; // 关联模型id
|
||||
private String version; // 模型版本
|
||||
private Integer datasetId; // 数据集id
|
||||
private String modelConfig; // 模型配置信息
|
||||
private String modelPath; // 模型存储路径
|
||||
private Integer status; // 模型状态(1代表上线,0代表不上线)
|
||||
private LocalDateTime createTime; // 创建时间
|
||||
//补充更新时间字段
|
||||
private LocalDateTime updateTime; // 更新时间
|
||||
//创建模型部分补充的字段
|
||||
private Integer modelSize; // 模型大小
|
||||
private String dataPreHandleFile; // 数据预处理文件存储路径
|
||||
//模型信息管理部分补充的字段
|
||||
private String modelSuperArgs; // 模型超参数
|
||||
private String modelArgsSize; // 模型参数量
|
||||
private String modelSourceCodeUrl; // 模型源代码路径
|
||||
private String modelFile; // 模型文件存储路径
|
||||
private String modelDesignDocument; // 模型设计文档存储路径
|
||||
|
||||
private String lifeCycle; // 模型生命周期
|
||||
|
||||
private String operateUser; // 操作人
|
||||
|
||||
private String modelName; //模型名称
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ModelVersionDTO {
|
||||
private Long id; // 模型版本id
|
||||
private Long modelId; // 模型id
|
||||
private String version; // 模型版本
|
||||
private Integer datasetId; // 数据集id
|
||||
private String modelConfig; // 模型配置信息
|
||||
private String modelPath; // 模型存储路径
|
||||
private Integer status; // 模型状态(1代表上线,0代表不上线)
|
||||
private LocalDateTime createTime; // 创建时间
|
||||
private LocalDateTime updateTime; // 更新时间
|
||||
private Integer modelSize; // 模型大小
|
||||
private String dataPreHandleFile; // 数据预处理文件存储路径
|
||||
private String modelSuperArgs; // 模型超参数
|
||||
private String modelArgsSize; // 模型参数量
|
||||
private String modelSourceCodeUrl; // 模型源代码路径
|
||||
private String modelFile; // 模型文件存储路径
|
||||
private String modelDesignDocument; // 模型设计文档存储路径
|
||||
private String lifeCycle; // 模型生命周期
|
||||
private String operateUser; // 操作人
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 后端统一返回结果
|
||||
* @author hky
|
||||
* @param <T>
|
||||
*/
|
||||
@Data
|
||||
public class OptResult<T> implements Serializable {
|
||||
|
||||
private boolean isSuccess;
|
||||
private String errorInfo;
|
||||
private int statusCode;
|
||||
private T data;
|
||||
|
||||
public static <T> OptResult<T> success() {
|
||||
OptResult<T> result = new OptResult<>();
|
||||
result.isSuccess = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> OptResult<T> success(T object) {
|
||||
OptResult<T> result = new OptResult<>();
|
||||
result.data = object;
|
||||
result.isSuccess = true;
|
||||
return result;
|
||||
}
|
||||
|
||||
public static <T> OptResult<T> error(String errorInfo) {
|
||||
OptResult result = new OptResult();
|
||||
result.errorInfo = errorInfo;
|
||||
result.isSuccess = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分页
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PageResult implements Serializable {
|
||||
private long total;
|
||||
private List records;
|
||||
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.enumeration.ErrorCodeEnum;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ResponseVO<T> implements Serializable {
|
||||
private Integer code; //状态码
|
||||
private String message; //描述信息
|
||||
private T data; //业务数据
|
||||
|
||||
|
||||
//私有构造方法
|
||||
private ResponseVO(Integer code, String message, T data) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
//静态工厂方法
|
||||
//成功响应(无数据)
|
||||
public static <T> ResponseVO<T> success() {
|
||||
return new ResponseVO<>(200, "OK", null);
|
||||
}
|
||||
//成功响应(有数据)
|
||||
public static <T> ResponseVO<T> success(T data) {
|
||||
return new ResponseVO<>(200, "OK", data);
|
||||
}
|
||||
//失败响应(自定义错误码和消息)
|
||||
public static <T> ResponseVO<T> error(Integer code, String message) {
|
||||
return new ResponseVO<>(code, message, null);
|
||||
}
|
||||
//失败响应(基于预定义错误枚举)
|
||||
public static <T> ResponseVO<T> error(ErrorCodeEnum errorCode) {
|
||||
return new ResponseVO<>(errorCode.getCode(), errorCode.getMessage(), null);
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServicePublish implements Serializable {
|
||||
private Long modelId;
|
||||
private String GPUModel;
|
||||
private String ip;
|
||||
private String GPUMemorySize;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServicePublishDTO implements Serializable {
|
||||
private Long id;
|
||||
private Long modelId;
|
||||
private String apiUrl;
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime createTime;
|
||||
private String ip;
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServicePublishVO implements Serializable {
|
||||
private Long modelId;
|
||||
/*private String GPUModel;*/
|
||||
private String ip;
|
||||
/* private String GPUMemorySize;*/
|
||||
private String apiUrl;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "aliyun.oss") // 读取以 aliyun.oss 开头的配置
|
||||
public class AliOssProperties {
|
||||
private String endpoint;
|
||||
private String accessKeyId;
|
||||
private String accessKeySecret;
|
||||
private String bucketName;
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.AlgorithmInfo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface AlgorithmInfoService {
|
||||
AlgorithmInfo getById(Long id);
|
||||
AlgorithmInfo getByName(String algorithmName);
|
||||
List<AlgorithmInfo> getByType(String algorithmType);
|
||||
boolean update(AlgorithmInfo algorithmInfo);
|
||||
boolean delete(Long id);
|
||||
boolean validateAlgorithmInfo(AlgorithmInfo algorithmInfo);
|
||||
|
||||
void save(AlgorithmInfo algorithmInfo, MultipartFile file);
|
||||
|
||||
String run(Long id, String param);
|
||||
|
||||
List<String> getAllNames();
|
||||
|
||||
List<AlgorithmInfo> getByNameLike(String keyword);
|
||||
}
|
@ -0,0 +1,195 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.exception.CacheInitException;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@Component
|
||||
public class CacheManager {
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private GpuResourceDao gpuResourceDao;
|
||||
|
||||
@Autowired
|
||||
private ObjectMapper objectMapper; // 注入ObjectMapper用于类型转换
|
||||
|
||||
private final ReentrantLock lock = new ReentrantLock();
|
||||
|
||||
@Value("${cache.redis-key-prefix:gpu:}")
|
||||
private String keyPrefix;
|
||||
|
||||
@Value("${cache.ttl-base:7200}")
|
||||
private int ttlBase;
|
||||
|
||||
@Value("${cache.init-batch-size:500}")
|
||||
private int initBatchSize;
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(CacheManager.class);
|
||||
|
||||
// 全量加载(带分页和分布式锁)
|
||||
@PostConstruct
|
||||
public void loadFullCache() {
|
||||
if (tryLock()) {
|
||||
try {
|
||||
int page = 0;
|
||||
while (true) {
|
||||
List<GpuResource> batch = gpuResourceDao.findByPage(page * initBatchSize, initBatchSize);
|
||||
if (batch.isEmpty()) break;
|
||||
|
||||
batch.forEach(this::setCacheWithTTL);
|
||||
page++;
|
||||
}
|
||||
} finally {
|
||||
unlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 单条缓存刷新(带版本控制)
|
||||
public void refreshCache(Long gpuId) {
|
||||
GpuResource latest = gpuResourceDao.selectByIdWithLock(gpuId);
|
||||
if (latest != null) {
|
||||
setCacheWithTTL(latest);
|
||||
}
|
||||
}
|
||||
|
||||
// 批量增量同步
|
||||
public void syncCache(LocalDateTime lastSyncTime) {
|
||||
List<GpuResource> updates = gpuResourceDao.findModifiedSince(lastSyncTime);
|
||||
updates.forEach(entity -> {
|
||||
if (entity.getIsDeleted()) {
|
||||
redisTemplate.delete(buildKey(entity.getGPUId().toString()));
|
||||
} else {
|
||||
setCacheWithTTL(entity);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 带随机TTL的缓存设置
|
||||
private void setCacheWithTTL(GpuResource entity) {
|
||||
String key = buildKey(entity.getGPUId().toString());
|
||||
|
||||
// 直接存储实体对象,确保类型一致性
|
||||
redisTemplate.opsForValue().set(
|
||||
key,
|
||||
entity,
|
||||
ttlBase + (int)(Math.random() * 600),
|
||||
TimeUnit.SECONDS
|
||||
);
|
||||
}
|
||||
|
||||
// 构建缓存键
|
||||
private String buildKey(String gpuId) {
|
||||
return keyPrefix + gpuId;
|
||||
}
|
||||
|
||||
// 分布式锁操作
|
||||
private boolean tryLock() {
|
||||
try {
|
||||
return lock.tryLock(30, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void unlock() {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
// 分页加载入口
|
||||
public void loadFullCache(int batchSize) {
|
||||
int page = 0;
|
||||
while (true) {
|
||||
List<GpuResource> batch = gpuResourceDao.findByPage(page * batchSize, batchSize);
|
||||
if (batch.isEmpty()) break;
|
||||
|
||||
batch.forEach(this::refreshWithRetry);
|
||||
page++;
|
||||
}
|
||||
}
|
||||
|
||||
// 带重试机制的缓存刷新
|
||||
public void refreshWithRetry(GpuResource entity) {
|
||||
try {
|
||||
setCacheWithTTL(entity);
|
||||
} catch (RedisConnectionFailureException ex) {
|
||||
// 3次重试逻辑
|
||||
for (int i = 0; i < 3; i++) {
|
||||
try {
|
||||
log.info("重试第 {} 次", i + 1);
|
||||
Thread.sleep(1000);
|
||||
setCacheWithTTL(entity);
|
||||
return;
|
||||
} catch (InterruptedException e) {
|
||||
if (i == 2) {
|
||||
throw new CacheInitException("缓存刷新失败: " + entity.getGPUId().toString());
|
||||
}
|
||||
|
||||
log.error("重试失败", e);
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取当前缓存数量(调试用)
|
||||
public long getCacheCount() {
|
||||
return redisTemplate.keys(keyPrefix + "*").size();
|
||||
}
|
||||
|
||||
public void evictCache(Long gpuId) {
|
||||
String key = buildKey(gpuId.toString());
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
// 修改获取缓存的方法,增加类型安全处理
|
||||
@SuppressWarnings("unchecked")
|
||||
public GpuResource getFromCache(String gpuId) {
|
||||
String key = buildKey(gpuId);
|
||||
Object value = redisTemplate.opsForValue().get(key);
|
||||
|
||||
// 处理可能的类型不匹配问题
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
// 优先尝试直接转换
|
||||
if (value instanceof GpuResource) {
|
||||
return (GpuResource) value;
|
||||
}
|
||||
// 如果是LinkedHashMap,使用ObjectMapper转换
|
||||
else if (value instanceof java.util.LinkedHashMap) {
|
||||
return objectMapper.convertValue(value, GpuResource.class);
|
||||
}
|
||||
// 其他情况尝试序列化后反序列化(适用于JSON存储场景)
|
||||
else {
|
||||
// 先序列化为JSON字符串,再反序列化为对象
|
||||
String json = objectMapper.writeValueAsString(value);
|
||||
return objectMapper.readValue(json, GpuResource.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取缓存时类型转换失败,key: {}, valueType: {}", key, value.getClass().getName(), e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.DatasetPageQueryDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.PageResult;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
public interface DatasetService {
|
||||
void save(DatasetDTO datasetDTO, MultipartFile file);
|
||||
|
||||
void update(DatasetDTO datasetDTO, MultipartFile file);
|
||||
|
||||
PageResult pageQuery(DatasetPageQueryDTO dataSetPageQueryDTO);
|
||||
|
||||
void deleteBatch(List<Long> datasetIds);
|
||||
|
||||
InputStream downloadDataset(Long datasetId);
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ModelLogVO;
|
||||
|
||||
public interface EvaluationService {
|
||||
ModelLogVO detail(Long id);
|
||||
|
||||
void startOrStop(Long id, Integer status);
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuCreateDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuResponseDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuUpdateDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ResponseVO;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface GpuManageService {
|
||||
public ResponseVO createGpuResource(GpuCreateDTO dto);
|
||||
public ResponseVO deleteGpuResource(Long gpuId);
|
||||
public void updateGpuResource(GpuUpdateDTO entity);
|
||||
public List<GpuResponseDTO> searchByCriteria(String model, Integer memorySize, String ip);
|
||||
|
||||
@Transactional
|
||||
ResponseVO createGpuResourceWithTrace(GpuCreateDTO dto);
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResourceRepository;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class GpuResourceService {
|
||||
@Autowired
|
||||
private GpuResourceRepository repository;
|
||||
|
||||
@Cacheable(value = "availableGpus")
|
||||
public List<GpuResource> getAvailableResources() {
|
||||
// 获取所有未删除的资源
|
||||
return repository.findAll().stream()
|
||||
.filter(gpu -> gpu.getIsDeleted() == null || !gpu.getIsDeleted())
|
||||
.collect(Collectors.toList()); }
|
||||
|
||||
public void markAsAllocated(Long gpuId, int allocatedMemory) {
|
||||
GpuResource gpu = repository.findById(gpuId);
|
||||
if (gpu != null) {
|
||||
// 更新已使用内存
|
||||
int currentMemory = gpu.getGPUMemorySize() != null ? gpu.getGPUMemorySize() : 0;
|
||||
gpu.setGPUMemorySize(currentMemory + allocatedMemory);
|
||||
repository.save(gpu);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.DeployRequest;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.DeployResponse;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.DeploymentResource;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.exception.EvaluationFailedException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@Service
|
||||
public class GrayDeployService {
|
||||
@Autowired
|
||||
private ModelEvaluator modelEvaluator;
|
||||
|
||||
@Autowired
|
||||
private ResourceAllocator resourceAllocator;
|
||||
|
||||
@Autowired
|
||||
private GpuResourceService gpuService;
|
||||
|
||||
// @Autowired
|
||||
// private MQSender mqSender;
|
||||
|
||||
public DeployResponse process(DeployRequest request) {
|
||||
// 检查评估状态
|
||||
if (!modelEvaluator.isEvaluationPassed(request.getModelId())) {
|
||||
throw new EvaluationFailedException("模型评估未通过");
|
||||
}
|
||||
|
||||
// 分配资源并获取URL
|
||||
DeploymentResource resource = resourceAllocator.allocate(
|
||||
gpuService.getAvailableResources(),
|
||||
request.getRequiredMemory(),
|
||||
request.getModelId(),
|
||||
true
|
||||
);
|
||||
|
||||
// // 发送MQ灰度通知
|
||||
// mqSender.sendGrayDeployNotification(
|
||||
// resource.getUrl(),
|
||||
// request.getModelId(),
|
||||
// resource.getGpu().getGPUId()
|
||||
// );
|
||||
// 标记资源已分配(更新内存使用量)
|
||||
gpuService.markAsAllocated(
|
||||
resource.getGpu().getGPUId(),
|
||||
request.getRequiredMemory()
|
||||
);
|
||||
return DeployResponse.success(resource.getUrl());
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,150 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.AlgorithmInfoMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.AlgorithmInfo;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.AlgorithmInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AlgorithmInfoServiceImpl implements AlgorithmInfoService {
|
||||
|
||||
@Autowired
|
||||
private AlgorithmInfoMapper algorithmInfoMapper;
|
||||
|
||||
@Value("${algorithm.upload.dir:/tmp/algorithm-files/}") // 默认上传目录
|
||||
private String uploadDir;
|
||||
@Override
|
||||
public AlgorithmInfo getById(Long id) {
|
||||
return algorithmInfoMapper.selectById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlgorithmInfo getByName(String algorithmName) {
|
||||
return algorithmInfoMapper.selectByName(algorithmName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AlgorithmInfo> getByType(String algorithmType) {
|
||||
return algorithmInfoMapper.selectByType(algorithmType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean update(AlgorithmInfo algorithmInfo) {
|
||||
if (!validateAlgorithmInfo(algorithmInfo)) {
|
||||
return false;
|
||||
}
|
||||
return algorithmInfoMapper.update(algorithmInfo) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean delete(Long id) {
|
||||
return algorithmInfoMapper.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validateAlgorithmInfo(AlgorithmInfo algorithmInfo) {
|
||||
if (algorithmInfo == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!StringUtils.hasText(algorithmInfo.getAlgorithmName()) ||
|
||||
!StringUtils.hasText(algorithmInfo.getAlgorithmFile()) ||
|
||||
!StringUtils.hasText(algorithmInfo.getAlgorithmType())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(AlgorithmInfo algorithmInfo, MultipartFile file) {
|
||||
String algorithmName = algorithmInfo.getAlgorithmName();
|
||||
// 检查同名算法
|
||||
AlgorithmInfo duplicateName = algorithmInfoMapper.selectByName(algorithmName);
|
||||
if (duplicateName != null) {
|
||||
throw new RuntimeException("算法已存在,请去修改算法");
|
||||
}
|
||||
|
||||
// 只接收文件但不进行保存操作
|
||||
if (file != null && !file.isEmpty()) {
|
||||
log.info("已接收文件: {}", file.getOriginalFilename());
|
||||
log.info("文件大小: {} 字节", file.getSize());
|
||||
log.info("文件类型: {}", file.getContentType());
|
||||
// 临时设置一个空路径(避免数据库保存空值)
|
||||
//todo 保存到分布式存储
|
||||
algorithmInfo.setAlgorithmFile("");
|
||||
}
|
||||
|
||||
algorithmInfo.setCreateTime(LocalDateTime.now());
|
||||
// 保存算法信息到数据库(注意:此时algorithmFile字段为空)
|
||||
algorithmInfoMapper.insert(algorithmInfo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String run(Long id, String param) {
|
||||
//todo从分布式存储中拿到文件(以下是示例)
|
||||
String file = algorithmInfoMapper.getFileById(id);
|
||||
StringBuilder result = new StringBuilder(); // 用于存储结果
|
||||
|
||||
try {
|
||||
// 构建命令,将 param 作为参数传递给 Python 脚本
|
||||
ProcessBuilder pb = new ProcessBuilder("python", file, param);
|
||||
Process process = pb.start();
|
||||
|
||||
// 读取标准输出(脚本执行结果)
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
result.append(line).append("\n");
|
||||
}
|
||||
|
||||
// 读取错误输出
|
||||
BufferedReader errorReader = new BufferedReader(
|
||||
new InputStreamReader(process.getErrorStream()));
|
||||
String errorLine;
|
||||
while ((errorLine = errorReader.readLine()) != null) {
|
||||
result.append("Error: ").append(errorLine).append("\n");
|
||||
}
|
||||
|
||||
int exitCode = process.waitFor();
|
||||
result.append("Exit Code: ").append(exitCode);
|
||||
|
||||
} catch (Exception e) {
|
||||
result.append("执行异常: ").append(e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return result.toString(); // 返回完整结果
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllNames() {
|
||||
return algorithmInfoMapper.getAllNames();
|
||||
}
|
||||
|
||||
/**
|
||||
* 模糊查询
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<AlgorithmInfo> getByNameLike(String keyword) {
|
||||
return algorithmInfoMapper.selectByNameLike(keyword);
|
||||
}
|
||||
}
|
@ -0,0 +1,132 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.StatusConstant;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.enumeration.DatasetType;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.DatasetMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.DatasetService;
|
||||
import com.github.pagehelper.Page;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import static com.bipt.intelligentapplicationorchestrationservice.enumeration.DatasetType.FROM_DATABASE;
|
||||
import static com.bipt.intelligentapplicationorchestrationservice.enumeration.DatasetType.UPLOAD;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class DatasetServiceImpl implements DatasetService {
|
||||
@Autowired
|
||||
private DatasetMapper datasetMapper;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(DatasetDTO datasetDTO, MultipartFile file) {
|
||||
DatasetType datasetType = DatasetType.fromCode(datasetDTO.getDatasetType());
|
||||
if (datasetType == UPLOAD && file != null && !file.isEmpty()) {
|
||||
try {
|
||||
//todo存入分布式文件系统
|
||||
|
||||
// 生成文件名(建议使用 UUID 避免重复)
|
||||
String fileName = UUID.randomUUID() + "-" + file.getOriginalFilename();
|
||||
// 假设使用本地存储(实际需对接分布式文件系统,如 MinIO、OSS 等)
|
||||
String filePath = "/your/storage/path/" + fileName;
|
||||
// 保存文件到磁盘(示例代码,需处理 IO 异常)
|
||||
file.transferTo(new File(filePath));
|
||||
// 更新数据集路径
|
||||
datasetDTO.setDsPath(filePath); // 取消注释,并确保 datasetDTO 有 setDsPath 方法
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("文件上传失败: " + e.getMessage());
|
||||
}
|
||||
} else if (datasetType == FROM_DATABASE){
|
||||
//todo 从数据仓库中查询 并选择筛选条件
|
||||
}
|
||||
|
||||
// 保存数据集实体
|
||||
DatasetEntity datasetEntity = new DatasetEntity();
|
||||
BeanUtils.copyProperties(datasetDTO, datasetEntity);
|
||||
datasetEntity.setCreateTime(LocalDateTime.now());
|
||||
datasetEntity.setUpdateTime(LocalDateTime.now());
|
||||
datasetMapper.insert(datasetEntity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改数据集
|
||||
*
|
||||
* @param datasetDTO
|
||||
* @param file
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(DatasetDTO datasetDTO, MultipartFile file) {
|
||||
DatasetType datasetType = DatasetType.fromCode(datasetDTO.getDatasetType());
|
||||
if (datasetType == UPLOAD && file != null && !file.isEmpty()) {
|
||||
try {
|
||||
// 生成文件名(建议使用 UUID 避免重复)
|
||||
String fileName = UUID.randomUUID() + "-" + file.getOriginalFilename();
|
||||
// 假设使用本地存储(实际需对接分布式文件系统,如 MinIO、OSS 等)
|
||||
String filePath = "/your/storage/path/" + fileName;
|
||||
// 保存文件到磁盘(示例代码,需处理 IO 异常)
|
||||
file.transferTo(new File(filePath));
|
||||
// 更新数据集路径
|
||||
datasetDTO.setDsPath(filePath); // 取消注释,并确保 datasetDTO 有 setDsPath 方法
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("文件上传失败: " + e.getMessage());
|
||||
}
|
||||
} else if (datasetType == FROM_DATABASE){
|
||||
//todo 从数据仓库中查询 并选择筛选条件
|
||||
}
|
||||
|
||||
DatasetEntity datasetEntity = new DatasetEntity();
|
||||
BeanUtils.copyProperties(datasetDTO,datasetEntity);
|
||||
datasetEntity.setUpdateTime(LocalDateTime.now());
|
||||
datasetMapper.updata(datasetEntity);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
* @param dataSetPageQueryDTO
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageResult pageQuery(DatasetPageQueryDTO dataSetPageQueryDTO) {
|
||||
PageHelper.startPage(dataSetPageQueryDTO.getPage(), dataSetPageQueryDTO.getPageSize());
|
||||
Page<DatasetVO> page = datasetMapper.pageQuery(dataSetPageQueryDTO);
|
||||
return new PageResult(page.getTotal(), page.getResult());
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param datasetIds
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void deleteBatch(List<Long> datasetIds) {
|
||||
|
||||
//TODO 在分布式文件系统中删除
|
||||
datasetMapper.deleteBatch(datasetIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载
|
||||
* @param datasetId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public InputStream downloadDataset(Long datasetId) {
|
||||
// TODO: 调用分布式存储系统的接口获取数据集文件的输入流
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.EvaluationMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ModelLogVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.EvaluationService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class EvaluationServiceImpl implements EvaluationService {
|
||||
@Autowired
|
||||
private EvaluationMapper evaluationMapper;
|
||||
/**
|
||||
* 获取日志详情
|
||||
* @param id 模型日志id
|
||||
* @return 日志详情
|
||||
*/
|
||||
@Override
|
||||
public ModelLogVO detail(Long id) {
|
||||
log.info("id:{}", id);
|
||||
ModelLogVO modelLogVO = evaluationMapper.selectLogDetail(id);
|
||||
return modelLogVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 评估模型决定是否上线
|
||||
* @param id 模型id
|
||||
* @param status 模型评估状态,评估通过则上线(1.上线,0.下线)
|
||||
*/
|
||||
@Override
|
||||
public void startOrStop(Long id, Integer status) {
|
||||
evaluationMapper.update(id, status);
|
||||
}
|
||||
}
|
@ -0,0 +1,226 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.constant.MessageConstant;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.enumeration.ModelLifecycle;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.ModelMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.ModelService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ModelServiceImpl implements ModelService {
|
||||
@Autowired
|
||||
private ModelMapper modelMapper;
|
||||
/**
|
||||
* 创建模型
|
||||
* @param dto
|
||||
*/
|
||||
@Transactional //事务注解
|
||||
@Override
|
||||
public void createModel(ModelDTO dto) {
|
||||
log.info("创建模型");
|
||||
//1.插入模型基本信息
|
||||
ModelInfo modelInfo = new ModelInfo();
|
||||
BeanUtils.copyProperties(dto, modelInfo, "id");
|
||||
modelMapper.insertModelInfo(modelInfo);
|
||||
log.info("模型id: {}", modelInfo.getId());
|
||||
//2.插入模型版本信息
|
||||
ModelVersion modelVersion = new ModelVersion();
|
||||
//使用工具类将dto属性复制给modelVersion
|
||||
BeanUtils.copyProperties(dto, modelVersion, "id");
|
||||
modelVersion.setModelId(modelInfo.getId());
|
||||
modelVersion.setCreateTime(LocalDateTime.now());
|
||||
modelVersion.setUpdateTime(LocalDateTime.now());
|
||||
modelVersion.setOperateUser("zs"); //这里的写死的,后续需要修改,应该是当前登录用户的id
|
||||
modelMapper.insertModelVersion(modelVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增模型版本
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void createModelVersion(ModelDTO dto) {
|
||||
log.info("新增模型版本");
|
||||
ModelVersion modelVersion = new ModelVersion();
|
||||
BeanUtils.copyProperties(dto, modelVersion, "id");
|
||||
modelVersion.setModelId(dto.getId());
|
||||
modelVersion.setCreateTime(LocalDateTime.now());
|
||||
modelVersion.setUpdateTime(LocalDateTime.now());
|
||||
modelVersion.setOperateUser("zs");
|
||||
modelMapper.insertModelVersion(modelVersion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模型列表
|
||||
*/
|
||||
@Override
|
||||
public List<ModelVO> list() {
|
||||
log.info("查询模型列表");
|
||||
List<ModelVO> modelVOList = modelMapper.list();
|
||||
return modelVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询模型详情
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public ModelVersion detail(Long id) {
|
||||
log.info("查询模型详情");
|
||||
ModelVersion modelVersion = modelMapper.selectById(id);
|
||||
return modelVersion;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模型
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void updateModel(ModelVersionDTO dto) {
|
||||
// TODO: 更新模型还需要更新操作人和时间
|
||||
log.info("更新模型");
|
||||
dto.setCreateTime(LocalDateTime.now());
|
||||
dto.setUpdateTime(LocalDateTime.now());
|
||||
modelMapper.update(dto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模型版本
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void deleteModelVersion(Long id) {
|
||||
log.info("删除模型版本");
|
||||
modelMapper.deleteModelVersion(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模型生命周期
|
||||
* @param id 版本表id
|
||||
* @param
|
||||
*/
|
||||
@Override
|
||||
public void updateLifeCycle(Long id, String lifeCycleDescription) {
|
||||
log.info("更新模型生命周期");
|
||||
|
||||
// 1. 查询当前生命周期并转为枚举
|
||||
String currentLifeCycleStr = modelMapper.selectLifeCycleById(id);
|
||||
if (currentLifeCycleStr == null) {
|
||||
log.error("未找到对应模型信息,无法更新生命周期");
|
||||
throw new IllegalArgumentException(MessageConstant.LifeCycle_No_Exist);
|
||||
}
|
||||
|
||||
ModelLifecycle currentLifeCycle;
|
||||
ModelLifecycle targetLifeCycle;
|
||||
try {
|
||||
currentLifeCycle = ModelLifecycle.valueOf(currentLifeCycleStr.trim()); // 数据库中是英文
|
||||
targetLifeCycle = ModelLifecycle.valueOf(lifeCycleDescription.trim()); // 前端传英文代码,直接转换
|
||||
} catch (IllegalArgumentException e) {
|
||||
log.error(MessageConstant.LifeCycle_Undefined + ":{}", e.getMessage());
|
||||
throw e;
|
||||
}
|
||||
|
||||
// 2. 业务逻辑校验(保持不变)
|
||||
switch (currentLifeCycle) {
|
||||
case DEPLOYED:
|
||||
if (targetLifeCycle == ModelLifecycle.DESIGNING) {
|
||||
log.error("已部署的模型不能直接调整成设计,需先下线再设计");
|
||||
throw new IllegalArgumentException(MessageConstant.ERROR_DEPLOYED_TO_DESIGNING);
|
||||
}
|
||||
break;
|
||||
case ABANDONED:
|
||||
log.error("已废弃的模型只能查看信息,不能更新生命周期");
|
||||
throw new IllegalArgumentException(MessageConstant.ERROR_ABANDONED_CANNOT_UPDATE);
|
||||
case TRAINING:
|
||||
if (targetLifeCycle != ModelLifecycle.DESIGNING && targetLifeCycle != ModelLifecycle.EVALUATING) {
|
||||
log.error("训练中的模型只能调整成设计和评估");
|
||||
throw new IllegalArgumentException(MessageConstant.ERROR_TRAINING_INVALID_TRANSITION);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// 3. 执行更新
|
||||
int affectedRows = modelMapper.updateLifeCycleById(id, targetLifeCycle.getDbValue());
|
||||
if (affectedRows == 0) {
|
||||
log.error("更新模型生命周期失败");
|
||||
throw new RuntimeException(MessageConstant.LIFECYCLE_UPDATE_FAILURE);
|
||||
}
|
||||
|
||||
log.info("模型生命周期更新成功,新状态为: {}", targetLifeCycle);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型生命周期列表
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, String>> listLifeCycle() {
|
||||
return Arrays.stream(ModelLifecycle.values())
|
||||
.map(lifecycle -> Map.of(
|
||||
"code", lifecycle.name(), // 枚举名称(如 "DESIGNING")
|
||||
"description", lifecycle.getDescription() // 中文描述(如 "设计中")
|
||||
))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型数据集列表
|
||||
*/
|
||||
@Override
|
||||
public List<DatasetEntity> listDataset() {
|
||||
List<DatasetEntity> datasetEntityList = modelMapper.listDataset();
|
||||
return datasetEntityList;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型训练信息
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public ModelTrainInfoVO getModelTrainInfo(Long id) {
|
||||
ModelTrainInfoVO modelTrainInfoVO = modelMapper.getModelTrainInfo(id);
|
||||
return modelTrainInfoVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型训练(把模型修改成训练中)
|
||||
* @param id
|
||||
*/
|
||||
@Override
|
||||
public void updateModelTrain(Long id) {
|
||||
// 更新当前模型的生命周期为训练中
|
||||
modelMapper.updateLifeCycleById(id, ModelLifecycle.TRAINING.getDbValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* 模型小版本更新
|
||||
* @param dto
|
||||
*/
|
||||
@Override
|
||||
public void updateModelVersionMinor(ModelVersionDTO dto) {
|
||||
// 更新模型小版本(其实是新增一个小版本)
|
||||
ModelVersion modelVersion = new ModelVersion();
|
||||
BeanUtils.copyProperties(dto, modelVersion, "id", "modelId");
|
||||
modelVersion.setModelId(dto.getModelId()); // 把模型id设置成该模型版本关联的模型id
|
||||
modelVersion.setCreateTime(LocalDateTime.now());
|
||||
modelVersion.setUpdateTime(LocalDateTime.now());
|
||||
modelVersion.setOperateUser("zs");
|
||||
// TODO: 后续可能还需要更新操作人
|
||||
modelMapper.insertModelVersion(modelVersion);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.ModelSelectVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.PublishMapper;
|
||||
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;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PublishServiceImpl implements PublishService {
|
||||
|
||||
@Autowired
|
||||
private PublishMapper publishMapper;
|
||||
/**
|
||||
* 新增服务请求
|
||||
* @param servicePublishDTO
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void save(ServicePublishDTO servicePublishDTO) {
|
||||
String apiUrl = servicePublishDTO.getApiUrl();
|
||||
Long id = publishMapper.getByApiUrl(apiUrl);
|
||||
if (id != null){
|
||||
throw new IllegalArgumentException("请求已存在: " + apiUrl);
|
||||
}
|
||||
|
||||
publishMapper.insert(servicePublishDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ServicePublishVO> listPublishedServices() {
|
||||
return publishMapper.listPublishedServices();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ModelSelectVO> getModelNames() {
|
||||
return publishMapper.selectModelSelectList();
|
||||
}
|
||||
|
||||
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user