Browse Source
Merge pull request #14688 from thingsboard/fix/alarm-test-race
Fix occasional alarm rule test failure due to race condition
pull/14703/head
Viacheslav Klimov
9 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
10 additions and
1 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
|
|
|
@ -150,7 +150,8 @@ public class AlarmCalculatedFieldState extends BaseCalculatedFieldState { |
|
|
|
clearRuleState = null; |
|
|
|
} |
|
|
|
} |
|
|
|
log.debug("Initialized create rule states {} and clear rule state {} for {}", createRuleStates, clearRuleState, configuration); |
|
|
|
log.debug("Initialized create rule states {} and clear rule state {} for {}. Restored: {}, reeval needed: {}", |
|
|
|
createRuleStates, clearRuleState, configuration, restored, reevalNeeded); |
|
|
|
|
|
|
|
if (reevalNeeded.get()) { |
|
|
|
initCurrentAlarm(ctx); |
|
|
|
|
|
|
|
@ -262,6 +262,14 @@ public class AlarmRuleState { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void setDurationCheckFuture(ScheduledFuture<?> durationCheckFuture) { |
|
|
|
if (this.durationCheckFuture != null) { |
|
|
|
log.warn("Setting new duration check future while previous is not null for state {}", this, new RuntimeException("stacktrace")); |
|
|
|
this.durationCheckFuture.cancel(true); |
|
|
|
} |
|
|
|
this.durationCheckFuture = durationCheckFuture; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean isEmpty() { |
|
|
|
return eventCount == 0L && firstEventTs == 0L && lastCheckTs == 0L && durationCheckFuture == null; |
|
|
|
} |
|
|
|
|