Skip to content

Commit

Permalink
Merge #5899
Browse files Browse the repository at this point in the history
5899: [Backport stable/0.25] Schedule clean up periodically r=deepthidevaki a=github-actions[bot]

# Description
Backport of #5884 to `stable/0.25`.

closes #5882

Co-authored-by: Christopher Zell <zelldon91@googlemail.com>
  • Loading branch information
zeebe-bors[bot] and ChrisKujawa authored Nov 23, 2020
2 parents d19415e + a97af0b commit 4d0928f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class MetricsExporter implements Exporter {
private final Long2LongHashMap jobKeyToCreationTimeMap;
private final Long2LongHashMap workflowInstanceKeyToCreationTimeMap;

// only used to keep track of how long the entries are existing and to clean up the corresponding
// maps
private final NavigableMap<Long, Long> creationTimeToJobKeyNavigableMap;
private final NavigableMap<Long, Long> creationTimeToWorkflowInstanceKeyNavigableMap;

Expand All @@ -53,6 +55,8 @@ public void open(final Controller controller) {
public void close() {
jobKeyToCreationTimeMap.clear();
workflowInstanceKeyToCreationTimeMap.clear();
creationTimeToJobKeyNavigableMap.clear();
creationTimeToWorkflowInstanceKeyNavigableMap.clear();
}

@Override
Expand Down Expand Up @@ -125,6 +129,8 @@ private void cleanUp() {
deadTime,
creationTimeToWorkflowInstanceKeyNavigableMap,
workflowInstanceKeyToCreationTimeMap);

controller.scheduleTask(TIME_TO_LIVE, this::cleanUp);
}

private void clearMaps(
Expand Down

0 comments on commit 4d0928f

Please sign in to comment.