aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-18 10:37:21 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-18 10:37:21 -0700
commit182656b6dc1fb5d167bb752c16ecf633add001a8 (patch)
tree917ab178c91a60f4639248298cb589a63d943989 /src/main/java
parent97a189c51817a6b1d7a86aece8a91ff378488799 (diff)
downloadtrackermap-server-182656b6dc1fb5d167bb752c16ecf633add001a8.tar.gz
trackermap-server-182656b6dc1fb5d167bb752c16ecf633add001a8.tar.bz2
trackermap-server-182656b6dc1fb5d167bb752c16ecf633add001a8.zip
Remove unused code
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/org/traccar/Context.java2
-rw-r--r--src/main/java/org/traccar/database/BaseObjectManager.java4
-rw-r--r--src/main/java/org/traccar/database/DeviceManager.java74
-rw-r--r--src/main/java/org/traccar/database/IdentityManager.java2
-rw-r--r--src/main/java/org/traccar/helper/model/AttributeUtil.java2
5 files changed, 2 insertions, 82 deletions
diff --git a/src/main/java/org/traccar/Context.java b/src/main/java/org/traccar/Context.java
index 9e8e3c521..854af97c0 100644
--- a/src/main/java/org/traccar/Context.java
+++ b/src/main/java/org/traccar/Context.java
@@ -25,7 +25,6 @@ import org.traccar.helper.Log;
import org.traccar.model.BaseModel;
import org.traccar.model.Device;
import org.traccar.session.ConnectionManager;
-import org.traccar.session.cache.CacheManager;
import org.traccar.storage.Storage;
public final class Context {
@@ -70,7 +69,6 @@ public final class Context {
deviceManager = new DeviceManager(
config,
- Main.getInjector().getInstance(CacheManager.class),
Main.getInjector().getInstance(DataManager.class),
Main.getInjector().getInstance(ConnectionManager.class));
diff --git a/src/main/java/org/traccar/database/BaseObjectManager.java b/src/main/java/org/traccar/database/BaseObjectManager.java
index dd8b3bae4..c94053985 100644
--- a/src/main/java/org/traccar/database/BaseObjectManager.java
+++ b/src/main/java/org/traccar/database/BaseObjectManager.java
@@ -67,10 +67,6 @@ public class BaseObjectManager<T extends BaseModel> {
return dataManager;
}
- protected final Class<T> getBaseClass() {
- return baseClass;
- }
-
public T getById(long itemId) {
try {
readLock();
diff --git a/src/main/java/org/traccar/database/DeviceManager.java b/src/main/java/org/traccar/database/DeviceManager.java
index 86334ede8..841915f1c 100644
--- a/src/main/java/org/traccar/database/DeviceManager.java
+++ b/src/main/java/org/traccar/database/DeviceManager.java
@@ -20,14 +20,10 @@ import org.slf4j.LoggerFactory;
import org.traccar.Context;
import org.traccar.config.Config;
import org.traccar.config.Keys;
-import org.traccar.model.Command;
import org.traccar.model.Device;
-import org.traccar.model.Group;
import org.traccar.model.Position;
-import org.traccar.model.Server;
import org.traccar.session.ConnectionManager;
import org.traccar.session.DeviceState;
-import org.traccar.session.cache.CacheManager;
import org.traccar.storage.StorageException;
import java.util.Collection;
@@ -43,12 +39,9 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
private static final Logger LOGGER = LoggerFactory.getLogger(DeviceManager.class);
- private final Config config;
- private final CacheManager cacheManager;
private final ConnectionManager connectionManager;
private final long dataRefreshDelay;
- private Map<String, Device> devicesByUniqueId;
private final AtomicLong devicesLastUpdate = new AtomicLong();
private final Map<Long, Position> positions = new ConcurrentHashMap<>();
@@ -56,19 +49,9 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
private final Map<Long, DeviceState> deviceStates = new ConcurrentHashMap<>();
public DeviceManager(
- Config config, CacheManager cacheManager, DataManager dataManager, ConnectionManager connectionManager) {
+ Config config, DataManager dataManager, ConnectionManager connectionManager) {
super(dataManager, Device.class);
- this.config = config;
- this.cacheManager = cacheManager;
this.connectionManager = connectionManager;
- try {
- writeLock();
- if (devicesByUniqueId == null) {
- devicesByUniqueId = new ConcurrentHashMap<>();
- }
- } finally {
- writeUnlock();
- }
dataRefreshDelay = config.getLong(Keys.DATABASE_REFRESH_DELAY) * 1000;
refreshLastPositions();
}
@@ -82,24 +65,6 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
}
@Override
- public Device getByUniqueId(String uniqueId) {
- boolean forceUpdate;
- try {
- readLock();
- forceUpdate = !devicesByUniqueId.containsKey(uniqueId) && !config.getBoolean(Keys.DATABASE_IGNORE_UNKNOWN);
- } finally {
- readUnlock();
- }
- updateDeviceCache(forceUpdate);
- try {
- readLock();
- return devicesByUniqueId.get(uniqueId);
- } finally {
- readUnlock();
- }
- }
-
- @Override
public Set<Long> getAllItems() {
Set<Long> result = super.getAllItems();
if (result.isEmpty()) {
@@ -132,35 +97,6 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
}
}
- private void addByUniqueId(Device device) {
- try {
- writeLock();
- if (devicesByUniqueId == null) {
- devicesByUniqueId = new ConcurrentHashMap<>();
- }
- devicesByUniqueId.put(device.getUniqueId(), device);
- } finally {
- writeUnlock();
- }
- }
-
- private void removeByUniqueId(String deviceUniqueId) {
- try {
- writeLock();
- if (devicesByUniqueId != null) {
- devicesByUniqueId.remove(deviceUniqueId);
- }
- } finally {
- writeUnlock();
- }
- }
-
- @Override
- protected void addNewItem(Device device) {
- super.addNewItem(device);
- addByUniqueId(device);
- }
-
@Override
protected void updateCachedItem(Device device) {
Device cachedDevice = getById(device.getId());
@@ -172,20 +108,14 @@ public class DeviceManager extends BaseObjectManager<Device> implements Identity
cachedDevice.setModel(device.getModel());
cachedDevice.setDisabled(device.getDisabled());
cachedDevice.setAttributes(device.getAttributes());
- if (!device.getUniqueId().equals(cachedDevice.getUniqueId())) {
- removeByUniqueId(cachedDevice.getUniqueId());
- cachedDevice.setUniqueId(device.getUniqueId());
- addByUniqueId(cachedDevice);
- }
+ cachedDevice.setUniqueId(device.getUniqueId());
}
@Override
protected void removeCachedItem(long deviceId) {
Device cachedDevice = getById(deviceId);
if (cachedDevice != null) {
- String deviceUniqueId = cachedDevice.getUniqueId();
super.removeCachedItem(deviceId);
- removeByUniqueId(deviceUniqueId);
}
positions.remove(deviceId);
}
diff --git a/src/main/java/org/traccar/database/IdentityManager.java b/src/main/java/org/traccar/database/IdentityManager.java
index 5ef1c8c5e..b42d4c292 100644
--- a/src/main/java/org/traccar/database/IdentityManager.java
+++ b/src/main/java/org/traccar/database/IdentityManager.java
@@ -22,8 +22,6 @@ public interface IdentityManager {
Device getById(long id);
- Device getByUniqueId(String uniqueId) throws Exception;
-
Position getLastPosition(long deviceId);
boolean isLatestPosition(Position position);
diff --git a/src/main/java/org/traccar/helper/model/AttributeUtil.java b/src/main/java/org/traccar/helper/model/AttributeUtil.java
index 225089d5c..58b922d95 100644
--- a/src/main/java/org/traccar/helper/model/AttributeUtil.java
+++ b/src/main/java/org/traccar/helper/model/AttributeUtil.java
@@ -15,11 +15,9 @@
*/
package org.traccar.helper.model;
-import org.traccar.Context;
import org.traccar.config.ConfigKey;
import org.traccar.config.KeyType;
import org.traccar.config.Keys;
-import org.traccar.model.Command;
import org.traccar.model.Device;
import org.traccar.model.Group;
import org.traccar.session.cache.CacheManager;