diff --git a/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/task/CacheAlertTask.java b/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/task/CacheAlertTask.java index 6eb40b394..d5e4c0db2 100644 --- a/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/task/CacheAlertTask.java +++ b/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/task/CacheAlertTask.java @@ -219,9 +219,10 @@ private boolean enableAlert(InspectConfig inspectConfig) { return status != null && status; } - public Integer ruleSize(String ruleType) { + public Integer ruleSize(String ruleType, byte status) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("rule_type", ruleType); + queryWrapper.eq("status", status); return this.alarmRuleDOMapper.selectCount(queryWrapper).intValue(); } diff --git a/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/task/coordinator/CoordinatorService.java b/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/task/coordinator/CoordinatorService.java index 3e9d18235..2b71b724b 100644 --- a/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/task/coordinator/CoordinatorService.java +++ b/server/home/home-alert/src/main/java/io/holoinsight/server/home/alert/service/task/coordinator/CoordinatorService.java @@ -113,9 +113,9 @@ public void spread(long heartbeat) { protected void calculateSelectRange(int realOrder) { double realSize = orderMap.getRealSize().doubleValue(); - double ruleSize = this.cacheAlertTask.ruleSize("rule").doubleValue(); - double aiSize = this.cacheAlertTask.ruleSize("ai").doubleValue(); - double pqlSize = this.cacheAlertTask.ruleSize("pql").doubleValue(); + double ruleSize = this.cacheAlertTask.ruleSize("rule", (byte) 1).doubleValue(); + double aiSize = this.cacheAlertTask.ruleSize("ai", (byte) 1).doubleValue(); + double pqlSize = this.cacheAlertTask.ruleSize("pql", (byte) 1).doubleValue(); // 领取任务,[(order-1)*(ruleSize/realSize), order*(ruleSize/realSize)) log.info("gossip order realOrder {}, realSize {}, ruleSize {}, aiSize {}, pqlSize {}", realOrder, realSize, ruleSize, aiSize, pqlSize); diff --git a/server/home/home-alert/src/test/java/io/holoinsight/server/home/alert/service/task/coordinator/CoordinatorServiceTest.java b/server/home/home-alert/src/test/java/io/holoinsight/server/home/alert/service/task/coordinator/CoordinatorServiceTest.java index f50c6057d..09205eca0 100644 --- a/server/home/home-alert/src/test/java/io/holoinsight/server/home/alert/service/task/coordinator/CoordinatorServiceTest.java +++ b/server/home/home-alert/src/test/java/io/holoinsight/server/home/alert/service/task/coordinator/CoordinatorServiceTest.java @@ -46,9 +46,9 @@ public void testCalculateSelectRange() { service.orderMap = Mockito.mock(OrderMap.class); Mockito.when(service.orderMap.getRealSize()).thenReturn(3); service.cacheAlertTask = Mockito.mock(CacheAlertTask.class); - Mockito.when(service.cacheAlertTask.ruleSize("ai")).thenReturn(73); - Mockito.when(service.cacheAlertTask.ruleSize("rule")).thenReturn(43); - Mockito.when(service.cacheAlertTask.ruleSize("pql")).thenReturn(1); + Mockito.when(service.cacheAlertTask.ruleSize("ai", (byte) 1)).thenReturn(73); + Mockito.when(service.cacheAlertTask.ruleSize("rule", (byte) 1)).thenReturn(43); + Mockito.when(service.cacheAlertTask.ruleSize("pql", (byte) 1)).thenReturn(1); order(service); }