Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
saimu.msm committed Apr 10, 2024
1 parent b90736e commit e334593
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<AlarmRule> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("rule_type", ruleType);
queryWrapper.eq("status", status);
return this.alarmRuleDOMapper.selectCount(queryWrapper).intValue();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit e334593

Please sign in to comment.