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