aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/org/traccar/database
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/traccar/database')
-rw-r--r--src/main/java/org/traccar/database/DataManager.java7
-rw-r--r--src/main/java/org/traccar/database/DeviceManager.java41
2 files changed, 2 insertions, 46 deletions
diff --git a/src/main/java/org/traccar/database/DataManager.java b/src/main/java/org/traccar/database/DataManager.java
index bfc79eb77..398c63892 100644
--- a/src/main/java/org/traccar/database/DataManager.java
+++ b/src/main/java/org/traccar/database/DataManager.java
@@ -16,7 +16,6 @@
package org.traccar.database;
import org.traccar.model.BaseModel;
-import org.traccar.model.Device;
import org.traccar.model.Server;
import org.traccar.storage.Storage;
import org.traccar.storage.StorageException;
@@ -36,12 +35,6 @@ public class DataManager {
this.storage = storage;
}
- public void updateDeviceStatus(Device device) throws StorageException {
- storage.updateObject(device, new Request(
- new Columns.Include("lastUpdate"),
- new Condition.Equals("id", "id")));
- }
-
public Server getServer() throws StorageException {
return storage.getObject(Server.class, new Request(new Columns.All()));
}
diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java
index d6c442f10..7a472c2d4 100644
--- a/src/main/java/org/traccar/database/DeviceManager.java
+++ b/src/main/java/org/traccar/database/DeviceManager.java
@@ -15,34 +15,22 @@
*/
package org.traccar.database;
-import org.traccar.config.Config;
-import org.traccar.config.Keys;
import org.traccar.model.Device;
-import org.traccar.session.DeviceState;
-import org.traccar.storage.StorageException;
-import java.util.Collection;
-import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
public class DeviceManager extends BaseObjectManager<Device> {
- private final long dataRefreshDelay;
-
private final AtomicLong devicesLastUpdate = new AtomicLong();
- private final Map<Long, DeviceState> deviceStates = new ConcurrentHashMap<>();
-
- public DeviceManager(Config config, DataManager dataManager) {
+ public DeviceManager(DataManager dataManager) {
super(dataManager, Device.class);
- dataRefreshDelay = config.getLong(Keys.DATABASE_REFRESH_DELAY) * 1000;
}
public void updateDeviceCache(boolean force) {
long lastUpdate = devicesLastUpdate.get();
- if ((force || System.currentTimeMillis() - lastUpdate > dataRefreshDelay)
+ if ((force || System.currentTimeMillis() - lastUpdate > 300000L)
&& devicesLastUpdate.compareAndSet(lastUpdate, System.currentTimeMillis())) {
refreshItems();
}
@@ -58,10 +46,6 @@ public class DeviceManager extends BaseObjectManager<Device> {
return result;
}
- public Collection<Device> getAllDevices() {
- return getItems(getAllItems());
- }
-
@Override
protected void updateCachedItem(Device device) {
Device cachedDevice = getById(device.getId());
@@ -84,25 +68,4 @@ public class DeviceManager extends BaseObjectManager<Device> {
}
}
- public void updateDeviceStatus(Device device) throws StorageException {
- getDataManager().updateDeviceStatus(device);
- Device cachedDevice = getById(device.getId());
- if (cachedDevice != null) {
- cachedDevice.setStatus(device.getStatus());
- }
- }
-
- public DeviceState getDeviceState(long deviceId) {
- DeviceState deviceState = deviceStates.get(deviceId);
- if (deviceState == null) {
- deviceState = new DeviceState();
- deviceStates.put(deviceId, deviceState);
- }
- return deviceState;
- }
-
- public void setDeviceState(long deviceId, DeviceState deviceState) {
- deviceStates.put(deviceId, deviceState);
- }
-
}