Browse Source
Merge pull request #15562 from zzzeebra/fix/alarm-duration-cleanup-on-reinit
Fixed stale duration check future warning on alarm rule REINIT
pull/15589/head
Viacheslav Klimov
5 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
9 additions and
4 deletions
-
application/src/main/java/org/thingsboard/server/service/cf/ctx/state/alarm/AlarmCalculatedFieldState.java
-
application/src/main/java/org/thingsboard/server/service/cf/ctx/state/alarm/AlarmRuleState.java
|
|
@ -179,6 +179,7 @@ public class AlarmCalculatedFieldState extends BaseCalculatedFieldState { |
|
|
ruleState.setActive(null); |
|
|
ruleState.setActive(null); |
|
|
AlarmCondition condition = rule.getCondition(); |
|
|
AlarmCondition condition = rule.getCondition(); |
|
|
if (condition.hasSchedule() || (condition.getType() == AlarmConditionType.DURATION && !ruleState.isEmpty())) { |
|
|
if (condition.hasSchedule() || (condition.getType() == AlarmConditionType.DURATION && !ruleState.isEmpty())) { |
|
|
|
|
|
ruleState.cancelDurationCheckFuture(); |
|
|
reevalNeeded.set(true); |
|
|
reevalNeeded.set(true); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
@ -256,10 +256,7 @@ public class AlarmRuleState { |
|
|
firstEventTs = 0L; |
|
|
firstEventTs = 0L; |
|
|
lastCheckTs = 0L; |
|
|
lastCheckTs = 0L; |
|
|
duration = 0L; |
|
|
duration = 0L; |
|
|
if (durationCheckFuture != null) { |
|
|
cancelDurationCheckFuture(); |
|
|
durationCheckFuture.cancel(true); |
|
|
|
|
|
durationCheckFuture = null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void setDurationCheckFuture(ScheduledFuture<?> durationCheckFuture) { |
|
|
public void setDurationCheckFuture(ScheduledFuture<?> durationCheckFuture) { |
|
|
@ -270,6 +267,13 @@ public class AlarmRuleState { |
|
|
this.durationCheckFuture = durationCheckFuture; |
|
|
this.durationCheckFuture = durationCheckFuture; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void cancelDurationCheckFuture() { |
|
|
|
|
|
if (durationCheckFuture != null) { |
|
|
|
|
|
durationCheckFuture.cancel(true); |
|
|
|
|
|
durationCheckFuture = null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public boolean isEmpty() { |
|
|
public boolean isEmpty() { |
|
|
return eventCount == 0L && firstEventTs == 0L && lastCheckTs == 0L && durationCheckFuture == null; |
|
|
return eventCount == 0L && firstEventTs == 0L && lastCheckTs == 0L && durationCheckFuture == null; |
|
|
} |
|
|
} |
|
|
|