diff options
author | Abyss777 <abyss@fox5.ru> | 2016-07-13 18:44:46 +0500 |
---|---|---|
committer | Abyss777 <abyss@fox5.ru> | 2016-07-13 18:44:46 +0500 |
commit | 8bf78f0d21c16c0538b60c05a5f6934a890de1a8 (patch) | |
tree | 9033586d9a69b2b03c47ace03a06fd35f3f8574d /src/org | |
parent | 51f22a533b0e511bd97da6d46a676ac15a47884d (diff) | |
download | trackermap-server-8bf78f0d21c16c0538b60c05a5f6934a890de1a8.tar.gz trackermap-server-8bf78f0d21c16c0538b60c05a5f6934a890de1a8.tar.bz2 trackermap-server-8bf78f0d21c16c0538b60c05a5f6934a890de1a8.zip |
Reduce locks of devices
Diffstat (limited to 'src/org')
-rw-r--r-- | src/org/traccar/database/DataManager.java | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/org/traccar/database/DataManager.java b/src/org/traccar/database/DataManager.java index b3f24383f..0dc3c5c52 100644 --- a/src/org/traccar/database/DataManager.java +++ b/src/org/traccar/database/DataManager.java @@ -401,9 +401,11 @@ public class DataManager implements IdentityManager { QueryBuilder.create(dataSource, getQuery("database.updateDeviceStatus")) .setObject(device) .executeUpdate(); - Device cachedDevice = getDeviceById(device.getId()); - cachedDevice.setStatus(device.getStatus()); - cachedDevice.setMotion(device.getMotion()); + if (devicesById.containsKey(device.getId())) { + Device cachedDevice = devicesById.get(device.getId()); + cachedDevice.setStatus(device.getStatus()); + cachedDevice.setMotion(device.getMotion()); + } } public void removeDevice(long deviceId) throws SQLException { @@ -512,8 +514,10 @@ public class DataManager implements IdentityManager { .setDate("now", new Date()) .setObject(position) .executeUpdate(); - Device device = getDeviceById(position.getDeviceId()); - device.setPositionId(position.getId()); + if (devicesById.containsKey(position.getDeviceId())) { + Device cachedDevice = devicesById.get(position.getDeviceId()); + cachedDevice.setPositionId(position.getId()); + } } public Collection<Position> getLatestPositions() throws SQLException { |