From a4c44b9a17a57dfd6f29dad02aacdf48b97018aa Mon Sep 17 00:00:00 2001 From: JangCan <2862008188@qq.com> Date: Sat, 20 Apr 2024 11:00:53 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E5=8A=A0=E5=85=A5=E7=9B=B8=E5=BA=94?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../loadcenter/controller/GatewayController.java | 13 +++++++++++++ .../com/loadcenter/service/GatewayLoadService.java | 12 +++++++++++- .../service/impl/GatewayLoadServiceImpl.java | 4 ++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/loadcenter/controller/GatewayController.java b/src/main/java/com/loadcenter/controller/GatewayController.java index e858b51..0795f22 100644 --- a/src/main/java/com/loadcenter/controller/GatewayController.java +++ b/src/main/java/com/loadcenter/controller/GatewayController.java @@ -40,4 +40,17 @@ public class GatewayController { public void scheduleECS(){ gatewayLoadService.scheduleECS(); } + + /** + * 刷新负载规则 实现动态负载 + */ + @Scheduled(cron = "0/30 * * * * ?") + public void refresh(){ + gatewayLoadService.refresh(); + } + + @Scheduled(cron = "0/30 * * * * ?") + public void dynamicEcs()throws Exception{ + gatewayLoadService.dynamicEcs(); + } } diff --git a/src/main/java/com/loadcenter/service/GatewayLoadService.java b/src/main/java/com/loadcenter/service/GatewayLoadService.java index 6fd3409..8368c82 100644 --- a/src/main/java/com/loadcenter/service/GatewayLoadService.java +++ b/src/main/java/com/loadcenter/service/GatewayLoadService.java @@ -12,8 +12,18 @@ public interface GatewayLoadService { */ String loadNode(); - + /** + * 查询ECS车辆连接数 + */ void scheduleECS(); + /** + * 刷新负载规则 实现动态负载 + */ void refresh(); + + /** + * 动态ECS + */ + void dynamicEcs() throws Exception; } diff --git a/src/main/java/com/loadcenter/service/impl/GatewayLoadServiceImpl.java b/src/main/java/com/loadcenter/service/impl/GatewayLoadServiceImpl.java index 664e0ab..0848253 100644 --- a/src/main/java/com/loadcenter/service/impl/GatewayLoadServiceImpl.java +++ b/src/main/java/com/loadcenter/service/impl/GatewayLoadServiceImpl.java @@ -76,6 +76,9 @@ public class GatewayLoadServiceImpl implements GatewayLoadService { } + /** + * 查询ECS车辆连接数 + */ @Override public void scheduleECS() { //客户端初始化 @@ -190,6 +193,7 @@ public class GatewayLoadServiceImpl implements GatewayLoadService { /** * 动态ECS */ + @Override public void dynamicEcs() throws Exception { //上线最大数量 Long vehicleMaxOnlineNum = gatewayNodeScoreCache.getNodeMaxOnlineNum();