This is an automated email from the ASF dual-hosted git repository.
shown pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/master by this push:
new 88aeb9fc2 [bugfix] fix alarm recover not match in converge reduce in
some condition (#2603)
88aeb9fc2 is described below
commit 88aeb9fc2179f3691407224ffb8f94dda91bbb53
Author: tomsun28 <[email protected]>
AuthorDate: Sun Aug 25 18:24:10 2024 +0800
[bugfix] fix alarm recover not match in converge reduce in some condition
(#2603)
Signed-off-by: tomsun28 <[email protected]>
---
.../alert/reduce/AlarmConvergeReduce.java | 24 +++++++++++-----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git
a/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java
b/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java
index 936cb2d8b..8b8dbb257 100644
---
a/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java
+++
b/alerter/src/main/java/org/apache/hertzbeat/alert/reduce/AlarmConvergeReduce.java
@@ -64,17 +64,11 @@ public class AlarmConvergeReduce {
isHasIgnore = true;
tags.remove(CommonConstants.IGNORE);
}
- int alertHash =
Objects.hash(CommonConstants.ALERT_PRIORITY_CODE_CRITICAL)
- + Arrays.hashCode(tags.keySet().toArray(new String[0]))
- + Arrays.hashCode(tags.values().toArray(new String[0]));
+ int alertHash =
generateAlertHash(CommonConstants.ALERT_PRIORITY_CODE_CRITICAL, tags);
converageAlertMap.remove(alertHash);
- alertHash =
Objects.hash(CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY)
- + Arrays.hashCode(tags.keySet().toArray(new String[0]))
- + Arrays.hashCode(tags.values().toArray(new String[0]));
+ alertHash =
generateAlertHash(CommonConstants.ALERT_PRIORITY_CODE_EMERGENCY, tags);
converageAlertMap.remove(alertHash);
- alertHash =
Objects.hash(CommonConstants.ALERT_PRIORITY_CODE_WARNING)
- + Arrays.hashCode(tags.keySet().toArray(new String[0]))
- + Arrays.hashCode(tags.values().toArray(new String[0]));
+ alertHash =
generateAlertHash(CommonConstants.ALERT_PRIORITY_CODE_WARNING, tags);
converageAlertMap.remove(alertHash);
if (isHasIgnore) {
tags.put(CommonConstants.IGNORE, CommonConstants.IGNORE);
@@ -132,9 +126,7 @@ public class AlarmConvergeReduce {
if (evalInterval <= 0) {
return true;
}
- int alertHash = Objects.hash(currentAlert.getPriority())
- +
Arrays.hashCode(currentAlert.getTags().keySet().toArray(new String[0]))
- +
Arrays.hashCode(currentAlert.getTags().values().toArray(new String[0]));
+ int alertHash = generateAlertHash(currentAlert.getPriority(),
currentAlert.getTags());
Alert preAlert = converageAlertMap.get(alertHash);
if (preAlert == null) {
currentAlert.setTimes(1);
@@ -165,4 +157,12 @@ public class AlarmConvergeReduce {
}
return true;
}
+
+ private int generateAlertHash(byte priority, Map<String, String> tags) {
+ List<String> keyList =
tags.keySet().stream().filter(Objects::nonNull).sorted().toList();
+ List<String> valueList =
tags.values().stream().filter(Objects::nonNull).sorted().toList();
+ return Objects.hash(priority)
+ + Arrays.hashCode(keyList.toArray(new String[0]))
+ + Arrays.hashCode(valueList.toArray(new String[0]));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]