You've already forked FrameTour-BE
refactor(basic): 重构渲染机相关代码
- 移除了 RenderWorkerMapper 中的未使用的接口 - 精简了 RenderWorkerEntity 中的字段 -重构了 RenderWorkerRepository 中的缓存逻辑 - 更新了 RenderWorkerService 接口和实现类,使用新的 RenderWorkerRespVO 响应对象 - 调整了 TaskTaskServiceImpl 中的渲染机相关代码,使用新的配置管理方式
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.ycwl.basic.repository;
|
||||
|
||||
import com.ycwl.basic.utils.JacksonUtil;
|
||||
import com.ycwl.basic.mapper.RenderWorkerMapper;
|
||||
import com.ycwl.basic.model.pc.renderWorker.entity.RenderWorkerEntity;
|
||||
import com.ycwl.basic.model.task.req.ClientStatusReqVo;
|
||||
import com.ycwl.basic.integration.render.dto.worker.RenderWorkerV2DTO;
|
||||
@@ -25,11 +24,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class RenderWorkerRepository {
|
||||
@Autowired
|
||||
private RedisTemplate<String, String> redisTemplate;
|
||||
public static final String RENDER_WORKER_CACHE_KEY = "render_worker:%s";
|
||||
public static final String RENDER_WORKER_STATUS_CACHE_KEY = "render_worker:host_status:%s";
|
||||
public static final String RENDER_WORKER_CONFIG_CACHE_KEY = "render_worker:%s:config";
|
||||
@Autowired
|
||||
private RenderWorkerMapper mapper;
|
||||
|
||||
@Autowired
|
||||
private RenderWorkerIntegrationService renderWorkerIntegrationService;
|
||||
@@ -61,21 +56,6 @@ public class RenderWorkerRepository {
|
||||
return;
|
||||
}
|
||||
status.setUpdateAt(new Date());
|
||||
RenderWorkerEntity worker = new RenderWorkerEntity();
|
||||
worker.setCpuCount(status.getCpu_count());
|
||||
worker.setCpuUsage(status.getCpu_usage());
|
||||
// 上报的是字节,存储的是兆
|
||||
worker.setMemoryAvailable(status.getMemory_available().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
|
||||
worker.setMemoryTotal(status.getMemory_total().divide(BigDecimal.valueOf(1024 * 1024), RoundingMode.CEILING));
|
||||
|
||||
worker.setPlatform(status.getPlatform());
|
||||
worker.setRuntimeVersion(status.getRuntime_version());
|
||||
worker.setSupportFeature(String.join(",", status.getSupport_feature()));
|
||||
worker.setVersion(status.getVersion());
|
||||
worker.setUpdateAt(status.getUpdateAt());
|
||||
if (!redisTemplate.hasKey(key)) {
|
||||
mapper.updateHost(id, worker);
|
||||
}
|
||||
redisTemplate.opsForValue().set(key, JacksonUtil.toJSONString(status), 1, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
@@ -88,15 +68,6 @@ public class RenderWorkerRepository {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void clearCache(Long id) {
|
||||
RenderWorkerEntity worker = getWorker(id);
|
||||
redisTemplate.delete(String.format(RENDER_WORKER_CACHE_KEY, id));
|
||||
if (worker != null) {
|
||||
redisTemplate.delete(String.format(RENDER_WORKER_CACHE_KEY, worker.getAccessKey()));
|
||||
}
|
||||
redisTemplate.delete(String.format(RENDER_WORKER_STATUS_CACHE_KEY, id));
|
||||
}
|
||||
|
||||
private RenderWorkerEntity convertToEntity(RenderWorkerV2DTO dto) {
|
||||
if (dto == null) {
|
||||
return null;
|
||||
|
Reference in New Issue
Block a user