Skip to content

Commit

Permalink
Add a release mechanism for alarm windows when it is expired in case …
Browse files Browse the repository at this point in the history
…of OOM. (apache#11336)
  • Loading branch information
IceSoda177 authored Sep 15, 2023
1 parent 1943ce0 commit e448feb
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 80 deletions.
1 change: 1 addition & 0 deletions docs/en/changes/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Support Kafka Monitoring.
* [Breaking Change] Elasticsearch storage merge all management data indices into one index `management`,
including `ui_template,ui_menu,continuous_profiling_policy`.
* Add a release mechanism for alarm windows when it is expired in case of OOM.

#### UI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,14 @@ public void moveTo(LocalDateTime targetTime) {
*/
public List<AlarmMessage> check() {
List<AlarmMessage> alarmMessageList = new ArrayList<>(30);
List<AlarmEntity> expiredEntityList = new ArrayList<>();

windows.forEach((alarmEntity, window) -> {
if (window.isExpired()) {
expiredEntityList.add(alarmEntity);
return;
}

Optional<AlarmMessage> alarmMessageOptional = window.checkAlarm();
if (alarmMessageOptional.isPresent()) {
AlarmMessage alarmMessage = alarmMessageOptional.get();
Expand All @@ -218,6 +224,7 @@ public List<AlarmMessage> check() {
}
});

expiredEntityList.forEach(windows::remove);
return alarmMessageList;
}

Expand Down Expand Up @@ -383,6 +390,17 @@ private boolean isMatch() {
return isMatch == 1;
}

public boolean isExpired() {
if (this.values != null) {
for (Map<String, Metrics> value : this.values) {
if (value != null) {
return false;
}
}
}
return true;
}

private void init() {
values = new LinkedList<>();
for (int i = 0; i < period; i++) {
Expand Down
Loading

0 comments on commit e448feb

Please sign in to comment.