Compare commits
11 Commits
1cf3944744
...
dc-feature
Author | SHA1 | Date | |
---|---|---|---|
ddf44f9d2c | |||
12f602dc45 | |||
86a64f205f | |||
0aff6e71ff | |||
94bfc4cc70 | |||
158fdca6e0 | |||
92b470e001 | |||
49851384c8 | |||
0619c7d184 | |||
5dd1cfcf9e | |||
77a4b86cb4 |
56
pom.xml
56
pom.xml
@ -18,7 +18,7 @@
|
|||||||
<url/>
|
<url/>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>21</java.version>
|
<java.version>17</java.version>
|
||||||
<!-- 添加 Spring Cloud 版本控制 -->
|
<!-- 添加 Spring Cloud 版本控制 -->
|
||||||
<spring-cloud.version>2022.0.4</spring-cloud.version>
|
<spring-cloud.version>2022.0.4</spring-cloud.version>
|
||||||
</properties>
|
</properties>
|
||||||
@ -38,7 +38,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.alibaba.cloud</groupId>
|
<groupId>com.alibaba.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
<version>2022.0.0.0</version> <!-- 适配 Spring Boot 3.1.x 的正确版本 -->
|
<version>2022.0.0.0-RC2</version> <!-- 适配 Spring Boot 3.1.x 的正确版本 -->
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -59,19 +59,6 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-data-redis</artifactId>
|
<artifactId>spring-boot-starter-data-redis</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.hibernate</groupId>-->
|
|
||||||
<!-- <artifactId>hibernate-core</artifactId>-->
|
|
||||||
<!-- <version>6.4.5.Final</version> <!– 推荐稳定版本:ml-citation{ref="5,8" data="citationList"} –>-->
|
|
||||||
<!-- <exclusions>-->
|
|
||||||
<!-- <exclusion>-->
|
|
||||||
<!-- <groupId>org.jboss.logging</groupId> <!– 常见冲突源:ml-citation{ref="7" data="citationList"} –>-->
|
|
||||||
<!-- <artifactId>jboss-logging</artifactId>-->
|
|
||||||
<!-- </exclusion>-->
|
|
||||||
<!-- </exclusions>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
|
|
||||||
<!-- 数据库驱动 -->
|
|
||||||
|
|
||||||
<!-- 数据库驱动 -->
|
<!-- 数据库驱动 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -117,10 +104,10 @@
|
|||||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||||
<artifactId>spring-cloud-starter-gateway</artifactId>
|
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||||
|
<version>2.15.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- 测试依赖 -->
|
<!-- 测试依赖 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@ -138,24 +125,11 @@
|
|||||||
<version>3.0.4</version>
|
<version>3.0.4</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- <dependency>-->
|
|
||||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
|
||||||
<!-- <artifactId>spring-boot-starter-data-jpa</artifactId>-->
|
|
||||||
<!-- <exclusions>-->
|
|
||||||
<!-- <exclusion>-->
|
|
||||||
<!-- <groupId>org.hibernate.javax.persistence</groupId>-->
|
|
||||||
<!-- <artifactId>hibernate-jpa-2.1-api</artifactId>-->
|
|
||||||
<!-- </exclusion>-->
|
|
||||||
<!-- </exclusions>-->
|
|
||||||
<!-- </dependency>-->
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-amqp</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
@ -172,7 +146,15 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<!-- 排除 RabbitMQ 自动配置 -->
|
||||||
|
<exclusion>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-amqp</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-generator</artifactId>
|
<artifactId>mybatis-plus-generator</artifactId>
|
||||||
@ -204,6 +186,16 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.38</version>
|
<version>1.18.38</version>
|
||||||
</path>
|
</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>
|
</annotationProcessorPaths>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -2,6 +2,7 @@ package com.bipt.intelligentapplicationorchestrationservice;
|
|||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import org.slf4j.Logger;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
@ -11,9 +12,9 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableTransactionManagement
|
@EnableTransactionManagement
|
||||||
@EnableDiscoveryClient
|
@EnableDiscoveryClient
|
||||||
@Slf4j
|
//@Slf4j
|
||||||
public class IntelligentApplicationOrchestrationServiceApplication {
|
public class IntelligentApplicationOrchestrationServiceApplication {
|
||||||
|
private static final Logger log = org.slf4j.LoggerFactory.getLogger(IntelligentApplicationOrchestrationServiceApplication.class);
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(IntelligentApplicationOrchestrationServiceApplication.class, args);
|
SpringApplication.run(IntelligentApplicationOrchestrationServiceApplication.class, args);
|
||||||
log.info("server started");
|
log.info("server started");
|
||||||
|
@ -2,7 +2,7 @@ package com.bipt.intelligentapplicationorchestrationservice.cache;
|
|||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.service.CacheManager;
|
import com.bipt.intelligentapplicationorchestrationservice.service.CacheManager;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao;
|
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource;
|
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -2,7 +2,7 @@ package com.bipt.intelligentapplicationorchestrationservice.config;
|
|||||||
|
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.service.CacheManager;
|
import com.bipt.intelligentapplicationorchestrationservice.service.CacheManager;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource;
|
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||||
import org.aspectj.lang.JoinPoint;
|
import org.aspectj.lang.JoinPoint;
|
||||||
import org.aspectj.lang.annotation.AfterReturning;
|
import org.aspectj.lang.annotation.AfterReturning;
|
||||||
import org.aspectj.lang.annotation.Aspect;
|
import org.aspectj.lang.annotation.Aspect;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||||
|
|
||||||
import ch.qos.logback.classic.Logger;
|
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.ClientOptions;
|
||||||
import io.lettuce.core.SocketOptions;
|
import io.lettuce.core.SocketOptions;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -15,6 +18,7 @@ import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactor
|
|||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
|
|
||||||
@ -35,6 +39,11 @@ public class RedisConfig {
|
|||||||
@Value("${spring.data.redis.ssl:false}")
|
@Value("${spring.data.redis.ssl:false}")
|
||||||
private boolean useSsl;
|
private boolean useSsl;
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public RestTemplate restTemplate() {
|
||||||
|
return new RestTemplate();
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RedisConnectionFactory redisConnectionFactory() {
|
public RedisConnectionFactory redisConnectionFactory() {
|
||||||
// 1. 创建 SocketOptions
|
// 1. 创建 SocketOptions
|
||||||
@ -80,15 +89,12 @@ public class RedisConfig {
|
|||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public RedisTemplate<String, Object> redisTemplate(){
|
public RedisTemplate<String, Object> redisTemplate(){
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.registerModule(new JavaTimeModule());
|
||||||
|
objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||||
Logger log = (Logger) LoggerFactory.getLogger(RedisConfig.class);
|
Logger log = (Logger) LoggerFactory.getLogger(RedisConfig.class);
|
||||||
log.info("开始创建redis模板对象...");
|
log.info("开始创建redis模板对象...");
|
||||||
//RedisTemplate redisTemplate = new RedisTemplate();
|
|
||||||
//设置redis的连接工厂对象
|
|
||||||
//redisTemplate.setConnectionFactory(redisConnectionFactory);
|
|
||||||
//设置redis key的序列化器
|
|
||||||
//redisTemplate.setKeySerializer(new StringRedisSerializer());
|
|
||||||
//RedisTemplate<String, GpuResource> template = new RedisTemplate<>();
|
|
||||||
template.setConnectionFactory(redisConnectionFactory());
|
template.setConnectionFactory(redisConnectionFactory());
|
||||||
template.setKeySerializer(new StringRedisSerializer());
|
template.setKeySerializer(new StringRedisSerializer());
|
||||||
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.utils;
|
package com.bipt.intelligentapplicationorchestrationservice.constant;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
@ -1,15 +1,20 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.AlgorithmInfo;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.AlgorithmInfo;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.OptResult;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.service.AlgorithmInfoService;
|
import com.bipt.intelligentapplicationorchestrationservice.service.AlgorithmInfoService;
|
||||||
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@Tag(name ="算法创建相关接口")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/algorithm")
|
@RequestMapping("/api/algorithm")
|
||||||
|
@Slf4j
|
||||||
public class AlgorithmInfoController {
|
public class AlgorithmInfoController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -57,4 +62,16 @@ public class AlgorithmInfoController {
|
|||||||
ResponseEntity.ok("Delete successful") :
|
ResponseEntity.ok("Delete successful") :
|
||||||
ResponseEntity.badRequest().body("Delete failed");
|
ResponseEntity.badRequest().body("Delete failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 算法创建
|
||||||
|
*/
|
||||||
|
@PostMapping
|
||||||
|
@Operation(summary ="算法创建")
|
||||||
|
public OptResult save(@RequestBody AlgorithmInfo algorithmInfo){
|
||||||
|
log.info("新增算法",algorithmInfo);
|
||||||
|
algorithmInfoService.save(algorithmInfo);
|
||||||
|
return OptResult.success("算法创建成功");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,48 +1,42 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuCreateDTO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuCreateDTO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuResponseDTO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuResponseDTO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuUpdateDTO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuUpdateDTO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ResponseVO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.vo.ResponseVO;
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.service.GpuManageService;
|
import com.bipt.intelligentapplicationorchestrationservice.service.GpuManageService;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping
|
@RequestMapping
|
||||||
public class GpuResourceController {
|
public class GpuResourceController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private GpuManageService gpuManageService;
|
private GpuManageService gpuManageService;
|
||||||
|
@PostMapping(value = "/add", produces = "application/json")
|
||||||
@PostMapping
|
|
||||||
public ResponseVO addGpu(@Valid @RequestBody GpuCreateDTO dto){
|
public ResponseVO addGpu(@Valid @RequestBody GpuCreateDTO dto){
|
||||||
return gpuManageService.createGpuResource(dto);
|
return gpuManageService.createGpuResource(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@DeleteMapping("/{gpuId}")
|
@DeleteMapping("/{gpuId}")
|
||||||
public ResponseVO removeGpu(@PathVariable("gpuId") Long gpuId){
|
public ResponseVO removeGpu(@PathVariable("gpuId") Long gpuId){
|
||||||
return gpuManageService.deleteGpuResource(gpuId);
|
return gpuManageService.deleteGpuResource(gpuId);
|
||||||
}
|
}
|
||||||
|
@PutMapping(value = "/update/{gpuId}", produces = "application/json")
|
||||||
@PutMapping("/{gpuId}")
|
|
||||||
public void updateGpuResource(
|
public void updateGpuResource(
|
||||||
@PathVariable Long gpuId,
|
@PathVariable("gpuId") Long gpuId,
|
||||||
@Valid @RequestBody GpuUpdateDTO dto){
|
@Valid @RequestBody GpuUpdateDTO dto){
|
||||||
|
if (gpuId == null) {
|
||||||
|
throw new IllegalArgumentException("GPU ID cannot be null");
|
||||||
|
}
|
||||||
dto.setGPUId(gpuId);
|
dto.setGPUId(gpuId);
|
||||||
gpuManageService.updateGpuResource(dto);
|
gpuManageService.updateGpuResource(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/search")
|
@GetMapping("/search")
|
||||||
public ResponseVO<List<GpuResponseDTO>> searchGpuResources(
|
public ResponseVO<List<GpuResponseDTO>> searchGpuResources(
|
||||||
@RequestParam(required = false) String model,
|
@RequestParam(required = false) String model,
|
||||||
@RequestParam(required = false) Integer memorySize,
|
@RequestParam(required = false) Integer memorySize,
|
||||||
@RequestParam(required = false) String ip){
|
@RequestParam(required = false) String ip){
|
||||||
|
|
||||||
List<GpuResponseDTO> resources = gpuManageService.searchByCriteria(model, memorySize,ip);
|
List<GpuResponseDTO> resources = gpuManageService.searchByCriteria(model, memorySize,ip);
|
||||||
|
|
||||||
return ResponseVO.success(resources);
|
return ResponseVO.success(resources);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,6 @@ public class PublishController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PublishService publishService;
|
private PublishService publishService;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private RedisTemplate redisTemplate;
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private NacosServiceUtil nacosServiceUtil;
|
private NacosServiceUtil nacosServiceUtil;
|
||||||
|
|
||||||
|
@ -74,13 +74,16 @@ public class ServiceAPIController {
|
|||||||
return OptResult.success("资源释放成功");
|
return OptResult.success("资源释放成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/request")
|
@PostMapping("/request/{modelId}")
|
||||||
@Operation(summary = "请求调度")
|
@Operation(summary = "请求调度")
|
||||||
@Transactional
|
@Transactional
|
||||||
public OptResult schedule(@PathVariable Long modelId) {
|
public OptResult schedule(@PathVariable Long modelId) {
|
||||||
// 1. 存储modelConfig到缓存
|
// 1. 存储modelConfig到缓存
|
||||||
String modelConfig = serviceAPIService.getByModelId(modelId);
|
String modelConfig = serviceAPIService.getByModelId(modelId);
|
||||||
int requestMemorySize = parseGpuMemorySize(modelConfig);
|
int requestMemorySize = parseGpuMemorySize(modelConfig);
|
||||||
|
if (requestMemorySize == -1){
|
||||||
|
return OptResult.error("解析配置失败,请检查模型:" + modelId +"是否存在");
|
||||||
|
}
|
||||||
String modelConfigKey = "modelConfig:" + modelId;
|
String modelConfigKey = "modelConfig:" + modelId;
|
||||||
redisTemplate.opsForValue().set(modelConfigKey, modelConfig);
|
redisTemplate.opsForValue().set(modelConfigKey, modelConfig);
|
||||||
// 2. 获取Nacos实例IP列表
|
// 2. 获取Nacos实例IP列表
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.deploy.entity;
|
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource;
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class DeploymentResource {
|
|
||||||
private final GpuResource gpu;
|
|
||||||
private final String url;
|
|
||||||
}
|
|
@ -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 +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.deploy.entity;
|
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||||
|
|
||||||
public class DeployResponse<T> {
|
public class DeployResponse<T> {
|
||||||
private boolean isSuccess;
|
private boolean isSuccess;
|
@ -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 GpuEntityTransfer {
|
||||||
|
GpuResource toEntity(GpuCreateDTO dto);
|
||||||
|
GpuResource toEntity(GpuUpdateDTO dto);
|
||||||
|
GpuResource toEntity(GpuResponseDTO dto);
|
||||||
|
GpuResponseDTO toDTO(GpuResource entity);
|
||||||
|
}
|
@ -1,8 +1,7 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.entity.entity;
|
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
@ -10,15 +9,12 @@ import java.time.LocalDateTime;
|
|||||||
@Setter
|
@Setter
|
||||||
@Data
|
@Data
|
||||||
public class GpuResource {
|
public class GpuResource {
|
||||||
@Getter
|
|
||||||
@TableField("GPUId")
|
@TableField("GPUId")
|
||||||
private Long GPUId;
|
private Long GPUId;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@TableField("GPUModel")
|
@TableField("GPUModel")
|
||||||
private String GPUModel;
|
private String GPUModel;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@TableField("GPUMemorySize")
|
@TableField("GPUMemorySize")
|
||||||
private Integer GPUMemorySize;
|
private Integer GPUMemorySize;
|
||||||
|
|
||||||
@ -28,15 +24,12 @@ public class GpuResource {
|
|||||||
@TableField("Ip")
|
@TableField("Ip")
|
||||||
private String Ip;
|
private String Ip;
|
||||||
|
|
||||||
@Getter
|
@TableField("created_time")
|
||||||
@TableField("CreatedTime")
|
private LocalDateTime createTime;
|
||||||
private LocalDateTime CreateTime;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@TableField("update_time")
|
@TableField("update_time")
|
||||||
private LocalDateTime UpdateTime;
|
private LocalDateTime UpdateTime;
|
||||||
|
|
||||||
@Getter
|
|
||||||
@TableField("GPUMaxMemory")
|
@TableField("GPUMaxMemory")
|
||||||
private Integer GPUMaxMemory;
|
private Integer GPUMaxMemory;
|
||||||
|
|
||||||
@ -60,37 +53,58 @@ public class GpuResource {
|
|||||||
this.GPUModel = Model;
|
this.GPUModel = Model;
|
||||||
this.GPUMemorySize = MemorySize;
|
this.GPUMemorySize = MemorySize;
|
||||||
this.Ip = ip;
|
this.Ip = ip;
|
||||||
this.CreateTime = create_time;
|
this.createTime = create_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GpuResource() {}
|
public GpuResource() {}
|
||||||
|
|
||||||
// public void setGPUId(Long GPUId) {
|
public Integer getGPUMemorySize() {
|
||||||
// this.GPUId = GPUId;
|
return GPUMemorySize;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void setGPUModel(String GPUModel) {
|
public Long getGPUId() {
|
||||||
// this.GPUModel = GPUModel;
|
return GPUId;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void setGPUMemorySize(Integer GPUMemorySize) {
|
public String getGPUModel() {
|
||||||
// this.GPUMemorySize = GPUMemorySize;
|
return GPUModel;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void setIsDeleted(Integer isDeleted) {
|
public String getIp() {
|
||||||
// this.isDeleted = isDeleted;
|
return Ip;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void setIp(String ip) {
|
public LocalDateTime getCreateTime() {
|
||||||
// Ip = ip;
|
return createTime;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void setCreateTime(LocalDateTime createTime) {
|
public Integer getGPUMaxMemory() {
|
||||||
// CreateTime = createTime;
|
return GPUMaxMemory;
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// public void setUpdateTime(LocalDateTime updateTime) {
|
public void setGPUId(Long GPUId) {
|
||||||
// UpdateTime = updateTime;
|
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 + '\'' +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.entity.enums;
|
package com.bipt.intelligentapplicationorchestrationservice.enumeration;
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@ -19,7 +19,8 @@ public enum ErrorCodeEnum {
|
|||||||
DB_CONNECTION_FAILED(701, "数据库连接错误"),
|
DB_CONNECTION_FAILED(701, "数据库连接错误"),
|
||||||
VALIDATION_ERROR(801,"参数校验异常" ),
|
VALIDATION_ERROR(801,"参数校验异常" ),
|
||||||
|
|
||||||
CACHE_INIT_ERROR(901, "缓存初始化失败");
|
CACHE_INIT_ERROR(901, "缓存初始化失败"),
|
||||||
|
INTERNAL_SERVER_ERROR(201,"内部服务出错" );
|
||||||
|
|
||||||
public int getCode() {
|
public int getCode() {
|
||||||
return code;
|
return code;
|
@ -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("模型评估未通过,无法部署");
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.exception;
|
package com.bipt.intelligentapplicationorchestrationservice.exception;
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.enums.ErrorCodeEnum;
|
import com.bipt.intelligentapplicationorchestrationservice.enumeration.ErrorCodeEnum;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.vo.ResponseVO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ResponseVO;
|
||||||
import org.springframework.dao.DataAccessResourceFailureException;
|
import org.springframework.dao.DataAccessResourceFailureException;
|
||||||
import org.springframework.web.bind.MethodArgumentNotValidException;
|
import org.springframework.web.bind.MethodArgumentNotValidException;
|
||||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.exception;
|
package com.bipt.intelligentapplicationorchestrationservice.exception;
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.enums.ErrorCodeEnum;
|
import com.bipt.intelligentapplicationorchestrationservice.enumeration.ErrorCodeEnum;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@ -15,16 +15,12 @@ public class ApiRequestGlobalFilter implements GlobalFilter, Ordered {
|
|||||||
@Override
|
@Override
|
||||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||||
ServerHttpRequest request = exchange.getRequest();
|
ServerHttpRequest request = exchange.getRequest();
|
||||||
|
|
||||||
// 检查请求路径和方法
|
// 检查请求路径和方法
|
||||||
if (request.getURI().getPath().equals("/request") &&
|
if (request.getURI().getPath().equals("/request/{id}") &&
|
||||||
request.getMethod() == HttpMethod.POST) {
|
request.getMethod() == HttpMethod.POST) {
|
||||||
|
|
||||||
// 在此处添加拦截逻辑
|
// 在此处添加拦截逻辑
|
||||||
System.out.println("拦截到POST /request请求");
|
System.out.println("拦截到POST /request请求");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 继续处理请求
|
// 继续处理请求
|
||||||
return chain.filter(exchange);
|
return chain.filter(exchange);
|
||||||
}
|
}
|
@ -1,16 +0,0 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuCreateDTO;
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuResponseDTO;
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuUpdateDTO;
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.MappingConstants;
|
|
||||||
|
|
||||||
@Mapper(componentModel = MappingConstants.ComponentModel.SPRING)
|
|
||||||
public interface GpuMapper {
|
|
||||||
GpuResource toEntity(GpuCreateDTO dto);
|
|
||||||
GpuResource toEntity(GpuUpdateDTO dto);
|
|
||||||
GpuResource toEntity(GpuResponseDTO dto);
|
|
||||||
GpuResponseDTO toDTO(GpuResource entity);
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource;
|
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||||
import org.apache.ibatis.annotations.*;
|
import org.apache.ibatis.annotations.*;
|
||||||
import org.apache.ibatis.jdbc.SQL;
|
import org.apache.ibatis.jdbc.SQL;
|
||||||
|
|
||||||
@ -11,8 +11,8 @@ import java.util.Map;
|
|||||||
@Mapper
|
@Mapper
|
||||||
public interface GpuResourceDao {
|
public interface GpuResourceDao {
|
||||||
//---------------------- 基础CRUD ------------------------
|
//---------------------- 基础CRUD ------------------------
|
||||||
@Insert("INSERT INTO Ipz.public.gpu_resource (GPUModel, GPUMemorySize, Ip) " +
|
@Insert("INSERT INTO Ipz.public.gpu_resource (GPUModel, GPUMemorySize, Ip, created_time) " +
|
||||||
"VALUES (#{model}, #{memory}, #{ip})")
|
"VALUES (#{GPUModel}, #{GPUMemorySize}, #{Ip}, NOW())")
|
||||||
@Options(useGeneratedKeys = true, keyProperty = "GPUId")
|
@Options(useGeneratedKeys = true, keyProperty = "GPUId")
|
||||||
Integer insert(GpuResource entity);
|
Integer insert(GpuResource entity);
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ public interface GpuResourceDao {
|
|||||||
Integer isDeleted(@Param("gpuId") Long gpuId);
|
Integer isDeleted(@Param("gpuId") Long gpuId);
|
||||||
|
|
||||||
@Update("UPDATE Ipz.public.gpu_resource " +
|
@Update("UPDATE Ipz.public.gpu_resource " +
|
||||||
"SET GPUModel = #{model}, GPUMemorySize = #{memory}, Ip = #{ip} " +
|
"SET GPUModel = #{GPUModel}, GPUMemorySize = #{GPUMemorySize}, Ip = #{Ip} " +
|
||||||
"WHERE GPUId = #{GPUId}")
|
"WHERE GPUId = #{GPUId}")
|
||||||
Integer updateById(GpuResource entity);
|
Integer updateById(GpuResource entity);
|
||||||
|
|
||||||
|
@ -1,7 +1,16 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
public class AlgorithmInfo {
|
public class AlgorithmInfo {
|
||||||
private Long id;
|
private Long id;
|
||||||
private String algorithmName;
|
private String algorithmName;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.entity.dto;
|
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import jakarta.validation.constraints.Pattern;
|
import jakarta.validation.constraints.Pattern;
|
||||||
@ -14,14 +15,17 @@ public class GpuCreateDTO {
|
|||||||
@NotBlank(message = "GPU型号不能为空")
|
@NotBlank(message = "GPU型号不能为空")
|
||||||
@Pattern(regexp = "^([A-Z][A-Z0-9-]+)-\\w+",
|
@Pattern(regexp = "^([A-Z][A-Z0-9-]+)-\\w+",
|
||||||
message = "型号格式应为 [厂商(大写字母开头)]-[型号],如 Intel-Xe_GPU")
|
message = "型号格式应为 [厂商(大写字母开头)]-[型号],如 Intel-Xe_GPU")
|
||||||
|
@JsonProperty("GPUModel") // 显示指定JSON映射名称
|
||||||
private String GPUModel;
|
private String GPUModel;
|
||||||
|
|
||||||
@NotNull(message = "显存容量不能为空")
|
@NotNull(message = "显存容量不能为空")
|
||||||
|
@JsonProperty("GPUMemorySize")
|
||||||
private Integer GPUMemorySize;
|
private Integer GPUMemorySize;
|
||||||
|
|
||||||
@NotBlank(message = "IP地址不能为空")
|
@NotBlank(message = "IP地址不能为空")
|
||||||
@Pattern(regexp = "^\\\\d{1,3}\\\\.\\\\d{1,3}\\\\.\\\\d{1,3}\\\\.\\\\d{1,3}$",
|
@Pattern(regexp = "^(\\d{1,3}\\.){3}\\d{1,3}$",
|
||||||
message = "IP地址格式无效")
|
message = "IP地址格式无效")
|
||||||
|
@JsonProperty("Ip") // 显示指定JSON映射名称
|
||||||
private String Ip;
|
private String Ip;
|
||||||
|
|
||||||
}
|
}
|
@ -1,23 +1,30 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.entity.dto;
|
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 lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class GpuResponseDTO {
|
public class GpuResponseDTO {
|
||||||
private Long id;
|
@JsonView
|
||||||
|
private Long GPUId;
|
||||||
private String GPUModel;
|
private String GPUModel;
|
||||||
private Integer GPUMemorySize;
|
private Integer GPUMemorySize;
|
||||||
private String Ip;
|
private String Ip;
|
||||||
|
|
||||||
|
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
// Builder类
|
// Builder类
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private Long id;
|
private Long id;
|
||||||
private String model;
|
private String model;
|
||||||
private Integer memory;
|
private Integer memory;
|
||||||
private String ip;
|
private String ip;
|
||||||
private LocalDateTime createdTime;
|
private LocalDateTime createTime = LocalDateTime.now(); // 统一命名为createTime
|
||||||
|
|
||||||
public Builder id(Long id) {
|
public Builder id(Long id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -39,19 +46,29 @@ public class GpuResponseDTO {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder createdTime(LocalDateTime createdTime) {
|
public Builder createTime(LocalDateTime createTime) {
|
||||||
this.createdTime = createdTime;
|
this.createTime = createTime;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GpuResponseDTO build() {
|
public GpuResponseDTO build() {
|
||||||
// 必填字段校验(如网页2的推荐)
|
// 必填字段校验
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
throw new IllegalArgumentException("GPU ID必须填写");
|
throw new IllegalArgumentException("GPU ID必须填写");
|
||||||
}
|
}
|
||||||
return new GpuResponseDTO();
|
|
||||||
|
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.toString();
|
public String getCreateTimeStr() {
|
||||||
|
return "GPU创建时间:" + (createTime != null ? createTime.toString() : "未设置");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.entity.dto;
|
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||||
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import jakarta.validation.constraints.Pattern;
|
import jakarta.validation.constraints.Pattern;
|
||||||
@ -10,11 +10,30 @@ import lombok.*;
|
|||||||
//@Setter
|
//@Setter
|
||||||
//@Getter
|
//@Getter
|
||||||
public class GpuUpdateDTO {
|
public class GpuUpdateDTO {
|
||||||
public @NotNull(message = "GPU ID cannot be null") Long getGPUId() {
|
|
||||||
return GPUId;
|
private Long GPUId;
|
||||||
|
|
||||||
|
public @Pattern(regexp = "^([A-Z][A-Z0-9-]+)-\\w+",
|
||||||
|
message = "型号格式应为 [厂商(大写字母开头)]-[型号],如 Intel-Xe_GPU") String getGPUModel() {
|
||||||
|
return GPUModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGPUId(@NotNull(message = "GPU ID cannot be null") Long GPUId) {
|
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")
|
||||||
|
private String GPUModel;
|
||||||
|
|
||||||
|
private Integer GPUMemorySize;
|
||||||
|
|
||||||
|
@Pattern(regexp = "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$",
|
||||||
|
message = "IP地址格式无效")
|
||||||
|
private String Ip;
|
||||||
|
|
||||||
|
public void setGPUId(Long GPUId) {
|
||||||
this.GPUId = GPUId;
|
this.GPUId = GPUId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,18 +46,15 @@ public class GpuUpdateDTO {
|
|||||||
message = "IP地址格式无效") String ip) {
|
message = "IP地址格式无效") String ip) {
|
||||||
Ip = ip;
|
Ip = ip;
|
||||||
}
|
}
|
||||||
|
public Long getGPUId() {
|
||||||
|
return GPUId;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull(message = "GPU ID cannot be null")
|
public Integer getGPUMemorySize() {
|
||||||
private Long GPUId;
|
return GPUMemorySize;
|
||||||
|
}
|
||||||
|
|
||||||
@Pattern(regexp = "^([A-Z][A-Z0-9-]+)-\\w+",
|
public void setGPUMemorySize(Integer GPUMemorySize) {
|
||||||
message = "型号格式应为 [厂商(大写字母开头)]-[型号],如 Intel-Xe_GPU")
|
this.GPUMemorySize = GPUMemorySize;
|
||||||
private String GPUModel;
|
}
|
||||||
|
|
||||||
@Setter
|
|
||||||
private Integer GPUMemorySize;
|
|
||||||
|
|
||||||
@Pattern(regexp = "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$",
|
|
||||||
message = "IP地址格式无效")
|
|
||||||
private String Ip;
|
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.entity.vo;
|
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.enums.ErrorCodeEnum;
|
import com.bipt.intelligentapplicationorchestrationservice.enumeration.ErrorCodeEnum;
|
||||||
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
@ -33,6 +33,30 @@ public class ResponseVO<T> implements Serializable {
|
|||||||
}
|
}
|
||||||
//失败响应(基于预定义错误枚举)
|
//失败响应(基于预定义错误枚举)
|
||||||
public static <T> ResponseVO<T> error(ErrorCodeEnum errorCode) {
|
public static <T> ResponseVO<T> error(ErrorCodeEnum errorCode) {
|
||||||
return new ResponseVO<>(errorCode.getCode(), errorCode.getMessage(), null);
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -18,6 +19,7 @@ public class ServicePublishDTO implements Serializable {
|
|||||||
private Long id;
|
private Long id;
|
||||||
private Long modelId;
|
private Long modelId;
|
||||||
private String apiUrl;
|
private String apiUrl;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private LocalDateTime createTime;
|
private LocalDateTime createTime;
|
||||||
private String ip;
|
private String ip;
|
||||||
}
|
}
|
||||||
|
@ -11,4 +11,7 @@ public interface AlgorithmInfoService {
|
|||||||
boolean update(AlgorithmInfo algorithmInfo);
|
boolean update(AlgorithmInfo algorithmInfo);
|
||||||
boolean delete(Long id);
|
boolean delete(Long id);
|
||||||
boolean validateAlgorithmInfo(AlgorithmInfo algorithmInfo);
|
boolean validateAlgorithmInfo(AlgorithmInfo algorithmInfo);
|
||||||
}
|
|
||||||
|
void save(AlgorithmInfo algorithmInfo);
|
||||||
|
|
||||||
|
}
|
@ -2,7 +2,7 @@ package com.bipt.intelligentapplicationorchestrationservice.service;
|
|||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao;
|
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.exception.CacheInitException;
|
import com.bipt.intelligentapplicationorchestrationservice.exception.CacheInitException;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource;
|
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuCreateDTO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuCreateDTO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuResponseDTO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuResponseDTO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuUpdateDTO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuUpdateDTO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.vo.ResponseVO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ResponseVO;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -12,4 +13,7 @@ public interface GpuManageService {
|
|||||||
public ResponseVO deleteGpuResource(Long gpuId);
|
public ResponseVO deleteGpuResource(Long gpuId);
|
||||||
public void updateGpuResource(GpuUpdateDTO entity);
|
public void updateGpuResource(GpuUpdateDTO entity);
|
||||||
public List<GpuResponseDTO> searchByCriteria(String model, Integer memorySize, String ip);
|
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());
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -60,4 +60,23 @@ public class AlgorithmInfoServiceImpl implements AlgorithmInfoService {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 算法创建
|
||||||
|
* @param algorithmInfo
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public void save(AlgorithmInfo algorithmInfo) {
|
||||||
|
String algorithmName = algorithmInfo.getAlgorithmName();
|
||||||
|
//查找表里是否有重复的算法,如果有则报错
|
||||||
|
AlgorithmInfo duplicateName = algorithmInfoMapper.selectByName(algorithmName);
|
||||||
|
if (duplicateName != null){
|
||||||
|
throw new RuntimeException("算法已存在");
|
||||||
|
}
|
||||||
|
//todo 算法文件分布式存入分布式存储中
|
||||||
|
|
||||||
|
|
||||||
|
algorithmInfoMapper.insert(algorithmInfo);
|
||||||
|
}
|
||||||
}
|
}
|
@ -0,0 +1,97 @@
|
|||||||
|
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||||
|
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.entity.DeployRequest;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.entity.DeployResponse;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.entity.ModelInfo;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.exception.DeployException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ModelDeployer {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ModelRepositoryClient modelRepositoryClient;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ModelEvaluator modelEvaluationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private NormalDeployService normalDeployService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GrayDeployService grayDeployService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResourceAllocator resourceAllocator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GpuResourceService gpuResourceService;
|
||||||
|
|
||||||
|
public DeployResponse deploy(DeployRequest request) {
|
||||||
|
try {
|
||||||
|
// 1. 获取完整模型信息
|
||||||
|
ModelInfo modelInfo = getModelInfo(request.getModelId());
|
||||||
|
|
||||||
|
// 2. 更新请求中的模型信息
|
||||||
|
request.setModelInfo(modelInfo);
|
||||||
|
|
||||||
|
// 3. 添加模型评估检查
|
||||||
|
if (!isEvaluationPassed(modelInfo)) {
|
||||||
|
return DeployResponse.fail(403,
|
||||||
|
"模型[" + modelInfo.getModelName() + "]评估未通过,无法部署");
|
||||||
|
}
|
||||||
|
List<GpuResource> availableResources = gpuResourceService.getAvailableResources();
|
||||||
|
int requiredMemory = request.getRequiredMemory();
|
||||||
|
String modelId = request.getModelId();
|
||||||
|
|
||||||
|
if (!resourceAllocator.checkResourceQuota(availableResources, requiredMemory, modelId)){
|
||||||
|
return DeployResponse.fail(507, "资源配额不足。需要内存: " + requiredMemory + "MB\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 根据部署类型路由
|
||||||
|
if (request.getDeployType() == DeployRequest.DeployType.NORMAL) {
|
||||||
|
return normalDeployService.process(request);
|
||||||
|
} else {
|
||||||
|
return grayDeployService.process(request);
|
||||||
|
}
|
||||||
|
} catch (DeployException e) {
|
||||||
|
return DeployResponse.fail(404, "获取模型信息失败: " + e.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return DeployResponse.fail(500, "部署失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从模型仓库获取模型详细信息
|
||||||
|
*/
|
||||||
|
private ModelInfo getModelInfo(String modelId) {
|
||||||
|
// 添加缓存和重试机制
|
||||||
|
ModelInfo modelInfo = modelRepositoryClient.getModelInfo(modelId);
|
||||||
|
|
||||||
|
// 验证关键字段
|
||||||
|
if (modelInfo.getModelFilePath() == null) {
|
||||||
|
throw new DeployException("模型文件路径未定义");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取额外信息
|
||||||
|
modelInfo.setStorageLocation(
|
||||||
|
modelRepositoryClient.getModelStorageLocation(modelId)
|
||||||
|
);
|
||||||
|
|
||||||
|
return modelInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查模型评估状态
|
||||||
|
*/
|
||||||
|
private boolean isEvaluationPassed(ModelInfo modelInfo) {
|
||||||
|
return modelEvaluationService.isEvaluationPassed(
|
||||||
|
modelInfo.getModelId()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ModelEvaluator {
|
||||||
|
@Value("${model.evaluation.service-url}")
|
||||||
|
private String evaluationServiceUrl;
|
||||||
|
|
||||||
|
@Value("${model.evaluation.api-timeout:3000}")
|
||||||
|
private int apiTimeout;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查模型评估是否通过
|
||||||
|
* @param modelId 模型ID
|
||||||
|
* @return 评估是否通过
|
||||||
|
*/
|
||||||
|
public boolean isEvaluationPassed(String modelId) {
|
||||||
|
return isEvaluationPassed(modelId, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查模型评估是否通过(带版本号)
|
||||||
|
* @param modelId 模型ID
|
||||||
|
* @param version 模型版本
|
||||||
|
* @return 评估是否通过
|
||||||
|
*/
|
||||||
|
public boolean isEvaluationPassed(String modelId, String version) {
|
||||||
|
// 1. 构建API调用参数
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("modelId", modelId);
|
||||||
|
if (version != null) {
|
||||||
|
params.put("version", version);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 2. 设置请求头和超时
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
headers.set("X-Request-ID", generateRequestId(modelId));
|
||||||
|
|
||||||
|
// 3. 调用评估API
|
||||||
|
ResponseEntity<EvaluationResponse> response = restTemplate.exchange(
|
||||||
|
buildEvaluationUrl(modelId, version),
|
||||||
|
HttpMethod.GET,
|
||||||
|
new HttpEntity<>(headers),
|
||||||
|
EvaluationResponse.class
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4. 处理响应
|
||||||
|
if (response.getStatusCode() == HttpStatus.OK && response.getBody() != null) {
|
||||||
|
return response.getBody().isPassed();
|
||||||
|
} else if (response.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
logEvaluationWarning(modelId, "模型未找到");
|
||||||
|
} else {
|
||||||
|
logEvaluationError(modelId, "评估服务返回非200状态: " + response.getStatusCode());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
logEvaluationError(modelId, "评估服务调用失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. 默认返回失败
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ================= 辅助方法 =================
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建评估API URL
|
||||||
|
*/
|
||||||
|
private String buildEvaluationUrl(String modelId, String version) {
|
||||||
|
String baseUrl = evaluationServiceUrl + "/models/" + modelId + "/evaluation";
|
||||||
|
return version != null ? baseUrl + "?version=" + version : baseUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成请求ID(用于日志追踪)
|
||||||
|
*/
|
||||||
|
private String generateRequestId(String modelId) {
|
||||||
|
return "eval-" + modelId + "-" + System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录评估错误日志
|
||||||
|
*/
|
||||||
|
private void logEvaluationError(String modelId, String message) {
|
||||||
|
// 实际实现应使用日志框架(如SLF4J)
|
||||||
|
System.err.println("[" + modelId + "] 评估错误: " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 记录评估警告日志
|
||||||
|
*/
|
||||||
|
private void logEvaluationWarning(String modelId, String message) {
|
||||||
|
// 实际实现应使用日志框架
|
||||||
|
System.out.println("[" + modelId + "] 评估警告: " + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 评估响应内部类
|
||||||
|
*/
|
||||||
|
private static class EvaluationResponse {
|
||||||
|
private boolean passed;
|
||||||
|
private String reason;
|
||||||
|
private String evaluatedAt;
|
||||||
|
|
||||||
|
// 需要默认构造方法用于JSON反序列化
|
||||||
|
public EvaluationResponse() {}
|
||||||
|
|
||||||
|
public boolean isPassed() {
|
||||||
|
return passed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getReason() {
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getEvaluatedAt() {
|
||||||
|
return evaluatedAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,98 @@
|
|||||||
|
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||||
|
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.entity.ModelInfo;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.exception.DeployException;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.http.*;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class ModelRepositoryClient {
|
||||||
|
|
||||||
|
@Value("${model.repository.url}")
|
||||||
|
private String repositoryBaseUrl;
|
||||||
|
|
||||||
|
@Value("${model.repository.api-key}")
|
||||||
|
private String apiKey;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RestTemplate restTemplate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从模型仓库获取模型信息
|
||||||
|
*
|
||||||
|
* @param modelId 模型唯一标识
|
||||||
|
* @return 完整的模型信息对象
|
||||||
|
*/
|
||||||
|
public ModelInfo getModelInfo(String modelId) {
|
||||||
|
// 1. 构建请求URL
|
||||||
|
String url = repositoryBaseUrl + "/models/" + modelId + "/info";
|
||||||
|
|
||||||
|
// 2. 设置认证头
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
headers.set("X-API-KEY", apiKey);
|
||||||
|
headers.set("Model-Id", modelId);
|
||||||
|
|
||||||
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 3. 发送请求到模型仓库服务
|
||||||
|
ResponseEntity<ModelInfo> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.GET,
|
||||||
|
entity,
|
||||||
|
ModelInfo.class
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4. 处理响应
|
||||||
|
if (response.getStatusCode() == HttpStatus.OK && response.getBody() != null) {
|
||||||
|
return response.getBody();
|
||||||
|
} else if (response.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
throw new DeployException("模型未找到: " + modelId);
|
||||||
|
} else {
|
||||||
|
throw new DeployException("获取模型信息失败,状态码: " + response.getStatusCode());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new DeployException("访问模型仓库失败: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public String getModelStorageLocation(String modelId) {
|
||||||
|
// 1. 构建请求URL
|
||||||
|
String url = repositoryBaseUrl + "/models/" + modelId + "/storage-location";
|
||||||
|
|
||||||
|
// 2. 设置认证头
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||||
|
headers.set("X-API-KEY", apiKey);
|
||||||
|
headers.setAccept(Collections.singletonList(MediaType.TEXT_PLAIN));
|
||||||
|
|
||||||
|
HttpEntity<?> entity = new HttpEntity<>(headers);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 3. 发送请求到模型仓库服务
|
||||||
|
ResponseEntity<String> response = restTemplate.exchange(
|
||||||
|
url,
|
||||||
|
HttpMethod.GET,
|
||||||
|
entity,
|
||||||
|
String.class
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4. 处理响应
|
||||||
|
if (response.getStatusCode() == HttpStatus.OK && response.getBody() != null) {
|
||||||
|
return response.getBody();
|
||||||
|
} else if (response.getStatusCode() == HttpStatus.NOT_FOUND) {
|
||||||
|
throw new DeployException("模型存储位置未找到: " + modelId);
|
||||||
|
} else {
|
||||||
|
throw new DeployException("获取存储位置失败,状态码: " + response.getStatusCode());
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new DeployException("访问模型仓库失败: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,118 @@
|
|||||||
|
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.entity.ModelInfo;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.exception.EvaluationFailedException;
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.util.TemplateParser;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
|
import java.nio.file.attribute.PosixFilePermission;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@Service
|
||||||
|
public class NormalDeployService {
|
||||||
|
@Autowired
|
||||||
|
private ModelEvaluator modelEvaluator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ResourceAllocator resourceAllocator;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GpuResourceService gpuService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TemplateParser templateParser; // 使用模板解析器
|
||||||
|
|
||||||
|
@Value("${model.deploy.script-directory:/opt/deploy_scripts}")
|
||||||
|
private String scriptDirectory;
|
||||||
|
|
||||||
|
@Value("${model.deploy.script-timeout:300}")
|
||||||
|
private int scriptTimeout;
|
||||||
|
|
||||||
|
public DeployResponse process(DeployRequest request) {
|
||||||
|
try {
|
||||||
|
// 1. 检查模型评估状态(使用ModelInfo包含的模型ID)
|
||||||
|
ModelInfo modelInfo = request.getModelInfo();
|
||||||
|
if (!modelEvaluator.isEvaluationPassed(modelInfo != null ? modelInfo.getModelName() : "")) {
|
||||||
|
throw new EvaluationFailedException("模型评估未通过");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 分配资源并获取URL
|
||||||
|
DeploymentResource resource = resourceAllocator.allocate(
|
||||||
|
gpuService.getAvailableResources(),
|
||||||
|
request.getRequiredMemory(),
|
||||||
|
modelInfo != null ? modelInfo.getModelName() : "unknown",
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
// 3. 使用ModelInfo生成部署脚本内容
|
||||||
|
String scriptContent = templateParser.generateDeploymentScript(
|
||||||
|
request.getModelInfo(),
|
||||||
|
resource.getUrl()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 4. 执行部署脚本
|
||||||
|
executeDeploymentScript(scriptContent);
|
||||||
|
|
||||||
|
// 5. 标记资源已分配
|
||||||
|
gpuService.markAsAllocated(
|
||||||
|
resource.getGpu().getGPUId(),
|
||||||
|
request.getRequiredMemory()
|
||||||
|
);
|
||||||
|
|
||||||
|
return DeployResponse.success(resource.getUrl());
|
||||||
|
|
||||||
|
} catch (EvaluationFailedException e) {
|
||||||
|
return DeployResponse.fail(403, e.getMessage());
|
||||||
|
} catch (Exception e) {
|
||||||
|
return DeployResponse.fail(500, "部署失败: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行部署脚本
|
||||||
|
*/
|
||||||
|
private void executeDeploymentScript(String scriptContent) throws Exception {
|
||||||
|
// 创建脚本文件
|
||||||
|
Path scriptPath = Paths.get(scriptDirectory, "deploy_" + System.currentTimeMillis() + ".sh");
|
||||||
|
Files.write(scriptPath, scriptContent.getBytes());
|
||||||
|
|
||||||
|
// 设置执行权限 (754)
|
||||||
|
Set<PosixFilePermission> permissions = Set.of(
|
||||||
|
PosixFilePermission.OWNER_READ,
|
||||||
|
PosixFilePermission.OWNER_WRITE,
|
||||||
|
PosixFilePermission.OWNER_EXECUTE,
|
||||||
|
PosixFilePermission.GROUP_READ,
|
||||||
|
PosixFilePermission.GROUP_EXECUTE,
|
||||||
|
PosixFilePermission.OTHERS_READ
|
||||||
|
);
|
||||||
|
Files.setPosixFilePermissions(scriptPath, permissions);
|
||||||
|
|
||||||
|
// 执行脚本
|
||||||
|
Process process = new ProcessBuilder(scriptPath.toString())
|
||||||
|
.directory(Paths.get(scriptDirectory).toFile())
|
||||||
|
.start();
|
||||||
|
|
||||||
|
// 带超时等待
|
||||||
|
boolean completed = process.waitFor(scriptTimeout, TimeUnit.SECONDS);
|
||||||
|
if (!completed) {
|
||||||
|
process.destroyForcibly();
|
||||||
|
throw new RuntimeException("脚本执行超时(限制: " + scriptTimeout + "秒)");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查退出码
|
||||||
|
if (process.exitValue() != 0) {
|
||||||
|
throw new RuntimeException("脚本执行失败,退出码: " + process.exitValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 清理脚本文件
|
||||||
|
Files.deleteIfExists(scriptPath);
|
||||||
|
}
|
||||||
|
}
|
@ -1,16 +1,19 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||||
|
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource;
|
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||||
|
import org.apache.ibatis.cache.CacheException;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.data.redis.connection.RedisConnection;
|
||||||
|
import org.springframework.data.redis.core.Cursor;
|
||||||
import org.springframework.data.redis.core.RedisCallback;
|
import org.springframework.data.redis.core.RedisCallback;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.ScanOptions;
|
||||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@ -124,4 +127,26 @@ public class RedisCacheService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public Set<String> scanKeys(String pattern) {
|
||||||
|
try (RedisConnection connection = Objects.requireNonNull(
|
||||||
|
redisTemplate.getConnectionFactory()).getConnection()) {
|
||||||
|
|
||||||
|
ScanOptions options = ScanOptions.scanOptions()
|
||||||
|
.match(pattern)
|
||||||
|
.count(100) // 批量扫描数量
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Set<String> keys = new HashSet<>();
|
||||||
|
Cursor<byte[]> cursor = connection.scan(options);
|
||||||
|
|
||||||
|
while (cursor.hasNext()) {
|
||||||
|
keys.add(new String(cursor.next(), StandardCharsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
return keys;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new CacheException("Keys scan failed", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.deploy.deployment;
|
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.deploy.entity.DeploymentResource;
|
import com.bipt.intelligentapplicationorchestrationservice.entity.DeploymentResource;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource;
|
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.utils.ConfigConstants;
|
import com.bipt.intelligentapplicationorchestrationservice.constant.ConfigConstants;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.web.client.ResourceAccessException;
|
import org.springframework.web.client.ResourceAccessException;
|
||||||
@ -16,6 +16,54 @@ public class ResourceAllocator {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ConfigConstants config;
|
private ConfigConstants config;
|
||||||
|
|
||||||
|
// 检查资源配额
|
||||||
|
public boolean checkResourceQuota(List<GpuResource> resources, int requiredMemory, String modelId) {
|
||||||
|
// 1. 检查全局资源是否充足
|
||||||
|
long totalFreeMemory = resources.stream()
|
||||||
|
.mapToInt(this::getRemainingMemory)
|
||||||
|
.sum();
|
||||||
|
|
||||||
|
// 全局内存不足
|
||||||
|
if (totalFreeMemory < requiredMemory) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. 检查单个GPU是否能满足需求
|
||||||
|
boolean canAllocate = resources.stream()
|
||||||
|
.anyMatch(gpu -> getRemainingMemory(gpu) >= requiredMemory);
|
||||||
|
|
||||||
|
if (!canAllocate) {
|
||||||
|
// 检查碎片化分配
|
||||||
|
return checkFragmentationAllocation(resources, requiredMemory);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查碎片化分配可能性
|
||||||
|
private boolean checkFragmentationAllocation(List<GpuResource> resources, int requiredMemory) {
|
||||||
|
// 按碎片率排序(碎片小的优先)
|
||||||
|
resources.sort(Comparator.comparingDouble(
|
||||||
|
r -> (double)getRemainingMemory(r) / r.getGPUMaxMemory()
|
||||||
|
));
|
||||||
|
|
||||||
|
// 检查碎片整合后是否可能满足需求
|
||||||
|
int accumulatedMemory = 0;
|
||||||
|
for (GpuResource gpu : resources) {
|
||||||
|
int fragment = getRemainingMemory(gpu);
|
||||||
|
// 如果单个碎片就足够,直接返回成功
|
||||||
|
if (fragment >= requiredMemory) return true;
|
||||||
|
|
||||||
|
// 累积碎片
|
||||||
|
accumulatedMemory += fragment;
|
||||||
|
if (accumulatedMemory >= requiredMemory) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//获取剩余内存
|
//获取剩余内存
|
||||||
private int getRemainingMemory(GpuResource resource){
|
private int getRemainingMemory(GpuResource resource){
|
||||||
return resource.getGPUMaxMemory()-resource.getGPUMemorySize();
|
return resource.getGPUMaxMemory()-resource.getGPUMemorySize();
|
@ -1,17 +1,19 @@
|
|||||||
package com.bipt.intelligentapplicationorchestrationservice.service.impl;
|
package com.bipt.intelligentapplicationorchestrationservice.service.impl;
|
||||||
|
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao;
|
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuMapper;
|
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuEntityTransfer;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuCreateDTO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuCreateDTO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuResponseDTO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuResponseDTO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.dto.GpuUpdateDTO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuUpdateDTO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource;
|
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.enums.ErrorCodeEnum;
|
import com.bipt.intelligentapplicationorchestrationservice.enumeration.ErrorCodeEnum;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.entity.vo.ResponseVO;
|
import com.bipt.intelligentapplicationorchestrationservice.pojo.ResponseVO;
|
||||||
import com.bipt.intelligentapplicationorchestrationservice.service.GpuManageService;
|
import com.bipt.intelligentapplicationorchestrationservice.service.GpuManageService;
|
||||||
import jakarta.transaction.Transactional;
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -20,53 +22,128 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class GpuManageServiceImpl implements GpuManageService {
|
public class GpuManageServiceImpl implements GpuManageService {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(GpuManageServiceImpl.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GpuResourceDao gpuDao;
|
private GpuResourceDao gpuDao;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GpuMapper gpuMapper;
|
private GpuEntityTransfer gpuEntityTransfer;
|
||||||
@Autowired
|
|
||||||
private GpuResourceDao gpuResourceDao;
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
//创建GPU资源
|
@Override
|
||||||
public ResponseVO createGpuResource(GpuCreateDTO dto) {
|
public ResponseVO createGpuResource(GpuCreateDTO dto) {
|
||||||
GpuResource entity = gpuMapper.toEntity(dto);
|
try {
|
||||||
gpuDao.insert(entity);
|
logger.info("创建GPU资源请求: {}", dto);
|
||||||
return ResponseVO.success(entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Transactional
|
GpuResource entity = gpuEntityTransfer.toEntity(dto);
|
||||||
//删除GPU资源(逻辑删除)
|
gpuDao.insert(entity);
|
||||||
public ResponseVO deleteGpuResource(Long gpuId) {
|
|
||||||
GpuResource entity = gpuDao.selectById(gpuId);
|
logger.info("创建GPU资源成功, ID: {}", entity.getGPUId());
|
||||||
if (entity == null) {
|
return ResponseVO.success(entity);
|
||||||
return ResponseVO.error(ErrorCodeEnum.GPU_NOT_FOUND);
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("创建GPU资源失败: {}, 参数: {}", e.getMessage(), dto, e);
|
||||||
|
return ResponseVO.error(ErrorCodeEnum.INTERNAL_SERVER_ERROR);
|
||||||
}
|
}
|
||||||
gpuDao.isDeleted(gpuId);
|
|
||||||
return ResponseVO.success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
//更新GPU资源
|
@Override
|
||||||
|
public ResponseVO deleteGpuResource(Long gpuId) {
|
||||||
|
logger.info("删除GPU资源请求, ID: {}", gpuId);
|
||||||
|
|
||||||
|
try {
|
||||||
|
GpuResource entity = gpuDao.selectById(gpuId);
|
||||||
|
if (entity == null) {
|
||||||
|
logger.warn("GPU资源不存在, ID: {}", gpuId);
|
||||||
|
return ResponseVO.error(ErrorCodeEnum.GPU_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
gpuDao.isDeleted(gpuId);
|
||||||
|
logger.info("逻辑删除GPU资源成功, ID: {}", gpuId);
|
||||||
|
return ResponseVO.success();
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("删除GPU资源失败, ID: {}, 错误: {}", gpuId, e.getMessage(), e);
|
||||||
|
return ResponseVO.error(ErrorCodeEnum.INTERNAL_SERVER_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
public void updateGpuResource(GpuUpdateDTO dto) {
|
public void updateGpuResource(GpuUpdateDTO dto) {
|
||||||
GpuResource entity = gpuMapper.toEntity(dto);
|
logger.info("更新GPU资源请求: {}", dto);
|
||||||
gpuDao.updateById(entity);
|
|
||||||
|
try {
|
||||||
|
GpuResource entity = gpuEntityTransfer.toEntity(dto);
|
||||||
|
gpuDao.updateById(entity);
|
||||||
|
logger.info("更新GPU资源成功, ID: {}", entity.getGPUId());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("更新GPU资源失败: {}, 参数: {}", e.getMessage(), dto, e);
|
||||||
|
throw new RuntimeException("更新GPU资源失败", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
//模糊匹配查询
|
|
||||||
public List<GpuResponseDTO> searchByCriteria(String model, Integer memorySize, String ip) {
|
public List<GpuResponseDTO> searchByCriteria(String model, Integer memorySize, String ip) {
|
||||||
// PermissionCheckUtil.checkTenantAccess();
|
|
||||||
|
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
if(model != null) params.put("model","%" + model + "%");
|
if(model != null) params.put("model", "%" + model + "%");
|
||||||
if(memorySize!=null) params.put("memorySize", memorySize);
|
if(memorySize != null) params.put("memorySize", memorySize);
|
||||||
if(ip!=null) params.put("ip", ip);
|
if(ip != null) params.put("ip", ip);
|
||||||
|
|
||||||
List<GpuResource> entities = gpuResourceDao.selectByFields(params);
|
logger.info("查询GPU资源条件: {}", params);
|
||||||
|
|
||||||
return entities.stream().map(gpuMapper::toDTO).collect(Collectors.toList());
|
try {
|
||||||
|
List<GpuResource> entities = gpuDao.selectByFields(params);
|
||||||
|
logger.info("查询到 {} 条GPU资源", entities.size());
|
||||||
|
|
||||||
|
return entities.stream()
|
||||||
|
.map(gpuEntityTransfer::toDTO)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logger.error("查询GPU资源失败, 条件: {}, 错误: {}", params, e.getMessage(), e);
|
||||||
|
throw new RuntimeException("查询GPU资源失败", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== 新增的日志追踪方法 ==========
|
||||||
|
|
||||||
|
private void logOperation(String methodName, Object... details) {
|
||||||
|
if (logger.isDebugEnabled()) {
|
||||||
|
StringBuilder logBuilder = new StringBuilder(methodName);
|
||||||
|
for (Object detail : details) {
|
||||||
|
logBuilder.append(" | ").append(detail);
|
||||||
|
}
|
||||||
|
logger.debug(logBuilder.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void logDuration(String methodName, long startTime, boolean success) {
|
||||||
|
long duration = System.currentTimeMillis() - startTime;
|
||||||
|
String status = success ? "成功" : "失败";
|
||||||
|
logger.info("方法 {} 执行{} | 耗时: {}ms", methodName, status, duration);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ========== 增强的日志版本 ==========
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public ResponseVO createGpuResourceWithTrace(GpuCreateDTO dto) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
try {
|
||||||
|
logOperation("createGpuResource", "请求参数", dto);
|
||||||
|
|
||||||
|
ResponseVO result = createGpuResource(dto);
|
||||||
|
|
||||||
|
logDuration("createGpuResource", start, true);
|
||||||
|
return result;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
logDuration("createGpuResource", start, false);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,78 @@
|
|||||||
|
package com.bipt.intelligentapplicationorchestrationservice.util;
|
||||||
|
|
||||||
|
import com.bipt.intelligentapplicationorchestrationservice.entity.ModelInfo;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TemplateParser {
|
||||||
|
// 使用静态模板避免硬编码(可根据需要扩展为读取外部配置文件)
|
||||||
|
private static final Map<String, String> DEPLOYMENT_TEMPLATES = new HashMap<>() {{
|
||||||
|
put("tensorflow", "#!/bin/bash\n"
|
||||||
|
+ "# TensorFlow Serving Deployment\n"
|
||||||
|
+ "docker run -d --name {0}-service \\\n"
|
||||||
|
+ " -p {1} \\\n"
|
||||||
|
+ " -v {2}:/models/{0} \\\n"
|
||||||
|
+ " -e MODEL_NAME={0} \\\n"
|
||||||
|
+ " tensorflow/serving:latest\n"
|
||||||
|
+ "# Preprocessing\n"
|
||||||
|
+ "{3} $1");
|
||||||
|
|
||||||
|
put("pytorch", "#!/bin/bash\n"
|
||||||
|
+ "# TorchServe Deployment\n"
|
||||||
|
+ "torch-model-archiver --model-name {0} \\\n"
|
||||||
|
+ " --version 1.0 \\\n"
|
||||||
|
+ " --serialized-file {2} \\\n"
|
||||||
|
+ " --handler {3} \\\n"
|
||||||
|
+ " --export-path model_store\n"
|
||||||
|
+ "torchserve --start \\\n"
|
||||||
|
+ " --model-store model_store \\\n"
|
||||||
|
+ " --models {0}.mar \\\n"
|
||||||
|
+ " --ncs \\\n"
|
||||||
|
+ " --ts-config config.properties");
|
||||||
|
}};
|
||||||
|
|
||||||
|
public String generateDeploymentScript(ModelInfo modelInfo, String endpointUrl) {
|
||||||
|
// 提取URL端口号 (假设URL格式为 http://host:port)
|
||||||
|
String port = extractPortFromUrl(endpointUrl);
|
||||||
|
|
||||||
|
// 获取基础模板
|
||||||
|
String template = DEPLOYMENT_TEMPLATES.getOrDefault(
|
||||||
|
modelInfo.getModelType().toLowerCase(),
|
||||||
|
getDefaultTemplate()
|
||||||
|
);
|
||||||
|
|
||||||
|
// 安全处理空值
|
||||||
|
String safeModelName = modelInfo.getModelName() != null ? modelInfo.getModelName() : "unnamed";
|
||||||
|
String safeFilePath = modelInfo.getModelFilePath() != null ? modelInfo.getModelFilePath() : "";
|
||||||
|
String safeScript = modelInfo.getPreprocessScript() != null ? modelInfo.getPreprocessScript() : "echo 'No preprocessing'";
|
||||||
|
|
||||||
|
// 填充模板参数
|
||||||
|
return MessageFormat.format(template,
|
||||||
|
safeModelName,
|
||||||
|
port,
|
||||||
|
safeFilePath,
|
||||||
|
safeScript
|
||||||
|
);
|
||||||
|
}
|
||||||
|
private String extractPortFromUrl(String url) {
|
||||||
|
if (url == null) return "8080"; // 默认端口
|
||||||
|
try {
|
||||||
|
return url.split(":")[2].replaceAll("[^0-9]", "");
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "8080";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getDefaultTemplate() {
|
||||||
|
return "#!/bin/bash\n"
|
||||||
|
+ "# Universal Deployment Template\n"
|
||||||
|
+ "echo \"Deploying model: {0} at endpoint {1}\"\n"
|
||||||
|
+ "echo \"Model path: {2}\"\n"
|
||||||
|
+ "echo \"Running preprocessing: {3}\"\n"
|
||||||
|
+ "# Add custom deployment logic here";
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ spring.datasource.driver-class-name=com.kingbase8.Driver
|
|||||||
spring.datasource.hikari.maximum-pool-size=10
|
spring.datasource.hikari.maximum-pool-size=10
|
||||||
spring.datasource.hikari.minimum-idle=5
|
spring.datasource.hikari.minimum-idle=5
|
||||||
spring.datasource.hikari.connection-timeout=30000
|
spring.datasource.hikari.connection-timeout=30000
|
||||||
|
spring.mvc.contentnegotiation.default-content-type=application/json
|
||||||
|
|
||||||
# MyBatis??
|
# MyBatis??
|
||||||
mybatis.mapper-locations=classpath:mapper/*.xml
|
mybatis.mapper-locations=classpath:mapper/*.xml
|
||||||
@ -22,6 +23,8 @@ spring.data.redis.host=116.205.121.200
|
|||||||
spring.data.redis.port=6379
|
spring.data.redis.port=6379
|
||||||
spring.data.redis.username=default
|
spring.data.redis.username=default
|
||||||
spring.data.redis.password=Jbjhhzstsl97@
|
spring.data.redis.password=Jbjhhzstsl97@
|
||||||
|
spring.data.redis.database=0
|
||||||
|
spring.data.redis.timeout=3000
|
||||||
spring.data.redis.ssl.enabled=false
|
spring.data.redis.ssl.enabled=false
|
||||||
|
|
||||||
# ??????
|
# ??????
|
||||||
@ -30,9 +33,16 @@ spring.cloud.gateway.routes[0].uri=lb://intelligent-application-orchestration-se
|
|||||||
spring.cloud.gateway.routes[0].predicates[0]=Path=/request
|
spring.cloud.gateway.routes[0].predicates[0]=Path=/request
|
||||||
|
|
||||||
|
|
||||||
|
logging.level.org.springframework.web=DEBUG
|
||||||
|
|
||||||
|
# ????????
|
||||||
|
model.evaluation.service-url=http://evaluation-service:8080/api/v1
|
||||||
|
model.evaluation.api-timeout=3000
|
||||||
|
# ????????
|
||||||
|
model.repository.url=https://model-repo.example.com/api/v1
|
||||||
|
model.repository.api-key=SECURE_API_KEY_12345
|
||||||
|
model.repository.timeout=5000
|
||||||
|
|
||||||
#SQL ????????
|
#SQL ????????
|
||||||
logging.level.com.bipt.intelligentapplicationorchestrationservice.mapper=DEBUG
|
logging.level.com.bipt.intelligentapplicationorchestrationservice.mapper=DEBUG
|
||||||
mybatis.configuration.log-impl=org.apache.ibatis.logging.slf4j.Slf4jImpl
|
mybatis.configuration.log-impl=org.apache.ibatis.logging.slf4j.Slf4jImpl
|
||||||
|
|
||||||
#spring.jpa.database-platform=org.hibernate.dialect.Kingbase8Dialect
|
|
@ -2,9 +2,9 @@
|
|||||||
spring.application.name=intelligent-application-orchestration-service
|
spring.application.name=intelligent-application-orchestration-service
|
||||||
|
|
||||||
# Nacos配置中心地址(引导阶段加载配置)
|
# Nacos配置中心地址(引导阶段加载配置)
|
||||||
spring.cloud.nacos.config.server-addr=192.168.100.1:8848
|
spring.cloud.nacos.config.server-addr=113.44.217.169:8848
|
||||||
spring.cloud.nacos.config.data-id=${spring.application.name}.properties
|
spring.cloud.nacos.config.data-id=${spring.application.name}.properties
|
||||||
spring.cloud.nacos.config.group=DEFAULT_GROUP
|
spring.cloud.nacos.config.group=DEFAULT_GROUP
|
||||||
|
|
||||||
# Nacos服务注册地址(引导阶段注册服务)
|
# Nacos服务注册地址(引导阶段注册服务)
|
||||||
spring.cloud.nacos.discovery.server-addr=192.168.100.1:8848
|
spring.cloud.nacos.discovery.server-addr=113.44.217.169:8848
|
@ -2,7 +2,7 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.bipt.intelligentapplicationorchestrationservice.mapper.EvaluationMapper">
|
<mapper namespace="com.bipt.intelligentapplicationorchestrationservice.mapper.EvaluationMapper">
|
||||||
<!--查询模型日志详细信息-->
|
<!--查询模型日志详细信息-->
|
||||||
<select id="selectLogDetail" resultType="ModelLogVO">
|
<select id="selectLogDetail" resultType="com.bipt.intelligentapplicationorchestrationservice.pojo.ModelLogVO">
|
||||||
select m1.*,
|
select m1.*,
|
||||||
m2.model_name,
|
m2.model_name,
|
||||||
m3.model_config, m3.version
|
m3.model_config, m3.version
|
||||||
|
@ -2,10 +2,19 @@
|
|||||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao">
|
<mapper namespace="com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao">
|
||||||
|
<resultMap id="gpuResourceMap" type="com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource">
|
||||||
|
<id property="GPUId" column="GPUId" /> <!-- 强制映射 -->
|
||||||
|
<result property="createTime" column="created_time"/>
|
||||||
|
<result property="UpdateTime" column="update_time"/>
|
||||||
|
<result property="GPUModel" column="GPUModel"/>
|
||||||
|
<result property="GPUMemorySize" column="GPUMemorySize"/>
|
||||||
|
<result property="Ip" column="Ip"/>
|
||||||
|
<result property="isDeleted" column="is_deleted"/>
|
||||||
|
<result property="GPUMaxMemory" column="GPUMaxMemory"/>
|
||||||
|
</resultMap>
|
||||||
<!-- 动态条件查询 -->
|
<!-- 动态条件查询 -->
|
||||||
<select id="selectByFields"
|
<select id="selectByFields"
|
||||||
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource">
|
resultMap="gpuResourceMap">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM Ipz.public.gpu_resource
|
FROM Ipz.public.gpu_resource
|
||||||
<where>
|
<where>
|
||||||
@ -28,7 +37,7 @@
|
|||||||
|
|
||||||
<!-- 分页查询 -->
|
<!-- 分页查询 -->
|
||||||
<select id="findByPage"
|
<select id="findByPage"
|
||||||
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource">
|
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM gpu_resource
|
FROM gpu_resource
|
||||||
WHERE is_deleted = 0
|
WHERE is_deleted = 0
|
||||||
@ -38,7 +47,7 @@
|
|||||||
|
|
||||||
<!-- 增量同步查询 -->
|
<!-- 增量同步查询 -->
|
||||||
<select id="findModifiedSince"
|
<select id="findModifiedSince"
|
||||||
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource">
|
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource">
|
||||||
SELECT *, is_deleted
|
SELECT *, is_deleted
|
||||||
FROM gpu_resource
|
FROM gpu_resource
|
||||||
WHERE update_time > #{since}
|
WHERE update_time > #{since}
|
||||||
@ -47,7 +56,7 @@
|
|||||||
|
|
||||||
<!-- 带锁查询 -->
|
<!-- 带锁查询 -->
|
||||||
<select id="selectByIdWithLock"
|
<select id="selectByIdWithLock"
|
||||||
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.entity.GpuResource">
|
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource">
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM gpu_resource
|
FROM gpu_resource
|
||||||
WHERE GPUId = #{gpuId}
|
WHERE GPUId = #{gpuId}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<!--查询模型列表-->
|
<!--查询模型列表-->
|
||||||
<select id="list" resultType="modelVO">
|
<select id="list" resultType="com.bipt.intelligentapplicationorchestrationservice.pojo.ModelVO">
|
||||||
select t1.*,
|
select t1.*,
|
||||||
t2.id as versionId,t2.version, t2.version, t2.data_pre_handle_file, t2.operate_user, t2.update_time,
|
t2.id as versionId,t2.version, t2.version, t2.data_pre_handle_file, t2.operate_user, t2.update_time,
|
||||||
t2.status
|
t2.status
|
||||||
@ -29,7 +29,7 @@
|
|||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!--查询模型详细信息-->
|
<!--查询模型详细信息-->
|
||||||
<select id="selectById" resultType="modelVersion">
|
<select id="selectById" resultType="com.bipt.intelligentapplicationorchestrationservice.pojo.ModelVersion">
|
||||||
SELECT
|
SELECT
|
||||||
t1.model_name,
|
t1.model_name,
|
||||||
t2.version, t2.dataset_id, t2.model_config,
|
t2.version, t2.dataset_id, t2.model_config,
|
||||||
|
Reference in New Issue
Block a user