WIP: dc-feature #14
@ -82,6 +82,12 @@ public class CacheManager {
|
||||
// 带随机TTL的缓存设置
|
||||
private void setCacheWithTTL(GpuResource entity) {
|
||||
String key = buildKey(entity.getGPUId().toString());
|
||||
GpuResource cached = (GpuResource) redisTemplate.opsForValue().get(key);
|
||||
|
||||
// 保留原有内存字段值
|
||||
if (cached != null && cached.getGPUMemorySize() != null) {
|
||||
entity.setGPUMemorySize(cached.getGPUMemorySize());
|
||||
}
|
||||
redisTemplate.opsForValue().set(
|
||||
key,
|
||||
entity,
|
||||
@ -155,4 +161,9 @@ public class CacheManager {
|
||||
String key = buildKey(gpuId.toString());
|
||||
redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
public GpuResource getFromCache(String gpuId) {
|
||||
return (GpuResource) redisTemplate.opsForValue().get("gpu:" + gpuId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Service
|
||||
@ -117,7 +118,7 @@ public class RedisCacheService {
|
||||
*/
|
||||
public boolean healthCheck() {
|
||||
try {
|
||||
return "PONG".equals(redisTemplate.getConnectionFactory()
|
||||
return "PONG".equals(Objects.requireNonNull(redisTemplate.getConnectionFactory())
|
||||
.getConnection().ping());
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
|
@ -11,27 +11,27 @@ import java.util.Map;
|
||||
@Mapper
|
||||
public interface GpuResourceDao {
|
||||
//---------------------- 基础CRUD ------------------------
|
||||
@Insert("INSERT INTO ipz.gpu_resource (GPUModel, GPUMemorySize, Ip) " +
|
||||
@Insert("INSERT INTO Ipz.public.gpu_resource (GPUModel, GPUMemorySize, Ip) " +
|
||||
"VALUES (#{model}, #{memory}, #{ip})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "GPUId")
|
||||
Integer insert(GpuResource entity);
|
||||
|
||||
//物理删除
|
||||
@Delete("DELETE FROM ipz.gpu_resource WHERE GPUId = #{gpuId}")
|
||||
@Delete("DELETE FROM Ipz.public.gpu_resource WHERE GPUId = #{gpuId}")
|
||||
Integer deleteById(@Param("gpuId") Long gpuId);
|
||||
|
||||
// 逻辑删除
|
||||
@Update("UPDATE ipz.gpu_resource" +
|
||||
@Update("UPDATE Ipz.public.gpu_resource" +
|
||||
" SET is_deleted = 1, update_time = NOW() " +
|
||||
" WHERE GPUId = #{gpuId}")
|
||||
Integer isDeleted(@Param("gpuId") Long gpuId);
|
||||
|
||||
@Update("UPDATE ipz.gpu_resource " +
|
||||
@Update("UPDATE Ipz.public.gpu_resource " +
|
||||
"SET GPUModel = #{model}, GPUMemorySize = #{memory}, Ip = #{ip} " +
|
||||
"WHERE GPUId = #{GPUId}")
|
||||
Integer updateById(GpuResource entity);
|
||||
|
||||
@Select("SELECT * FROM ipz.gpu_resource WHERE GPUId = #{gpuId} AND is_deleted = 0")
|
||||
@Select("SELECT * FROM Ipz.public.gpu_resource WHERE GPUId = #{gpuId} AND is_deleted = 0")
|
||||
GpuResource selectById(@Param("gpuId") Long gpuId);
|
||||
|
||||
//---------------------- 缓存相关扩展 ------------------------
|
||||
@ -74,7 +74,7 @@ class GpuSqlBuilder {
|
||||
public static String buildDynamicQuery(Map<String, Object> params) {
|
||||
return new SQL() {{
|
||||
SELECT("*");
|
||||
FROM("ipz.gpu_resource");
|
||||
FROM("Ipz.public.gpu_resource");
|
||||
if (params.containsKey("model")) {
|
||||
WHERE("GPUModel LIKE #{params.model}");
|
||||
}
|
||||
|
@ -23,10 +23,6 @@ public class GpuUpdateDTO {
|
||||
this.GPUModel = GPUModel;
|
||||
}
|
||||
|
||||
public void setGPUMemorySize(Integer GPUMemorySize) {
|
||||
this.GPUMemorySize = GPUMemorySize;
|
||||
}
|
||||
|
||||
public void setIp(@Pattern(regexp = "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$",
|
||||
message = "IP地址格式无效") String ip) {
|
||||
Ip = ip;
|
||||
@ -39,6 +35,7 @@ public class GpuUpdateDTO {
|
||||
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}$",
|
||||
|
@ -2,50 +2,23 @@ package com.bipt.intelligentapplicationorchestrationservice.gpu.model.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Setter
|
||||
@Data
|
||||
//@Entity
|
||||
//@Table(name = "Gpu_Resource")
|
||||
public class GpuResource {
|
||||
|
||||
public void setGPUId(Long GPUId) {
|
||||
this.GPUId = GPUId;
|
||||
}
|
||||
|
||||
public void setGPUModel(String GPUModel) {
|
||||
this.GPUModel = GPUModel;
|
||||
}
|
||||
|
||||
public void setGPUMemorySize(Integer GPUMemorySize) {
|
||||
this.GPUMemorySize = GPUMemorySize;
|
||||
}
|
||||
|
||||
public void setIsDeleted(Integer isDeleted) {
|
||||
this.isDeleted = isDeleted;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
Ip = ip;
|
||||
}
|
||||
|
||||
public void setCreateTime(LocalDateTime createTime) {
|
||||
CreateTime = createTime;
|
||||
}
|
||||
|
||||
public void setUpdateTime(LocalDateTime updateTime) {
|
||||
UpdateTime = updateTime;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@TableField("GPUId")
|
||||
private Long GPUId;
|
||||
|
||||
@Getter
|
||||
@TableField("GPUModel")
|
||||
private String GPUModel;
|
||||
|
||||
@Getter
|
||||
@TableField("GPUMemorySize")
|
||||
private Integer GPUMemorySize;
|
||||
|
||||
@ -55,12 +28,18 @@ public class GpuResource {
|
||||
@TableField("Ip")
|
||||
private String Ip;
|
||||
|
||||
@Getter
|
||||
@TableField("CreatedTime")
|
||||
private LocalDateTime CreateTime;
|
||||
|
||||
@Getter
|
||||
@TableField("update_time")
|
||||
private LocalDateTime UpdateTime;
|
||||
|
||||
@Getter
|
||||
@TableField("GPUMaxMemory")
|
||||
private Integer GPUMaxMemory;
|
||||
|
||||
public GpuResource(long l, String s, boolean b) {
|
||||
this.GPUId = l;
|
||||
this.GPUModel = s;
|
||||
@ -70,22 +49,6 @@ public class GpuResource {
|
||||
// return Ip;
|
||||
// }
|
||||
|
||||
public Long getGPUId() {
|
||||
return GPUId;
|
||||
}
|
||||
|
||||
public String getGPUModel() {
|
||||
return GPUModel;
|
||||
}
|
||||
|
||||
public Integer getGPUMemorySize() {
|
||||
return GPUMemorySize;
|
||||
}
|
||||
|
||||
public LocalDateTime getCreateTime() {
|
||||
return CreateTime;
|
||||
}
|
||||
|
||||
public Boolean getIsDeleted() {
|
||||
return isDeleted != 0;
|
||||
}
|
||||
@ -102,5 +65,32 @@ public class GpuResource {
|
||||
|
||||
public GpuResource() {}
|
||||
|
||||
// public void setGPUId(Long GPUId) {
|
||||
// this.GPUId = GPUId;
|
||||
// }
|
||||
//
|
||||
// public void setGPUModel(String GPUModel) {
|
||||
// this.GPUModel = GPUModel;
|
||||
// }
|
||||
//
|
||||
// public void setGPUMemorySize(Integer GPUMemorySize) {
|
||||
// this.GPUMemorySize = GPUMemorySize;
|
||||
// }
|
||||
//
|
||||
// public void setIsDeleted(Integer isDeleted) {
|
||||
// this.isDeleted = isDeleted;
|
||||
// }
|
||||
//
|
||||
// public void setIp(String ip) {
|
||||
// Ip = ip;
|
||||
// }
|
||||
//
|
||||
// public void setCreateTime(LocalDateTime createTime) {
|
||||
// CreateTime = createTime;
|
||||
// }
|
||||
//
|
||||
// public void setUpdateTime(LocalDateTime updateTime) {
|
||||
// UpdateTime = updateTime;
|
||||
// }
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,4 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.setmodel.config;
|
||||
|
||||
public class GPUPoolConfig {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.setmodel.config;
|
||||
|
||||
public class MQConfig {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.setmodel.controller;
|
||||
|
||||
public class ModelDeployController {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.setmodel.service;
|
||||
|
||||
public class GrayDeployService {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.setmodel.service;
|
||||
|
||||
public class ModelDeployService {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.setmodel.service.scheduler;
|
||||
|
||||
public class RequestReplicator {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.bipt.intelligentapplicationorchestrationservice.setmodel.service.scheduler;
|
||||
|
||||
public class ResourceScheduler {
|
||||
}
|
@ -1,15 +1,15 @@
|
||||
spring.application.name=intelligent-application-orchestration-service
|
||||
|
||||
#spring.datasource.url=jdbc:kingbase8://116.205.121.200:54321/Ipz
|
||||
#spring.datasource.username=system
|
||||
#spring.datasource.password=root
|
||||
#spring.datasource.driver-class-name=com.kingbase8.Driver
|
||||
#spring.jpa.database-platform=org.hibernate.dialect.Kingbase8Dialect
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/Ipz
|
||||
spring.datasource.username=root
|
||||
spring.datasource.password=zxc25864
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
|
||||
spring.datasource.url=jdbc:kingbase8://116.205.121.200:54321/Ipz
|
||||
spring.datasource.username=system
|
||||
spring.datasource.password=root
|
||||
spring.datasource.driver-class-name=com.kingbase8.Driver
|
||||
spring.jpa.database-platform=org.hibernate.dialect.Kingbase8Dialect
|
||||
#spring.datasource.url=jdbc:mysql://localhost:3306/Ipz
|
||||
#spring.datasource.username=root
|
||||
#spring.datasource.password=zxc25864
|
||||
#spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
#spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect
|
||||
spring.datasource.hikari.maximum-pool-size=10
|
||||
spring.datasource.hikari.minimum-idle=5
|
||||
spring.datasource.hikari.connection-timeout=30000
|
||||
|
@ -7,7 +7,7 @@
|
||||
<select id="selectByFields"
|
||||
resultType="com.bipt.intelligentapplicationorchestrationservice.gpu.model.entity.GpuResource">
|
||||
SELECT *
|
||||
FROM ipz.gpu_resource
|
||||
FROM Ipz.public.gpu_resource
|
||||
<where>
|
||||
is_deleted = 0
|
||||
<if test="params.model != null and params.model != ''">
|
||||
@ -30,7 +30,7 @@
|
||||
<select id="findByPage"
|
||||
resultType="com.bipt.intelligentapplicationorchestrationservice.gpu.model.entity.GpuResource">
|
||||
SELECT *
|
||||
FROM ipz.gpu_resource
|
||||
FROM gpu_resource
|
||||
WHERE is_deleted = 0
|
||||
ORDER BY GPUId ASC
|
||||
LIMIT #{limit} OFFSET #{offset}
|
||||
@ -40,7 +40,7 @@
|
||||
<select id="findModifiedSince"
|
||||
resultType="com.bipt.intelligentapplicationorchestrationservice.gpu.model.entity.GpuResource">
|
||||
SELECT *, is_deleted
|
||||
FROM ipz.gpu_resource
|
||||
FROM gpu_resource
|
||||
WHERE update_time > #{since}
|
||||
ORDER BY update_time ASC
|
||||
</select>
|
||||
@ -49,7 +49,7 @@
|
||||
<select id="selectByIdWithLock"
|
||||
resultType="com.bipt.intelligentapplicationorchestrationservice.gpu.model.entity.GpuResource">
|
||||
SELECT *
|
||||
FROM ipz.gpu_resource
|
||||
FROM gpu_resource
|
||||
WHERE GPUId = #{gpuId}
|
||||
FOR UPDATE NOWAIT
|
||||
</select>
|
||||
|
Reference in New Issue
Block a user