渲染机

This commit is contained in:
2025-07-18 14:22:54 +08:00
parent 52086dbea4
commit d7d503212f
4 changed files with 33 additions and 0 deletions

View File

@@ -21,4 +21,6 @@ public interface RenderWorkerMapper {
int updateStatus(Long id);
RenderWorkerEntity findByAccessKey(String accessKey);
int updateHost(Long id, RenderWorkerEntity status);
}

View File

@@ -8,6 +8,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.concurrent.TimeUnit;
@@ -52,6 +54,21 @@ 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, JSONObject.toJSONString(status), 1, TimeUnit.HOURS);
}

View File

@@ -175,6 +175,7 @@ public class TaskTaskServiceImpl implements TaskService {
taskList.forEach(task -> {
taskMapper.assignToWorker(task.getId(), worker.getId());
videoTaskRepository.clearTaskCache(task.getId());
repository.clearCache(worker.getId());
});
} finally {
lock.unlock();

View File

@@ -65,6 +65,19 @@
END)
where id = #{id}
</update>
<update id="updateHost">
update render_worker
set platform = #{status.platform},
runtime_version = #{status.runtimeVersion},
version = #{status.version},
cpu_count = #{status.cpuCount},
cpu_usage = #{status.cpuUsage},
memory_total = #{status.memoryTotal},
memory_available = #{status.memoryAvailable},
support_feature = #{status.supportFeature},
update_at = #{status.updateAt}
where id = #{id}
</update>
<delete id="deleteById">
delete from render_worker where id = #{id}
</delete>