GPU和服务发布和算法部分代码优化
This commit is contained in:
26
pom.xml
26
pom.xml
@ -92,7 +92,6 @@
|
||||
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
|
||||
<version>2.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Nacos 配置依赖(移除手动版本,由上方依赖管理控制) -->
|
||||
<dependency>
|
||||
<groupId>com.alibaba.cloud</groupId>
|
||||
@ -103,7 +102,6 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-starter-bootstrap</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- 测试依赖 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@ -137,8 +135,6 @@
|
||||
<artifactId>mapstruct</artifactId>
|
||||
<version>1.5.5.Final</version> <!-- 确保版本 ≥1.2.0 -->
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
@ -206,19 +202,17 @@
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.38</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<path>
|
||||
<groupId>org.mapstruct</groupId>
|
||||
<artifactId>mapstruct-processor</artifactId>
|
||||
<version>1.5.5.Final</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
||||
<version>0.2.0</version>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
@ -1,10 +1,12 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.config.IpConfig;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.slf4j.Logger;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
@ -12,6 +14,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
@SpringBootApplication
|
||||
@EnableTransactionManagement
|
||||
@EnableDiscoveryClient
|
||||
@EnableConfigurationProperties(IpConfig.class)
|
||||
//@Slf4j
|
||||
public class IntelligentApplicationOrchestrationServiceApplication {
|
||||
private static final Logger log = org.slf4j.LoggerFactory.getLogger(IntelligentApplicationOrchestrationServiceApplication.class);
|
||||
|
@ -0,0 +1,21 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Configuration
|
||||
@ConfigurationProperties(prefix = "available")
|
||||
public class IpConfig {
|
||||
private List<String> ips;
|
||||
|
||||
public List<String> getIps() {
|
||||
return ips;
|
||||
}
|
||||
|
||||
public void setIps(String ips) {
|
||||
this.ips = Arrays.asList(ips.split(","));
|
||||
}
|
||||
}
|
@ -1,6 +1,9 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.config;
|
||||
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import io.lettuce.core.ClientOptions;
|
||||
import io.lettuce.core.SocketOptions;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@ -60,38 +63,41 @@ public class RedisConfig {
|
||||
.clientOptions(clientOptions) // 注入 ClientOptions
|
||||
.commandTimeout(Duration.ofSeconds(30)) // 全局命令超时
|
||||
.build();
|
||||
|
||||
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
|
||||
config.setHostName(redisHost);
|
||||
config.setPort(redisPort);
|
||||
config.setUsername(redisUsername); // Redis 6.0+ 支持用户名
|
||||
config.setPassword(RedisPassword.of(redisPassword));
|
||||
|
||||
// LettuceClientConfiguration clientConfig = LettuceClientConfiguration.builder()
|
||||
// .commandTimeout(Duration.ofSeconds(30)) // 增加命令超时
|
||||
// .socketOptions(SocketOptions.builder()
|
||||
// .connectTimeout(Duration.ofSeconds(15)) // TCP连接超时
|
||||
// .build())
|
||||
// .build();
|
||||
|
||||
return new LettuceConnectionFactory(config, clientConfig);
|
||||
}
|
||||
|
||||
|
||||
// @Bean
|
||||
// public RedisConnectionFactory redisConnectionFactory() {
|
||||
// RedisStandaloneConfiguration config = new RedisStandaloneConfiguration();
|
||||
// config.setPassword("");
|
||||
// return new LettuceConnectionFactory(config);
|
||||
// }
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(){
|
||||
public RedisTemplate<String, Object> redisTemplate() {
|
||||
RedisTemplate<String, Object> template = new RedisTemplate<>();
|
||||
Logger log = (Logger) LoggerFactory.getLogger(RedisConfig.class);
|
||||
log.info("开始创建redis模板对象...");
|
||||
template.setConnectionFactory(redisConnectionFactory());
|
||||
|
||||
// 创建自定义的ObjectMapper并注册JavaTimeModule
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
// 禁用将日期序列化为时间戳
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
// 注册Java 8日期时间模块
|
||||
mapper.registerModule(new JavaTimeModule());
|
||||
|
||||
// 使用自定义的ObjectMapper创建JSON序列化器
|
||||
GenericJackson2JsonRedisSerializer jsonSerializer =
|
||||
new GenericJackson2JsonRedisSerializer(mapper);
|
||||
|
||||
// 设置键和值的序列化方式
|
||||
template.setKeySerializer(new StringRedisSerializer());
|
||||
template.setValueSerializer(new GenericJackson2JsonRedisSerializer());
|
||||
template.setValueSerializer(jsonSerializer);
|
||||
template.setHashKeySerializer(new StringRedisSerializer());
|
||||
template.setHashValueSerializer(jsonSerializer);
|
||||
|
||||
template.afterPropertiesSet();
|
||||
return template;
|
||||
}
|
||||
}
|
@ -9,11 +9,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping
|
||||
@RequestMapping("/gpu")
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
public class GpuResourceController {
|
||||
@Autowired
|
||||
private GpuManageService gpuManageService;
|
||||
@PostMapping
|
||||
@PostMapping(value = "/add", produces = "application/json")
|
||||
public ResponseVO addGpu(@Valid @RequestBody GpuCreateDTO dto){
|
||||
return gpuManageService.createGpuResource(dto);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.controller;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.config.IpConfig;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.*;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.util.NacosServiceUtil;
|
||||
@ -17,6 +18,8 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/publish")
|
||||
@Slf4j
|
||||
@CrossOrigin(origins = "http://localhost:3000") // 生产环境指定具体域名
|
||||
|
||||
public class PublishController {
|
||||
@Autowired
|
||||
private PublishService publishService;
|
||||
@ -24,6 +27,9 @@ public class PublishController {
|
||||
@Autowired
|
||||
private NacosServiceUtil nacosServiceUtil;
|
||||
|
||||
@Autowired
|
||||
private IpConfig ipConfig;
|
||||
|
||||
@PostMapping
|
||||
@Operation(summary ="新增发布请求")
|
||||
@Transactional
|
||||
@ -38,7 +44,6 @@ public class PublishController {
|
||||
log.warn("IP列表为空,不进行Nacos注册");
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
try {
|
||||
// 使用逗号分割IP字符串
|
||||
String[] ipArray = ipListStr.split(",");
|
||||
@ -59,15 +64,31 @@ public class PublishController {
|
||||
log.error("Nacos服务注册失败", e);
|
||||
return OptResult.error("Nacos服务注册失败"); // 根据业务需求返回错误
|
||||
}
|
||||
|
||||
|
||||
return OptResult.success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已发布的服务列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@Operation(summary ="获取已发布服务列表")
|
||||
public OptResult<List<ServicePublishVO>> listPublishedServices() {
|
||||
log.info("获取已发布服务列表接口被调用");
|
||||
List<ServicePublishVO> services = publishService.listPublishedServices();
|
||||
log.info("返回的数据: {}", services);
|
||||
return OptResult.success(services);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 获取IP列表
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/config/ips")
|
||||
@Operation(summary = "获取可用IP地址列表")
|
||||
public OptResult<List<String>> getAvailableIps() {
|
||||
List<String> ips = ipConfig.getIps();
|
||||
log.info("返回列表;{}",ips);
|
||||
return OptResult.success(ips);
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.mapper;
|
||||
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuCreateDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuResponseDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuUpdateDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.MappingConstants;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Mapper(componentModel = "spring")
|
||||
public interface GpuMapper {
|
||||
GpuResource toEntity(GpuCreateDTO dto);
|
@ -1,52 +1,21 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Setter
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@Setter
|
||||
@Getter
|
||||
public class GpuResource {
|
||||
@Getter
|
||||
@TableField("GPUId")
|
||||
private Long GPUId;
|
||||
|
||||
@Getter
|
||||
@TableField("GPUModel")
|
||||
private String GPUModel;
|
||||
|
||||
public Integer getGPUMemorySize() {
|
||||
return GPUMemorySize;
|
||||
}
|
||||
|
||||
public Long getGPUId() {
|
||||
return GPUId;
|
||||
}
|
||||
|
||||
public String getGPUModel() {
|
||||
return GPUModel;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return Ip;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return CreateTime;
|
||||
}
|
||||
|
||||
public LocalDateTime getUpdateTime() {
|
||||
return UpdateTime;
|
||||
}
|
||||
|
||||
public Integer getGPUMaxMemory() {
|
||||
return GPUMaxMemory;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@TableField("GPUMemorySize")
|
||||
private Integer GPUMemorySize;
|
||||
|
||||
@ -56,15 +25,12 @@ public class GpuResource {
|
||||
@TableField("Ip")
|
||||
private String Ip;
|
||||
|
||||
@Getter
|
||||
@TableField("CreatedTime")
|
||||
private LocalDateTime CreateTime;
|
||||
@TableField("created_time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Getter
|
||||
@TableField("update_time")
|
||||
private LocalDateTime UpdateTime;
|
||||
|
||||
@Getter
|
||||
@TableField("GPUMaxMemory")
|
||||
private Integer GPUMaxMemory;
|
||||
|
||||
@ -83,16 +49,40 @@ public class GpuResource {
|
||||
|
||||
|
||||
|
||||
public GpuResource(Long Id, String Model, Integer MemorySize, String ip, LocalDateTime create_time) {
|
||||
public GpuResource(Long Id, String GPUModel, Integer GPUMemorySize, String ip, LocalDateTime create_time) {
|
||||
this.GPUId = Id;
|
||||
this.GPUModel = Model;
|
||||
this.GPUMemorySize = MemorySize;
|
||||
this.GPUModel = GPUModel;
|
||||
this.GPUMemorySize = GPUMemorySize;
|
||||
this.Ip = ip;
|
||||
this.CreateTime = create_time;
|
||||
this.createTime = create_time;
|
||||
}
|
||||
|
||||
public GpuResource() {}
|
||||
|
||||
public Integer getGPUMemorySize() {
|
||||
return GPUMemorySize;
|
||||
}
|
||||
|
||||
public Long getGPUId() {
|
||||
return GPUId;
|
||||
}
|
||||
|
||||
public String getGPUModel() {
|
||||
return GPUModel;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return Ip;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
|
||||
public Integer getGPUMaxMemory() {
|
||||
return GPUMaxMemory;
|
||||
}
|
||||
|
||||
public void setGPUId(Long GPUId) {
|
||||
this.GPUId = GPUId;
|
||||
}
|
||||
@ -114,11 +104,7 @@ public class GpuResource {
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
CreateTime = createTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
UpdateTime = updateTime;
|
||||
this.createTime = createTime;
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ import java.util.Map;
|
||||
public interface GpuResourceDao {
|
||||
//---------------------- 基础CRUD ------------------------
|
||||
@Insert("INSERT INTO Ipz.public.gpu_resource (GPUModel, GPUMemorySize, Ip) " +
|
||||
"VALUES (#{model}, #{memory}, #{ip})")
|
||||
"VALUES (#{GPUModel}, #{GPUMemorySize}, #{Ip})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "GPUId")
|
||||
Integer insert(GpuResource entity);
|
||||
|
||||
@ -27,7 +27,7 @@ public interface GpuResourceDao {
|
||||
Integer isDeleted(@Param("gpuId") Long gpuId);
|
||||
|
||||
@Update("UPDATE Ipz.public.gpu_resource " +
|
||||
"SET GPUModel = #{model}, GPUMemorySize = #{memory}, Ip = #{ip} " +
|
||||
"SET GPUModel = #{GPUModel}, GPUMemorySize = #{GPUMemorySize}, Ip = #{Ip} " +
|
||||
"WHERE GPUId = #{GPUId}")
|
||||
Integer updateById(GpuResource entity);
|
||||
|
||||
|
@ -6,6 +6,8 @@ import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface PublishMapper {
|
||||
|
||||
@ -15,5 +17,6 @@ public interface PublishMapper {
|
||||
|
||||
Long getByApiUrl(String apiUrl);
|
||||
|
||||
|
||||
@Select("SELECT model_id,api_url,ip FROM service_publish")
|
||||
List<ServicePublishVO> listPublishedServices();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
@ -14,14 +15,17 @@ public class GpuCreateDTO {
|
||||
@NotBlank(message = "GPU型号不能为空")
|
||||
@Pattern(regexp = "^([A-Z][A-Z0-9-]+)-\\w+",
|
||||
message = "型号格式应为 [厂商(大写字母开头)]-[型号],如 Intel-Xe_GPU")
|
||||
@JsonProperty("GPUModel") // 显示指定JSON映射名称
|
||||
private String GPUModel;
|
||||
|
||||
@NotNull(message = "显存容量不能为空")
|
||||
@JsonProperty("GPUMemorySize")
|
||||
private Integer GPUMemorySize;
|
||||
|
||||
@NotBlank(message = "IP地址不能为空")
|
||||
@Pattern(regexp = "^\\\\d{1,3}\\\\.\\\\d{1,3}\\\\.\\\\d{1,3}\\\\.\\\\d{1,3}$",
|
||||
@Pattern(regexp = "^(\\d{1,3}\\.){3}\\d{1,3}$",
|
||||
message = "IP地址格式无效")
|
||||
@JsonProperty("Ip") // 显示指定JSON映射名称
|
||||
private String Ip;
|
||||
|
||||
}
|
||||
|
@ -1,23 +1,30 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class GpuResponseDTO {
|
||||
private Long id;
|
||||
@JsonView
|
||||
private Long GPUId;
|
||||
private String GPUModel;
|
||||
private Integer GPUMemorySize;
|
||||
private String Ip;
|
||||
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
// Builder类
|
||||
public static class Builder {
|
||||
private Long id;
|
||||
private String model;
|
||||
private Integer memory;
|
||||
private String ip;
|
||||
private LocalDateTime createdTime;
|
||||
private LocalDateTime createTime = LocalDateTime.now(); // 统一命名为createTime
|
||||
|
||||
public Builder id(Long id) {
|
||||
this.id = id;
|
||||
@ -39,19 +46,29 @@ public class GpuResponseDTO {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder createdTime(LocalDateTime createdTime) {
|
||||
this.createdTime = createdTime;
|
||||
public Builder createTime(LocalDateTime createTime) {
|
||||
this.createTime = createTime;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GpuResponseDTO build() {
|
||||
// 必填字段校验(如网页2的推荐)
|
||||
// 必填字段校验
|
||||
if (id == null) {
|
||||
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,5 +1,6 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.pojo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.*;
|
||||
@ -7,14 +8,36 @@ import lombok.*;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
//@Setter
|
||||
//@Getter
|
||||
@Setter
|
||||
@Getter
|
||||
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")
|
||||
@JsonProperty("GPUModel") // 显示指定JSON映射名称
|
||||
private String GPUModel;
|
||||
|
||||
@JsonProperty("GPUMemorySize") // 显示指定JSON映射名称
|
||||
private Integer GPUMemorySize;
|
||||
|
||||
@Pattern(regexp = "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$",
|
||||
message = "IP地址格式无效")
|
||||
@JsonProperty("Ip") // 显示指定JSON映射名称
|
||||
private String Ip;
|
||||
|
||||
public void setGPUId(Long GPUId) {
|
||||
this.GPUId = GPUId;
|
||||
}
|
||||
|
||||
@ -27,18 +50,15 @@ public class GpuUpdateDTO {
|
||||
message = "IP地址格式无效") String ip) {
|
||||
Ip = ip;
|
||||
}
|
||||
public Long getGPUId() {
|
||||
return GPUId;
|
||||
}
|
||||
|
||||
@NotNull(message = "GPU ID cannot be null")
|
||||
private Long GPUId;
|
||||
public Integer getGPUMemorySize() {
|
||||
return GPUMemorySize;
|
||||
}
|
||||
|
||||
@Pattern(regexp = "^([A-Z][A-Z0-9-]+)-\\w+",
|
||||
message = "型号格式应为 [厂商(大写字母开头)]-[型号],如 Intel-Xe_GPU")
|
||||
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;
|
||||
public void setGPUMemorySize(Integer GPUMemorySize) {
|
||||
this.GPUMemorySize = GPUMemorySize;
|
||||
}
|
||||
}
|
||||
|
@ -35,4 +35,28 @@ public class ResponseVO<T> implements Serializable {
|
||||
public static <T> ResponseVO<T> error(ErrorCodeEnum errorCode) {
|
||||
return new ResponseVO<>(errorCode.getCode(), errorCode.getMessage(), null);
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ import java.time.LocalDateTime;
|
||||
@AllArgsConstructor
|
||||
public class ServicePublishVO implements Serializable {
|
||||
private Long modelId;
|
||||
private String GPUModel;
|
||||
/*private String GPUModel;*/
|
||||
private String ip;
|
||||
private String GPUMemorySize;
|
||||
/* private String GPUMemorySize;*/
|
||||
private String apiUrl;
|
||||
|
||||
|
||||
|
@ -97,6 +97,7 @@ public class AlgorithmInfoServiceImpl implements AlgorithmInfoService {
|
||||
|
||||
@Override
|
||||
public String run(Long id, String param) {
|
||||
//todo从分布式存储中拿到文件(以下是示例)
|
||||
String file = algorithmInfoMapper.getFileById(id);
|
||||
StringBuilder result = new StringBuilder(); // 用于存储结果
|
||||
|
||||
|
@ -2,12 +2,15 @@ package com.bipt.intelligentapplicationorchestrationservice.service.Impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.PublishMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.service.PublishService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author hky
|
||||
*/
|
||||
@ -35,6 +38,10 @@ public class PublishServiceImpl implements PublishService {
|
||||
publishMapper.insert(servicePublishDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ServicePublishVO> listPublishedServices() {
|
||||
return publishMapper.listPublishedServices();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.ServicePublishVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface PublishService {
|
||||
|
||||
void save(ServicePublishDTO servicePublishDTO);
|
||||
|
||||
|
||||
|
||||
|
||||
List<ServicePublishVO> listPublishedServices();
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.service.impl;
|
||||
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuResourceDao;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.mapper.GpuMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.entity.GpuMapper;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuCreateDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuResponseDTO;
|
||||
import com.bipt.intelligentapplicationorchestrationservice.pojo.GpuUpdateDTO;
|
||||
|
@ -57,4 +57,6 @@ spring.servlet.multipart.max-request-size=100MB
|
||||
# 激活开发环境!告诉 Spring:加载 application-dev.properties 里的配置
|
||||
spring.profiles.active=dev
|
||||
|
||||
#配置IP列表(后续根据需求修改ip数据,以下仅为测试用例)
|
||||
available.ips=192.168.1.100,192.168.1.101,192.168.1.102
|
||||
|
||||
|
@ -2,10 +2,19 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<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"
|
||||
resultType="com.bipt.intelligentapplicationorchestrationservice.entity.GpuResource">
|
||||
resultMap="gpuResourceMap">
|
||||
SELECT *
|
||||
FROM Ipz.public.gpu_resource
|
||||
<where>
|
||||
|
@ -3,8 +3,8 @@
|
||||
<mapper namespace="com.bipt.intelligentapplicationorchestrationservice.mapper.PublishMapper">
|
||||
<insert id="insert">
|
||||
INSERT INTO service_publish
|
||||
(id,model_id,api_url,create_time)
|
||||
values (#{id}, #{modelId}, #{apiUrl}, #{createTime})
|
||||
(id,model_id,api_url,create_time,ip)
|
||||
values (#{id}, #{modelId}, #{apiUrl}, #{createTime},#{ip})
|
||||
</insert>
|
||||
|
||||
<select id="getByApiUrl" resultType="java.lang.Long">
|
||||
|
Reference in New Issue
Block a user