服务发布
This commit is contained in:
@ -63,3 +63,17 @@ redis设计
|
||||
|
||||
### 📅 明日计划
|
||||
完成redis设计,做完服务发布的逻辑开发
|
||||
|
||||
## 2025年5月21日
|
||||
### ✅ 今日完成
|
||||
redis的服务器配置
|
||||
|
||||
### 🚧 进行中
|
||||
开发服务发布的redis内容
|
||||
|
||||
### ⚠️ 问题/障碍
|
||||
如何把model_version表中的配置中相关GPU资源的内容提取出来。
|
||||
|
||||
|
||||
### 📅 明日计划
|
||||
完成服务发布的开发
|
@ -1,18 +1,21 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.config.RedisConfiguration;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Tag(name ="服务发布相关接口")
|
||||
@RestController
|
||||
@RequestMapping("/publish")
|
||||
@ -21,6 +24,8 @@ public class publishController {
|
||||
@Autowired
|
||||
private PublishService publishService;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
/**
|
||||
* 新增请求发布
|
||||
* @param servicePublishDTO
|
||||
@ -28,13 +33,29 @@ public class publishController {
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary ="新增发布请求")
|
||||
@Transactional
|
||||
public OptResult<ServicePublishVO> save(@RequestBody ServicePublishDTO servicePublishDTO){
|
||||
log.info("模型发布请求:{}", servicePublishDTO);
|
||||
publishService.save(servicePublishDTO);
|
||||
ServicePublishVO servicePublishVO = publishService.getByModelId(servicePublishDTO);
|
||||
Long modelId = servicePublishDTO.getModelId();
|
||||
String key="Model_" + modelId;
|
||||
//查询redis是否存在GPU相关资源数据
|
||||
ServicePublishVO servicePublishVO = (ServicePublishVO) redisTemplate.opsForValue().get(key);
|
||||
//如果存在,直接返回,无须查询数据库
|
||||
if (servicePublishVO != null){
|
||||
return OptResult.success(servicePublishVO);
|
||||
}
|
||||
|
||||
String modelConfig = publishService.getByModelId(modelId);
|
||||
//todo 序列化结果提出来
|
||||
|
||||
ServicePublish servicePublish = new ServicePublish();
|
||||
String ip = servicePublishDTO.getIp();
|
||||
servicePublish.setIp(ip);
|
||||
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -14,8 +14,7 @@ public interface PublishMapper {
|
||||
void insert(ServicePublishDTO servicePublishDTO);
|
||||
|
||||
Long getByApiUrl(String apiUrl);
|
||||
@Select("select * from model_version where model_id=#{modelId} and status = 1")
|
||||
ModelVersion getById(Long modelId);
|
||||
@Select("select model_config from model_version where model_id=#{modelId} and status = 1")
|
||||
String getById(Long modelId);
|
||||
|
||||
ServicePublishVO getByModelId(Long modelId);
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ import java.time.LocalDateTime;
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ServicePublish implements Serializable {
|
||||
private Long id;
|
||||
private Long modelId;
|
||||
private String apiUrl;
|
||||
private LocalDateTime createTime;
|
||||
private String GPUModel;
|
||||
private String ip;
|
||||
private String GPUMemorySize;
|
||||
}
|
||||
|
@ -19,4 +19,5 @@ public class ServicePublishDTO implements Serializable {
|
||||
private Long modelId;
|
||||
private String apiUrl;
|
||||
private LocalDateTime createTime;
|
||||
private String ip;
|
||||
}
|
||||
|
@ -17,13 +17,9 @@ import java.time.LocalDateTime;
|
||||
@AllArgsConstructor
|
||||
public class ServicePublishVO implements Serializable {
|
||||
private Long modelId;
|
||||
private String apiUrl;
|
||||
private String version;
|
||||
private Integer datasetId;
|
||||
private String modelConfig;
|
||||
private String modelPath;
|
||||
private Integer status;
|
||||
private LocalDateTime createTime;
|
||||
private String GPUModel;
|
||||
private String ip;
|
||||
private String GPUMemorySize;
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.PublishMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ModelVersion;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -31,19 +29,17 @@ public class PublishServiceImpl implements PublishService {
|
||||
if (id != null){
|
||||
throw new IllegalArgumentException("请求已存在: " + apiUrl);
|
||||
}
|
||||
Long modelId = servicePublishDTO.getModelId();
|
||||
ModelVersion modelVersion = publishMapper.getById(modelId);
|
||||
String modelConfig = modelVersion.getModelConfig();
|
||||
//todo 调用GPU分配
|
||||
|
||||
|
||||
publishMapper.insert(servicePublishDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查找配置信息
|
||||
* @param modelId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public ServicePublishVO getByModelId(ServicePublishDTO servicePublishDTO) {
|
||||
Long modelId = servicePublishDTO.getModelId();
|
||||
return publishMapper.getByModelId(modelId);
|
||||
public String getByModelId(Long modelId) {
|
||||
return publishMapper.getById(modelId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,10 +1,13 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||
|
||||
public interface PublishService {
|
||||
|
||||
void save(ServicePublishDTO servicePublishDTO);
|
||||
|
||||
ServicePublishVO getByModelId(ServicePublishDTO servicePublishDTO);
|
||||
|
||||
|
||||
|
||||
String getByModelId(Long modelId);
|
||||
}
|
||||
|
@ -24,6 +24,6 @@ spring.data.redis.port=6379
|
||||
# Redis密码(如果有)
|
||||
spring.data.redis.password=Jbjhhzstsl97@
|
||||
# Redis数据库索引(默认为0)
|
||||
spring.data.redis.database=0
|
||||
spring.data.redis.database = 0
|
||||
# 连接超时时间(毫秒)
|
||||
spring.data.redis.timeout=3000
|
||||
spring.data.redis.timeout = 3000
|
||||
|
Reference in New Issue
Block a user