aboutsummaryrefslogtreecommitdiff
path: root/src/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-10-28 12:11:39 +1300
committerAnton Tananaev <anton.tananaev@gmail.com>2017-10-28 12:11:39 +1300
commitdb6fd89ae6c85056bd90bc325689be7d11ed5b75 (patch)
tree08e85658fe046adf9937fab79f2f3195fa6ab868 /src/org/traccar
parent65ffcb945a0cd62198d0570f9044114bb1e57528 (diff)
downloadtrackermap-server-db6fd89ae6c85056bd90bc325689be7d11ed5b75.tar.gz
trackermap-server-db6fd89ae6c85056bd90bc325689be7d11ed5b75.tar.bz2
trackermap-server-db6fd89ae6c85056bd90bc325689be7d11ed5b75.zip
Atomic statistics check (fix #3614)
Diffstat (limited to 'src/org/traccar')
-rw-r--r--src/org/traccar/database/StatisticsManager.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/org/traccar/database/StatisticsManager.java b/src/org/traccar/database/StatisticsManager.java
index 06a3e7b35..9a3ff06bd 100644
--- a/src/org/traccar/database/StatisticsManager.java
+++ b/src/org/traccar/database/StatisticsManager.java
@@ -27,12 +27,13 @@ import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
public class StatisticsManager {
private static final int SPLIT_MODE = Calendar.DAY_OF_MONTH;
- private int lastUpdate = Calendar.getInstance().get(SPLIT_MODE);
+ private AtomicInteger lastUpdate = new AtomicInteger(Calendar.getInstance().get(SPLIT_MODE));
private Set<Long> users = new HashSet<>();
private Set<Long> devices = new HashSet<>();
@@ -47,7 +48,7 @@ public class StatisticsManager {
private void checkSplit() {
int currentUpdate = Calendar.getInstance().get(SPLIT_MODE);
- if (lastUpdate != currentUpdate) {
+ if (lastUpdate.getAndSet(currentUpdate) != currentUpdate) {
Statistics statistics = new Statistics();
statistics.setCaptureTime(new Date());
statistics.setActiveUsers(users.size());
@@ -96,7 +97,6 @@ public class StatisticsManager {
smsSent = 0;
geocoderRequests = 0;
geolocationRequests = 0;
- lastUpdate = currentUpdate;
}
}