Add cleanup to method start and set the interval to 24h

This commit is contained in:
0xb00bface 2020-12-27 18:23:44 +01:00
parent 11ac6d905d
commit 5d50515b81
1 changed files with 4 additions and 4 deletions

View File

@ -28,6 +28,10 @@ public class MissedSegmentsStatistics {
private MissedSegmentsStatistics() {}
public static void increase(Model model, short amount) {
if (Duration.between(lastclear, Instant.now()).toHours() > 24) {
missegSegmentsCount.clear();
LOG.debug("Missed segments statistics cleared");
}
short total = missegSegmentsCount.getOrDefault(model, (short) 0);
missegSegmentsCount.put(model, (short) (total + amount));
if (t == null) {
@ -47,10 +51,6 @@ public class MissedSegmentsStatistics {
t.setDaemon(true);
t.start();
}
if (Duration.between(lastclear, Instant.now()).toMinutes() > 60) {
missegSegmentsCount.clear();
LOG.debug("Missed segments statistics cleared");
}
}
private static void printStatistics() {