thingsboard-developers
Changes
application/ignored 26(+26 -0)
application/pom.xml 54(+54 -0)
application/src/main/java/org/thingsboard/server/actors/device/DeviceActorMessageProcessor.java 132(+66 -66)
application/src/main/java/org/thingsboard/server/service/cluster/discovery/ZkDiscoveryService.java 159(+81 -78)
application/src/main/java/org/thingsboard/server/service/session/DefaultDeviceSessionCacheService.java 38(+19 -19)
application/src/main/java/org/thingsboard/server/service/session/DeviceSessionCacheService.java 10(+5 -5)
common/queue/ignored 10(+10 -0)
common/queue/pom.xml 56(+56 -0)
dao/ignored 24(+24 -0)
dao/pom.xml 54(+54 -0)
docker/tb-node.env 2(+1 -1)
docker-compose.yml 6(+6 -0)
rule-engine/rule-engine-components/ignored 13(+13 -0)
rule-engine/rule-engine-components/pom.xml 55(+54 -1)
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAbstractCustomerActionNode.java 34(+20 -14)
rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAbstractCustomerActionNodeConfiguration.java 2(+1 -1)
Details
application/ignored 26(+26 -0)
diff --git a/application/ignored b/application/ignored
new file mode 100644
index 0000000..c1db740
--- /dev/null
+++ b/application/ignored
@@ -0,0 +1,26 @@
+org.projectlombok.
+ch.qos.logback.
+com.github.springtestdbunit.
+com.google.protobuf.
+com.jayway.jsonpath.
+com.sun.winsw.
+com.typesafe.akka.
+commons-io.
+io.grpc.
+io.jsonwebtoken.
+io.netty.
+io.springfox.
+io.takari.junit.
+javax.mail.
+junit.
+org.apache.commons.
+org.apache.curator.
+org.apache.velocity.
+org.cassandraunit.
+org.dbunit.
+org.eclipse.paho.
+org.hsqldb.
+org.javadelight.
+org.mockito.
+org.slf4j.
+org.springframework.
\ No newline at end of file
application/pom.xml 54(+54 -0)
diff --git a/application/pom.xml b/application/pom.xml
index 8b37284..6ca55bd 100644
--- a/application/pom.xml
+++ b/application/pom.xml
@@ -264,6 +264,11 @@
<groupId>org.javadelight</groupId>
<artifactId>delight-nashorn-sandbox</artifactId>
</dependency>
+ <dependency>
+ <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
+ <artifactId>ApplicationTracer</artifactId>
+ <version>1.0</version>
+ </dependency>
</dependencies>
<build>
@@ -606,6 +611,55 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
</plugin>
+
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>aspectj-maven-plugin</artifactId>
+ <version>1.11</version>
+ <configuration>
+ <showWeaveInfo>false</showWeaveInfo>
+ <complianceLevel>1.8</complianceLevel>
+ <source>1.8</source>
+ <target>1.8</target>
+ <Xlint>ignore</Xlint>
+ <encoding>UTF-8</encoding>
+ <verbose>false</verbose>
+ <forceAjcCompile>true</forceAjcCompile>
+ <sources/>
+ <weaveDirectories>
+ <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
+ </weaveDirectories>
+ <aspectLibraries>
+ <aspectLibrary>
+ <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
+ <artifactId>ApplicationTracer</artifactId>
+ </aspectLibrary>
+ </aspectLibraries>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjtools</artifactId>
+ <version>1.9.1</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+
</plugins>
</build>
<repositories>
diff --git a/application/src/main/java/org/thingsboard/server/actors/ActorSystemContext.java b/application/src/main/java/org/thingsboard/server/actors/ActorSystemContext.java
index 6ed400a..62cda58 100644
--- a/application/src/main/java/org/thingsboard/server/actors/ActorSystemContext.java
+++ b/application/src/main/java/org/thingsboard/server/actors/ActorSystemContext.java
@@ -70,7 +70,7 @@ import org.thingsboard.server.service.mail.MailExecutorService;
import org.thingsboard.server.service.rpc.DeviceRpcService;
import org.thingsboard.server.service.script.JsExecutorService;
import org.thingsboard.server.service.script.JsInvokeService;
-import org.thingsboard.server.service.session.DeviceSessionCacheService;
+//import org.thingsboard.server.service.session.DeviceSessionCacheService;
import org.thingsboard.server.service.state.DeviceStateService;
import org.thingsboard.server.service.telemetry.TelemetrySubscriptionService;
import org.thingsboard.server.service.transport.RuleEngineTransportService;
@@ -213,9 +213,9 @@ public class ActorSystemContext {
@Getter
private DeviceStateService deviceStateService;
- @Autowired
- @Getter
- private DeviceSessionCacheService deviceSessionCacheService;
+// @Autowired
+// @Getter
+// private DeviceSessionCacheService deviceSessionCacheService;
@Lazy
@Autowired
diff --git a/application/src/main/java/org/thingsboard/server/actors/device/DeviceActorMessageProcessor.java b/application/src/main/java/org/thingsboard/server/actors/device/DeviceActorMessageProcessor.java
index e46a959..f86420e 100644
--- a/application/src/main/java/org/thingsboard/server/actors/device/DeviceActorMessageProcessor.java
+++ b/application/src/main/java/org/thingsboard/server/actors/device/DeviceActorMessageProcessor.java
@@ -119,7 +119,7 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
this.toDeviceRpcPendingMap = new HashMap<>();
this.toServerRpcPendingMap = new HashMap<>();
initAttributes();
- restoreSessions();
+// restoreSessions();
}
private void initAttributes() {
@@ -427,7 +427,7 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
sessionMD.setSubscribedToAttributes(true);
log.debug("[{}] Registering attributes subscription for session [{}]", deviceId, sessionId);
attributeSubscriptions.put(sessionId, sessionMD.getSessionInfo());
- dumpSessions();
+ //dumpSessions();
}
}
@@ -449,7 +449,7 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
log.debug("[{}] Registering rpc subscription for session [{}]", deviceId, sessionId);
rpcSubscriptions.put(sessionId, sessionMD.getSessionInfo());
sendPendingRequests(context, sessionId, sessionInfo);
- dumpSessions();
+// dumpSessions();
}
}
@@ -471,7 +471,7 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
if (sessions.size() == 1) {
reportSessionOpen();
}
- dumpSessions();
+// dumpSessions();
} else if (msg.getEvent() == SessionEvent.CLOSED) {
log.debug("[{}] Canceling subscriptions for closed session [{}]", deviceId, sessionId);
sessions.remove(sessionId);
@@ -480,7 +480,7 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
if (sessions.isEmpty()) {
reportSessionClose();
}
- dumpSessions();
+// dumpSessions();
}
}
@@ -498,14 +498,14 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
if (subscriptionInfo.getRpcSubscription()) {
rpcSubscriptions.putIfAbsent(sessionId, sessionMD.getSessionInfo());
}
- dumpSessions();
+// dumpSessions();
}
void processCredentialsUpdate() {
sessions.forEach(this::notifyTransportAboutClosedSession);
attributeSubscriptions.clear();
rpcSubscriptions.clear();
- dumpSessions();
+// dumpSessions();
}
private void notifyTransportAboutClosedSession(UUID sessionId, SessionInfoMetaData sessionMd) {
@@ -628,64 +628,64 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
return builder.build();
}
- private void restoreSessions() {
- log.debug("[{}] Restoring sessions from cache", deviceId);
- TransportProtos.DeviceSessionsCacheEntry sessionsDump = null;
- try {
- sessionsDump = TransportProtos.DeviceSessionsCacheEntry.parseFrom(systemContext.getDeviceSessionCacheService().get(deviceId));
- } catch (InvalidProtocolBufferException e) {
- log.warn("[{}] Failed to decode device sessions from cache", deviceId);
- return;
- }
- if (sessionsDump.getSessionsCount() == 0) {
- log.debug("[{}] No session information found", deviceId);
- return;
- }
- for (TransportProtos.SessionSubscriptionInfoProto sessionSubscriptionInfoProto : sessionsDump.getSessionsList()) {
- SessionInfoProto sessionInfoProto = sessionSubscriptionInfoProto.getSessionInfo();
- UUID sessionId = getSessionId(sessionInfoProto);
- SessionInfo sessionInfo = new SessionInfo(TransportProtos.SessionType.ASYNC, sessionInfoProto.getNodeId());
- TransportProtos.SubscriptionInfoProto subInfo = sessionSubscriptionInfoProto.getSubscriptionInfo();
- SessionInfoMetaData sessionMD = new SessionInfoMetaData(sessionInfo, subInfo.getLastActivityTime());
- sessions.put(sessionId, sessionMD);
- if (subInfo.getAttributeSubscription()) {
- attributeSubscriptions.put(sessionId, sessionInfo);
- sessionMD.setSubscribedToAttributes(true);
- }
- if (subInfo.getRpcSubscription()) {
- rpcSubscriptions.put(sessionId, sessionInfo);
- sessionMD.setSubscribedToRPC(true);
- }
- log.debug("[{}] Restored session: {}", deviceId, sessionMD);
- }
- log.debug("[{}] Restored sessions: {}, rpc subscriptions: {}, attribute subscriptions: {}", deviceId, sessions.size(), rpcSubscriptions.size(), attributeSubscriptions.size());
- }
-
- private void dumpSessions() {
- log.debug("[{}] Dumping sessions: {}, rpc subscriptions: {}, attribute subscriptions: {} to cache", deviceId, sessions.size(), rpcSubscriptions.size(), attributeSubscriptions.size());
- List<TransportProtos.SessionSubscriptionInfoProto> sessionsList = new ArrayList<>(sessions.size());
- sessions.forEach((uuid, sessionMD) -> {
- if (sessionMD.getSessionInfo().getType() == TransportProtos.SessionType.SYNC) {
- return;
- }
- SessionInfo sessionInfo = sessionMD.getSessionInfo();
- TransportProtos.SubscriptionInfoProto subscriptionInfoProto = TransportProtos.SubscriptionInfoProto.newBuilder()
- .setLastActivityTime(sessionMD.getLastActivityTime())
- .setAttributeSubscription(sessionMD.isSubscribedToAttributes())
- .setRpcSubscription(sessionMD.isSubscribedToRPC()).build();
- TransportProtos.SessionInfoProto sessionInfoProto = TransportProtos.SessionInfoProto.newBuilder()
- .setSessionIdMSB(uuid.getMostSignificantBits())
- .setSessionIdLSB(uuid.getLeastSignificantBits())
- .setNodeId(sessionInfo.getNodeId()).build();
- sessionsList.add(TransportProtos.SessionSubscriptionInfoProto.newBuilder()
- .setSessionInfo(sessionInfoProto)
- .setSubscriptionInfo(subscriptionInfoProto).build());
- log.debug("[{}] Dumping session: {}", deviceId, sessionMD);
- });
- systemContext.getDeviceSessionCacheService()
- .put(deviceId, TransportProtos.DeviceSessionsCacheEntry.newBuilder()
- .addAllSessions(sessionsList).build().toByteArray());
- }
+// private void restoreSessions() {
+// log.debug("[{}] Restoring sessions from cache", deviceId);
+// TransportProtos.DeviceSessionsCacheEntry sessionsDump = null;
+// try {
+// sessionsDump = TransportProtos.DeviceSessionsCacheEntry.parseFrom(systemContext.getDeviceSessionCacheService().get(deviceId));
+// } catch (InvalidProtocolBufferException e) {
+// log.warn("[{}] Failed to decode device sessions from cache", deviceId);
+// return;
+// }
+// if (sessionsDump.getSessionsCount() == 0) {
+// log.debug("[{}] No session information found", deviceId);
+// return;
+// }
+// for (TransportProtos.SessionSubscriptionInfoProto sessionSubscriptionInfoProto : sessionsDump.getSessionsList()) {
+// SessionInfoProto sessionInfoProto = sessionSubscriptionInfoProto.getSessionInfo();
+// UUID sessionId = getSessionId(sessionInfoProto);
+// SessionInfo sessionInfo = new SessionInfo(TransportProtos.SessionType.ASYNC, sessionInfoProto.getNodeId());
+// TransportProtos.SubscriptionInfoProto subInfo = sessionSubscriptionInfoProto.getSubscriptionInfo();
+// SessionInfoMetaData sessionMD = new SessionInfoMetaData(sessionInfo, subInfo.getLastActivityTime());
+// sessions.put(sessionId, sessionMD);
+// if (subInfo.getAttributeSubscription()) {
+// attributeSubscriptions.put(sessionId, sessionInfo);
+// sessionMD.setSubscribedToAttributes(true);
+// }
+// if (subInfo.getRpcSubscription()) {
+// rpcSubscriptions.put(sessionId, sessionInfo);
+// sessionMD.setSubscribedToRPC(true);
+// }
+// log.debug("[{}] Restored session: {}", deviceId, sessionMD);
+// }
+// log.debug("[{}] Restored sessions: {}, rpc subscriptions: {}, attribute subscriptions: {}", deviceId, sessions.size(), rpcSubscriptions.size(), attributeSubscriptions.size());
+// }
+
+// private void dumpSessions() {
+// log.debug("[{}] Dumping sessions: {}, rpc subscriptions: {}, attribute subscriptions: {} to cache", deviceId, sessions.size(), rpcSubscriptions.size(), attributeSubscriptions.size());
+// List<TransportProtos.SessionSubscriptionInfoProto> sessionsList = new ArrayList<>(sessions.size());
+// sessions.forEach((uuid, sessionMD) -> {
+// if (sessionMD.getSessionInfo().getType() == TransportProtos.SessionType.SYNC) {
+// return;
+// }
+// SessionInfo sessionInfo = sessionMD.getSessionInfo();
+// TransportProtos.SubscriptionInfoProto subscriptionInfoProto = TransportProtos.SubscriptionInfoProto.newBuilder()
+// .setLastActivityTime(sessionMD.getLastActivityTime())
+// .setAttributeSubscription(sessionMD.isSubscribedToAttributes())
+// .setRpcSubscription(sessionMD.isSubscribedToRPC()).build();
+// TransportProtos.SessionInfoProto sessionInfoProto = TransportProtos.SessionInfoProto.newBuilder()
+// .setSessionIdMSB(uuid.getMostSignificantBits())
+// .setSessionIdLSB(uuid.getLeastSignificantBits())
+// .setNodeId(sessionInfo.getNodeId()).build();
+// sessionsList.add(TransportProtos.SessionSubscriptionInfoProto.newBuilder()
+// .setSessionInfo(sessionInfoProto)
+// .setSubscriptionInfo(subscriptionInfoProto).build());
+// log.debug("[{}] Dumping session: {}", deviceId, sessionMD);
+// });
+// systemContext.getDeviceSessionCacheService()
+// .put(deviceId, TransportProtos.DeviceSessionsCacheEntry.newBuilder()
+// .addAllSessions(sessionsList).build().toByteArray());
+// }
void initSessionTimeout(ActorContext context) {
schedulePeriodicMsgWithDelay(context, SessionTimeoutCheckMsg.instance(), systemContext.getSessionInactivityTimeout(), systemContext.getSessionInactivityTimeout());
@@ -701,7 +701,7 @@ class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcessor {
notifyTransportAboutClosedSession(sessionId, sessionMD);
});
if (!sessionsToRemove.isEmpty()) {
- dumpSessions();
+// dumpSessions();
}
}
}
diff --git a/application/src/main/java/org/thingsboard/server/service/cluster/discovery/ZkDiscoveryService.java b/application/src/main/java/org/thingsboard/server/service/cluster/discovery/ZkDiscoveryService.java
index e0bdd12..45dceb7 100644
--- a/application/src/main/java/org/thingsboard/server/service/cluster/discovery/ZkDiscoveryService.java
+++ b/application/src/main/java/org/thingsboard/server/service/cluster/discovery/ZkDiscoveryService.java
@@ -15,6 +15,7 @@
*/
package org.thingsboard.server.service.cluster.discovery;
+import java.util.ArrayList;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.SerializationException;
@@ -22,10 +23,10 @@ import org.apache.commons.lang3.SerializationUtils;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.framework.imps.CuratorFrameworkState;
-import org.apache.curator.framework.recipes.cache.ChildData;
-import org.apache.curator.framework.recipes.cache.PathChildrenCache;
-import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
-import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
+//import org.apache.curator.framework.recipes.cache.ChildData;
+//import org.apache.curator.framework.recipes.cache.PathChildrenCache;
+//import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
+//import org.apache.curator.framework.recipes.cache.PathChildrenCacheListener;
import org.apache.curator.framework.state.ConnectionState;
import org.apache.curator.framework.state.ConnectionStateListener;
import org.apache.curator.retry.RetryForever;
@@ -54,7 +55,7 @@ import java.util.List;
import java.util.NoSuchElementException;
import java.util.stream.Collectors;
-import static org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.Type.CHILD_REMOVED;
+//import static org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.Type.CHILD_REMOVED;
/**
* @author Andrew Shvayka
@@ -62,7 +63,8 @@ import static org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent.
@Service
@ConditionalOnProperty(prefix = "zk", value = "enabled", havingValue = "true", matchIfMissing = false)
@Slf4j
-public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheListener {
+//public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheListener {
+public class ZkDiscoveryService implements DiscoveryService {
@Value("${zk.url}")
private String zkUrl;
@@ -97,7 +99,7 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi
private ClusterRoutingService routingService;
private CuratorFramework client;
- private PathChildrenCache cache;
+// private PathChildrenCache cache;
private String nodePath;
private volatile boolean stopped = false;
@@ -117,12 +119,12 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi
client = CuratorFrameworkFactory.newClient(zkUrl, zkSessionTimeout, zkConnectionTimeout, new RetryForever(zkRetryInterval));
client.start();
client.blockUntilConnected();
- cache = new PathChildrenCache(client, zkNodesDir, true);
- cache.getListenable().addListener(this);
- cache.start();
+// cache = new PathChildrenCache(client, zkNodesDir, true);
+// cache.getListenable().addListener(this);
+// cache.start();
} catch (Exception e) {
log.error("Failed to connect to ZK: {}", e.getMessage(), e);
- CloseableUtils.closeQuietly(cache);
+// CloseableUtils.closeQuietly(cache);
CloseableUtils.closeQuietly(client);
throw new RuntimeException(e);
}
@@ -132,7 +134,7 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi
public void destroy() {
stopped = true;
unpublishCurrentServer();
- CloseableUtils.closeQuietly(cache);
+// CloseableUtils.closeQuietly(cache);
CloseableUtils.closeQuietly(client);
log.info("Stopped discovery service");
}
@@ -220,17 +222,18 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi
@Override
public List<ServerInstance> getOtherServers() {
- return cache.getCurrentData().stream()
- .filter(cd -> !cd.getPath().equals(nodePath))
- .map(cd -> {
- try {
- return new ServerInstance((ServerAddress) SerializationUtils.deserialize(cd.getData()));
- } catch (NoSuchElementException e) {
- log.error("Failed to decode ZK node", e);
- throw new RuntimeException(e);
- }
- })
- .collect(Collectors.toList());
+ return new ArrayList<ServerInstance>();
+// return cache.getCurrentData().stream()
+// .filter(cd -> !cd.getPath().equals(nodePath))
+// .map(cd -> {
+// try {
+// return new ServerInstance((ServerAddress) SerializationUtils.deserialize(cd.getData()));
+// } catch (NoSuchElementException e) {
+// log.error("Failed to decode ZK node", e);
+// throw new RuntimeException(e);
+// }
+// })
+// .collect(Collectors.toList());
}
@EventListener(ApplicationReadyEvent.class)
@@ -250,59 +253,59 @@ public class ZkDiscoveryService implements DiscoveryService, PathChildrenCacheLi
);
}
- @Override
- public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent) throws Exception {
- if (stopped) {
- log.debug("Ignoring {}. Service is stopped.", pathChildrenCacheEvent);
- return;
- }
- if (client.getState() != CuratorFrameworkState.STARTED) {
- log.debug("Ignoring {}, ZK client is not started, ZK client state [{}]", pathChildrenCacheEvent, client.getState());
- return;
- }
- ChildData data = pathChildrenCacheEvent.getData();
- if (data == null) {
- log.debug("Ignoring {} due to empty child data", pathChildrenCacheEvent);
- return;
- } else if (data.getData() == null) {
- log.debug("Ignoring {} due to empty child's data", pathChildrenCacheEvent);
- return;
- } else if (nodePath != null && nodePath.equals(data.getPath())) {
- if (pathChildrenCacheEvent.getType() == CHILD_REMOVED) {
- log.info("ZK node for current instance is somehow deleted.");
- publishCurrentServer();
- }
- log.debug("Ignoring event about current server {}", pathChildrenCacheEvent);
- return;
- }
- ServerInstance instance;
- try {
- ServerAddress serverAddress = SerializationUtils.deserialize(data.getData());
- instance = new ServerInstance(serverAddress);
- } catch (SerializationException e) {
- log.error("Failed to decode server instance for node {}", data.getPath(), e);
- throw e;
- }
- log.info("Processing [{}] event for [{}:{}]", pathChildrenCacheEvent.getType(), instance.getHost(), instance.getPort());
- switch (pathChildrenCacheEvent.getType()) {
- case CHILD_ADDED:
- routingService.onServerAdded(instance);
- tsSubService.onClusterUpdate();
- deviceStateService.onClusterUpdate();
- actorService.onServerAdded(instance);
- break;
- case CHILD_UPDATED:
- routingService.onServerUpdated(instance);
- actorService.onServerUpdated(instance);
- break;
- case CHILD_REMOVED:
- routingService.onServerRemoved(instance);
- tsSubService.onClusterUpdate();
- deviceStateService.onClusterUpdate();
- actorService.onServerRemoved(instance);
- break;
- default:
- break;
- }
- }
+// @Override
+// public void childEvent(CuratorFramework curatorFramework, PathChildrenCacheEvent pathChildrenCacheEvent) throws Exception {
+// if (stopped) {
+// log.debug("Ignoring {}. Service is stopped.", pathChildrenCacheEvent);
+// return;
+// }
+// if (client.getState() != CuratorFrameworkState.STARTED) {
+// log.debug("Ignoring {}, ZK client is not started, ZK client state [{}]", pathChildrenCacheEvent, client.getState());
+// return;
+// }
+// ChildData data = pathChildrenCacheEvent.getData();
+// if (data == null) {
+// log.debug("Ignoring {} due to empty child data", pathChildrenCacheEvent);
+// return;
+// } else if (data.getData() == null) {
+// log.debug("Ignoring {} due to empty child's data", pathChildrenCacheEvent);
+// return;
+// } else if (nodePath != null && nodePath.equals(data.getPath())) {
+// if (pathChildrenCacheEvent.getType() == CHILD_REMOVED) {
+// log.info("ZK node for current instance is somehow deleted.");
+// publishCurrentServer();
+// }
+// log.debug("Ignoring event about current server {}", pathChildrenCacheEvent);
+// return;
+// }
+// ServerInstance instance;
+// try {
+// ServerAddress serverAddress = SerializationUtils.deserialize(data.getData());
+// instance = new ServerInstance(serverAddress);
+// } catch (SerializationException e) {
+// log.error("Failed to decode server instance for node {}", data.getPath(), e);
+// throw e;
+// }
+// log.info("Processing [{}] event for [{}:{}]", pathChildrenCacheEvent.getType(), instance.getHost(), instance.getPort());
+// switch (pathChildrenCacheEvent.getType()) {
+// case CHILD_ADDED:
+// routingService.onServerAdded(instance);
+// tsSubService.onClusterUpdate();
+// deviceStateService.onClusterUpdate();
+// actorService.onServerAdded(instance);
+// break;
+// case CHILD_UPDATED:
+// routingService.onServerUpdated(instance);
+// actorService.onServerUpdated(instance);
+// break;
+// case CHILD_REMOVED:
+// routingService.onServerRemoved(instance);
+// tsSubService.onClusterUpdate();
+// deviceStateService.onClusterUpdate();
+// actorService.onServerRemoved(instance);
+// break;
+// default:
+// break;
+// }
+// }
}
diff --git a/application/src/main/java/org/thingsboard/server/service/session/DefaultDeviceSessionCacheService.java b/application/src/main/java/org/thingsboard/server/service/session/DefaultDeviceSessionCacheService.java
index c78d7df..b5c5a19 100644
--- a/application/src/main/java/org/thingsboard/server/service/session/DefaultDeviceSessionCacheService.java
+++ b/application/src/main/java/org/thingsboard/server/service/session/DefaultDeviceSessionCacheService.java
@@ -16,37 +16,37 @@
package org.thingsboard.server.service.session;
import lombok.extern.slf4j.Slf4j;
-import org.springframework.cache.annotation.CachePut;
-import org.springframework.cache.annotation.Cacheable;
+//import org.springframework.cache.annotation.CachePut;
+//import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.thingsboard.server.common.data.id.DeviceId;
-import org.thingsboard.server.gen.transport.TransportProtos.DeviceSessionsCacheEntry;
+//import org.thingsboard.server.gen.transport.TransportProtos.DeviceSessionsCacheEntry;
import java.util.Collections;
import java.util.UUID;
-import static org.thingsboard.server.common.data.CacheConstants.SESSIONS_CACHE;
+//import static org.thingsboard.server.common.data.CacheConstants.SESSIONS_CACHE;
/**
* Created by ashvayka on 29.10.18.
*/
@Service
@Slf4j
-public class DefaultDeviceSessionCacheService implements DeviceSessionCacheService {
-
- @Override
- @Cacheable(cacheNames = SESSIONS_CACHE, key = "#deviceId.toString()")
- public byte[] get(DeviceId deviceId) {
- log.debug("[{}] Fetching session data from cache", deviceId);
- return DeviceSessionsCacheEntry.newBuilder().addAllSessions(Collections.emptyList()).build().toByteArray();
- }
-
- @Override
- @CachePut(cacheNames = SESSIONS_CACHE, key = "#deviceId.toString()")
- public byte[] put(DeviceId deviceId, byte[] sessions) {
- log.debug("[{}] Pushing session data to cache: {}", deviceId, sessions);
- return sessions;
- }
+public class DefaultDeviceSessionCacheService {
+
+// @Override
+// @Cacheable(cacheNames = SESSIONS_CACHE, key = "#deviceId.toString()")
+// public byte[] get(DeviceId deviceId) {
+// log.debug("[{}] Fetching session data from cache", deviceId);
+// return DeviceSessionsCacheEntry.newBuilder().addAllSessions(Collections.emptyList()).build().toByteArray();
+// }
+
+// @Override
+// @CachePut(cacheNames = SESSIONS_CACHE, key = "#deviceId.toString()")
+// public byte[] put(DeviceId deviceId, byte[] sessions) {
+// log.debug("[{}] Pushing session data to cache: {}", deviceId, sessions);
+// return sessions;
+// }
public static void main (String[] args){
UUID uuid = UUID.fromString("d5db434e-9cd2-4903-8b3b-421b2d93664d");
diff --git a/application/src/main/java/org/thingsboard/server/service/session/DeviceSessionCacheService.java b/application/src/main/java/org/thingsboard/server/service/session/DeviceSessionCacheService.java
index a9a1702..0686036 100644
--- a/application/src/main/java/org/thingsboard/server/service/session/DeviceSessionCacheService.java
+++ b/application/src/main/java/org/thingsboard/server/service/session/DeviceSessionCacheService.java
@@ -15,16 +15,16 @@
*/
package org.thingsboard.server.service.session;
-import org.thingsboard.server.common.data.id.DeviceId;
-import org.thingsboard.server.gen.transport.TransportProtos.DeviceSessionsCacheEntry;
+//import org.thingsboard.server.common.data.id.DeviceId;
+//import org.thingsboard.server.gen.transport.TransportProtos.DeviceSessionsCacheEntry;
/**
* Created by ashvayka on 29.10.18.
*/
public interface DeviceSessionCacheService {
- byte[] get(DeviceId deviceId);
-
- byte[] put(DeviceId deviceId, byte[] sessions);
+// byte[] get(DeviceId deviceId);
+//
+// byte[] put(DeviceId deviceId, byte[] sessions);
}
diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml
index 0f87429..ca39f89 100644
--- a/application/src/main/resources/thingsboard.yml
+++ b/application/src/main/resources/thingsboard.yml
@@ -225,9 +225,9 @@ actors:
client_side_rpc:
timeout: "${CLIENT_SIDE_RPC_TIMEOUT:60000}"
-cache:
+#cache:
# caffeine or redis
- type: "${CACHE_TYPE:caffeine}"
+# type: "${CACHE_TYPE:caffeine}"
caffeine:
specs:
common/queue/ignored 10(+10 -0)
diff --git a/common/queue/ignored b/common/queue/ignored
new file mode 100644
index 0000000..b7b50cf
--- /dev/null
+++ b/common/queue/ignored
@@ -0,0 +1,10 @@
+org.projectlombok.
+ch.qos.logback.
+com.google.code.gson.
+com.google.guava.
+junit.
+org.apache.commons.
+org.apache.kafka.
+org.mockito.
+org.slf4j.
+org.springframework.
\ No newline at end of file
common/queue/pom.xml 56(+56 -0)
diff --git a/common/queue/pom.xml b/common/queue/pom.xml
index 1ab1956..63e0854 100644
--- a/common/queue/pom.xml
+++ b/common/queue/pom.xml
@@ -94,6 +94,62 @@
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
+ <artifactId>ApplicationTracer</artifactId>
+ <version>1.0</version>
+ </dependency>
</dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>aspectj-maven-plugin</artifactId>
+ <version>1.11</version>
+ <configuration>
+ <showWeaveInfo>false</showWeaveInfo>
+ <complianceLevel>1.8</complianceLevel>
+ <source>1.8</source>
+ <target>1.8</target>
+ <Xlint>ignore</Xlint>
+ <encoding>UTF-8</encoding>
+ <verbose>false</verbose>
+ <forceAjcCompile>true</forceAjcCompile>
+ <sources/>
+ <weaveDirectories>
+ <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
+ </weaveDirectories>
+ <aspectLibraries>
+ <aspectLibrary>
+ <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
+ <artifactId>ApplicationTracer</artifactId>
+ </aspectLibrary>
+ </aspectLibraries>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>compile</goal>
+ <goal>test-compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjtools</artifactId>
+ <version>1.9.1</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+
</project>
diff --git a/common/queue/src/main/java/org/thingsboard/server/kafka/TBKafkaProducerTemplate.java b/common/queue/src/main/java/org/thingsboard/server/kafka/TBKafkaProducerTemplate.java
index 6cf507f..ac4ce8f 100644
--- a/common/queue/src/main/java/org/thingsboard/server/kafka/TBKafkaProducerTemplate.java
+++ b/common/queue/src/main/java/org/thingsboard/server/kafka/TBKafkaProducerTemplate.java
@@ -53,7 +53,7 @@ public class TBKafkaProducerTemplate<T> {
private TbKafkaEnricher<T> enricher = ((value, responseTopic, requestId) -> value);
private final TbKafkaPartitioner<T> partitioner;
- private ConcurrentMap<String, List<PartitionInfo>> partitionInfoMap;
+// private ConcurrentMap<String, List<PartitionInfo>> partitionInfoMap;
@Getter
private final String defaultTopic;
@@ -62,7 +62,7 @@ public class TBKafkaProducerTemplate<T> {
@Builder
private TBKafkaProducerTemplate(TbKafkaSettings settings, TbKafkaEncoder<T> encoder, TbKafkaEnricher<T> enricher,
- TbKafkaPartitioner<T> partitioner, String defaultTopic) {
+ TbKafkaPartitioner<T> partitioner, String defaultTopic) {
Properties props = settings.toProps();
props.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.StringSerializer");
props.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, "org.apache.kafka.common.serialization.ByteArraySerializer");
@@ -75,7 +75,7 @@ public class TBKafkaProducerTemplate<T> {
}
public void init() {
- this.partitionInfoMap = new ConcurrentHashMap<>();
+// this.partitionInfoMap = new ConcurrentHashMap<>();
if (!StringUtils.isEmpty(defaultTopic)) {
try {
TBKafkaAdmin admin = new TBKafkaAdmin(this.settings);
@@ -86,7 +86,7 @@ public class TBKafkaProducerTemplate<T> {
throw new RuntimeException(e);
}
//Maybe this should not be cached, but we don't plan to change size of partitions
- this.partitionInfoMap.putIfAbsent(defaultTopic, producer.partitionsFor(defaultTopic));
+// this.partitionInfoMap.putIfAbsent(defaultTopic, producer.partitionsFor(defaultTopic));
}
}
@@ -134,7 +134,8 @@ public class TBKafkaProducerTemplate<T> {
if (partitioner == null) {
return null;
} else {
- return partitioner.partition(topic, key, value, data, partitionInfoMap.computeIfAbsent(topic, producer::partitionsFor));
+ return partitioner.partition(topic, key, value, data, producer.partitionsFor(topic));
+// return partitioner.partition(topic, key, value, data, partitionInfoMap.computeIfAbsent(topic, producer::partitionsFor));
}
}
}
diff --git a/common/transport/transport-api/src/main/proto/transport.proto b/common/transport/transport-api/src/main/proto/transport.proto
index ff740d4..5c370f9 100644
--- a/common/transport/transport-api/src/main/proto/transport.proto
+++ b/common/transport/transport-api/src/main/proto/transport.proto
@@ -184,9 +184,9 @@ message SessionSubscriptionInfoProto {
SubscriptionInfoProto subscriptionInfo = 2;
}
-message DeviceSessionsCacheEntry {
- repeated SessionSubscriptionInfoProto sessions = 1;
-}
+//message DeviceSessionsCacheEntry {
+ //repeated SessionSubscriptionInfoProto sessions = 1;
+//}
message TransportToDeviceActorMsg {
SessionInfoProto sessionInfo = 1;
dao/ignored 24(+24 -0)
diff --git a/dao/ignored b/dao/ignored
new file mode 100644
index 0000000..e888f8a
--- /dev/null
+++ b/dao/ignored
@@ -0,0 +1,24 @@
+org.projectlombok.
+ch.qos.logback.
+com.datastax.cassandra.
+com.fasterxml.jackson.core.
+com.github.ben-manes.caffeine.
+com.github.fge.
+com.github.springtestdbunit.
+com.google.guava.
+com.google.protobuf.
+commons-validator.
+io.takari.junit.
+junit.
+org.apache.commons.
+org.apache.curator.
+org.bouncycastle.
+org.cassandraunit.
+org.dbunit.
+org.elasticsearch.client.
+org.hsqldb.
+org.mockito.
+org.postgresql.
+org.slf4j.
+org.springframework.
+redis.clients.
\ No newline at end of file
dao/pom.xml 54(+54 -0)
diff --git a/dao/pom.xml b/dao/pom.xml
index 63332eb..6e016fe 100644
--- a/dao/pom.xml
+++ b/dao/pom.xml
@@ -194,6 +194,11 @@
<groupId>org.elasticsearch.client</groupId>
<artifactId>rest</artifactId>
</dependency>
+ <dependency>
+ <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
+ <artifactId>ApplicationTracer</artifactId>
+ <version>1.0</version>
+ </dependency>
</dependencies>
<build>
<plugins>
@@ -219,6 +224,55 @@
</execution>
</executions>
</plugin>
+
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>aspectj-maven-plugin</artifactId>
+ <version>1.11</version>
+ <configuration>
+ <showWeaveInfo>false</showWeaveInfo>
+ <complianceLevel>1.8</complianceLevel>
+ <source>1.6</source>
+ <target>1.6</target>
+ <Xlint>ignore</Xlint>
+ <encoding>UTF-8</encoding>
+ <verbose>false</verbose>
+ <forceAjcCompile>true</forceAjcCompile>
+ <sources/>
+ <weaveDirectories>
+ <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
+ </weaveDirectories>
+ <aspectLibraries>
+ <aspectLibrary>
+ <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
+ <artifactId>ApplicationTracer</artifactId>
+ </aspectLibrary>
+ </aspectLibraries>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjtools</artifactId>
+ <version>1.9.1</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+
</plugins>
</build>
</project>
diff --git a/dao/src/main/java/org/thingsboard/server/dao/asset/BaseAssetService.java b/dao/src/main/java/org/thingsboard/server/dao/asset/BaseAssetService.java
index 0fca8c5..629aeb4 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/asset/BaseAssetService.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/asset/BaseAssetService.java
@@ -21,10 +21,10 @@ import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.Cache;
-import org.springframework.cache.CacheManager;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.Cacheable;
+//import org.springframework.cache.Cache;
+//import org.springframework.cache.CacheManager;
+//import org.springframework.cache.annotation.CacheEvict;
+//import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.thingsboard.server.common.data.Customer;
@@ -57,7 +57,7 @@ import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
-import static org.thingsboard.server.common.data.CacheConstants.ASSET_CACHE;
+//import static org.thingsboard.server.common.data.CacheConstants.ASSET_CACHE;
import static org.thingsboard.server.dao.DaoUtil.toUUIDs;
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
import static org.thingsboard.server.dao.service.Validator.*;
@@ -82,8 +82,8 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ
@Autowired
private EntityViewService entityViewService;
- @Autowired
- private CacheManager cacheManager;
+// @Autowired
+// private CacheManager cacheManager;
@Override
public Asset findAssetById(TenantId tenantId, AssetId assetId) {
@@ -99,7 +99,7 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ
return assetDao.findByIdAsync(tenantId, assetId.getId());
}
- @Cacheable(cacheNames = ASSET_CACHE, key = "{#tenantId, #name}")
+// @Cacheable(cacheNames = ASSET_CACHE, key = "{#tenantId, #name}")
@Override
public Asset findAssetByTenantIdAndName(TenantId tenantId, String name) {
log.trace("Executing findAssetByTenantIdAndName [{}][{}]", tenantId, name);
@@ -108,7 +108,7 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ
.orElse(null);
}
- @CacheEvict(cacheNames = ASSET_CACHE, key = "{#asset.tenantId, #asset.name}")
+// @CacheEvict(cacheNames = ASSET_CACHE, key = "{#asset.tenantId, #asset.name}")
@Override
public Asset saveAsset(Asset asset) {
log.trace("Executing saveAsset [{}]", asset);
@@ -150,8 +150,8 @@ public class BaseAssetService extends AbstractEntityService implements AssetServ
List<Object> list = new ArrayList<>();
list.add(asset.getTenantId());
list.add(asset.getName());
- Cache cache = cacheManager.getCache(ASSET_CACHE);
- cache.evict(list);
+// Cache cache = cacheManager.getCache(ASSET_CACHE);
+// cache.evict(list);
assetDao.removeById(tenantId, assetId.getId());
}
diff --git a/dao/src/main/java/org/thingsboard/server/dao/cache/CacheSpecs.java b/dao/src/main/java/org/thingsboard/server/dao/cache/CacheSpecs.java
index 22e826a..636b3c2 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/cache/CacheSpecs.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/cache/CacheSpecs.java
@@ -19,6 +19,6 @@ import lombok.Data;
@Data
public class CacheSpecs {
- private Integer timeToLiveInMinutes;
- private Integer maxSize;
+// private Integer timeToLiveInMinutes;
+// private Integer maxSize;
}
diff --git a/dao/src/main/java/org/thingsboard/server/dao/cache/CaffeineCacheConfiguration.java b/dao/src/main/java/org/thingsboard/server/dao/cache/CaffeineCacheConfiguration.java
index fc2868e..7ee10a0 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/cache/CaffeineCacheConfiguration.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/cache/CaffeineCacheConfiguration.java
@@ -15,19 +15,19 @@
*/
package org.thingsboard.server.dao.cache;
-import com.github.benmanes.caffeine.cache.Caffeine;
-import com.github.benmanes.caffeine.cache.RemovalCause;
-import com.github.benmanes.caffeine.cache.Ticker;
-import com.github.benmanes.caffeine.cache.Weigher;
+//import com.github.benmanes.caffeine.cache.Caffeine;
+//import com.github.benmanes.caffeine.cache.RemovalCause;
+//import com.github.benmanes.caffeine.cache.Ticker;
+//import com.github.benmanes.caffeine.cache.Weigher;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.cache.CacheManager;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.cache.caffeine.CaffeineCache;
-import org.springframework.cache.interceptor.KeyGenerator;
-import org.springframework.cache.support.SimpleCacheManager;
+//import org.springframework.cache.CacheManager;
+//import org.springframework.cache.annotation.EnableCaching;
+//import org.springframework.cache.caffeine.CaffeineCache;
+//import org.springframework.cache.interceptor.KeyGenerator;
+//import org.springframework.cache.support.SimpleCacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@@ -39,56 +39,56 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Configuration
-@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "caffeine", matchIfMissing = true)
-@ConfigurationProperties(prefix = "caffeine")
-@EnableCaching
+//@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "caffeine", matchIfMissing = true)
+//@ConfigurationProperties(prefix = "caffeine")
+//@EnableCaching
@Data
@Slf4j
public class CaffeineCacheConfiguration {
- private Map<String, CacheSpecs> specs;
+// private Map<String, CacheSpecs> specs;
- @Bean
- public CacheManager cacheManager() {
- log.trace("Initializing cache: {}", Arrays.toString(RemovalCause.values()));
- SimpleCacheManager manager = new SimpleCacheManager();
- if (specs != null) {
- List<CaffeineCache> caches =
- specs.entrySet().stream()
- .map(entry -> buildCache(entry.getKey(),
- entry.getValue()))
- .collect(Collectors.toList());
- manager.setCaches(caches);
- }
- return manager;
- }
+// @Bean
+// public CacheManager cacheManager() {
+// log.trace("Initializing cache: {}", Arrays.toString(RemovalCause.values()));
+// SimpleCacheManager manager = new SimpleCacheManager();
+// if (specs != null) {
+// List<CaffeineCache> caches =
+// specs.entrySet().stream()
+// .map(entry -> buildCache(entry.getKey(),
+// entry.getValue()))
+// .collect(Collectors.toList());
+// manager.setCaches(caches);
+// }
+// return manager;
+// }
- private CaffeineCache buildCache(String name, CacheSpecs cacheSpec) {
- final Caffeine<Object, Object> caffeineBuilder
- = Caffeine.newBuilder()
- .weigher(collectionSafeWeigher())
- .maximumWeight(cacheSpec.getMaxSize())
- .expireAfterWrite(cacheSpec.getTimeToLiveInMinutes(), TimeUnit.MINUTES)
- .ticker(ticker());
- return new CaffeineCache(name, caffeineBuilder.build());
- }
+// private CaffeineCache buildCache(String name, CacheSpecs cacheSpec) {
+// final Caffeine<Object, Object> caffeineBuilder
+// = Caffeine.newBuilder()
+// .weigher(collectionSafeWeigher())
+// .maximumWeight(cacheSpec.getMaxSize())
+// .expireAfterWrite(cacheSpec.getTimeToLiveInMinutes(), TimeUnit.MINUTES)
+// .ticker(ticker());
+// return new CaffeineCache(name, caffeineBuilder.build());
+// }
- @Bean
- public Ticker ticker() {
- return Ticker.systemTicker();
- }
+// @Bean
+// public Ticker ticker() {
+// return Ticker.systemTicker();
+// }
- @Bean
- public KeyGenerator previousDeviceCredentialsId() {
- return new PreviousDeviceCredentialsIdKeyGenerator();
- }
+// @Bean
+// public KeyGenerator previousDeviceCredentialsId() {
+// return new PreviousDeviceCredentialsIdKeyGenerator();
+// }
- private Weigher<? super Object, ? super Object> collectionSafeWeigher() {
- return (Weigher<Object, Object>) (key, value) -> {
- if(value instanceof Collection) {
- return ((Collection) value).size();
- }
- return 1;
- };
- }
+// private Weigher<? super Object, ? super Object> collectionSafeWeigher() {
+// return (Weigher<Object, Object>) (key, value) -> {
+// if(value instanceof Collection) {
+// return ((Collection) value).size();
+// }
+// return 1;
+// };
+// }
}
diff --git a/dao/src/main/java/org/thingsboard/server/dao/cache/TBRedisCacheConfiguration.java b/dao/src/main/java/org/thingsboard/server/dao/cache/TBRedisCacheConfiguration.java
index 3be33f3..c34c1e3 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/cache/TBRedisCacheConfiguration.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/cache/TBRedisCacheConfiguration.java
@@ -18,19 +18,19 @@ package org.thingsboard.server.dao.cache;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.cache.CacheManager;
-import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.cache.interceptor.KeyGenerator;
+//import org.springframework.cache.CacheManager;
+//import org.springframework.cache.annotation.EnableCaching;
+//import org.springframework.cache.interceptor.KeyGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
-import org.springframework.data.redis.cache.RedisCacheManager;
+//import org.springframework.data.redis.cache.RedisCacheManager;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
@Configuration
-@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis", matchIfMissing = false)
-@EnableCaching
+//@ConditionalOnProperty(prefix = "cache", value = "type", havingValue = "redis", matchIfMissing = false)
+//@EnableCaching
@Data
public class TBRedisCacheConfiguration {
@@ -63,15 +63,15 @@ public class TBRedisCacheConfiguration {
return redisTemplate;
}
- @Bean
- public CacheManager cacheManager(RedisTemplate redisTemplate) {
- return new RedisCacheManager(redisTemplate);
- }
+// @Bean
+// public CacheManager cacheManager(RedisTemplate redisTemplate) {
+// return new RedisCacheManager(redisTemplate);
+// }
- @Bean
- public KeyGenerator previousDeviceCredentialsId() {
- return new PreviousDeviceCredentialsIdKeyGenerator();
- }
+// @Bean
+// public KeyGenerator previousDeviceCredentialsId() {
+// return new PreviousDeviceCredentialsIdKeyGenerator();
+// }
}
diff --git a/dao/src/main/java/org/thingsboard/server/dao/device/DeviceCredentialsServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/device/DeviceCredentialsServiceImpl.java
index b457bcb..ff505e2 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/device/DeviceCredentialsServiceImpl.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/device/DeviceCredentialsServiceImpl.java
@@ -18,8 +18,8 @@ package org.thingsboard.server.dao.device;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.Cacheable;
+//import org.springframework.cache.annotation.CacheEvict;
+//import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.thingsboard.server.common.data.Device;
@@ -32,7 +32,7 @@ import org.thingsboard.server.common.msg.EncryptionUtil;
import org.thingsboard.server.dao.exception.DataValidationException;
import org.thingsboard.server.dao.service.DataValidator;
-import static org.thingsboard.server.common.data.CacheConstants.DEVICE_CREDENTIALS_CACHE;
+//import static org.thingsboard.server.common.data.CacheConstants.DEVICE_CREDENTIALS_CACHE;
import static org.thingsboard.server.dao.service.Validator.validateId;
import static org.thingsboard.server.dao.service.Validator.validateString;
@@ -54,7 +54,7 @@ public class DeviceCredentialsServiceImpl implements DeviceCredentialsService {
}
@Override
- @Cacheable(cacheNames = DEVICE_CREDENTIALS_CACHE, unless = "#result == null")
+// @Cacheable(cacheNames = DEVICE_CREDENTIALS_CACHE, unless = "#result == null")
public DeviceCredentials findDeviceCredentialsByCredentialsId(String credentialsId) {
log.trace("Executing findDeviceCredentialsByCredentialsId [{}]", credentialsId);
validateString(credentialsId, "Incorrect credentialsId " + credentialsId);
@@ -62,7 +62,7 @@ public class DeviceCredentialsServiceImpl implements DeviceCredentialsService {
}
@Override
- @CacheEvict(cacheNames = DEVICE_CREDENTIALS_CACHE, keyGenerator = "previousDeviceCredentialsId", beforeInvocation = true)
+// @CacheEvict(cacheNames = DEVICE_CREDENTIALS_CACHE, keyGenerator = "previousDeviceCredentialsId", beforeInvocation = true)
public DeviceCredentials updateDeviceCredentials(TenantId tenantId, DeviceCredentials deviceCredentials) {
return saveOrUpdate(tenantId, deviceCredentials);
}
@@ -89,7 +89,7 @@ public class DeviceCredentialsServiceImpl implements DeviceCredentialsService {
}
@Override
- @CacheEvict(cacheNames = DEVICE_CREDENTIALS_CACHE, key = "#deviceCredentials.credentialsId")
+// @CacheEvict(cacheNames = DEVICE_CREDENTIALS_CACHE, key = "#deviceCredentials.credentialsId")
public void deleteDeviceCredentials(TenantId tenantId, DeviceCredentials deviceCredentials) {
log.trace("Executing deleteDeviceCredentials [{}]", deviceCredentials);
deviceCredentialsDao.removeById(tenantId, deviceCredentials.getUuidId());
diff --git a/dao/src/main/java/org/thingsboard/server/dao/device/DeviceServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/device/DeviceServiceImpl.java
index 902b4cd..250e719 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/device/DeviceServiceImpl.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/device/DeviceServiceImpl.java
@@ -21,10 +21,10 @@ import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.RandomStringUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.Cache;
-import org.springframework.cache.CacheManager;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.Cacheable;
+//import org.springframework.cache.Cache;
+//import org.springframework.cache.CacheManager;
+//import org.springframework.cache.annotation.CacheEvict;
+//import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.thingsboard.server.common.data.Customer;
@@ -61,7 +61,7 @@ import java.util.Optional;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
-import static org.thingsboard.server.common.data.CacheConstants.DEVICE_CACHE;
+//import static org.thingsboard.server.common.data.CacheConstants.DEVICE_CACHE;
import static org.thingsboard.server.dao.DaoUtil.toUUIDs;
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
import static org.thingsboard.server.dao.service.Validator.validateId;
@@ -92,8 +92,8 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe
@Autowired
private EntityViewService entityViewService;
- @Autowired
- private CacheManager cacheManager;
+// @Autowired
+// private CacheManager cacheManager;
@Override
public Device findDeviceById(TenantId tenantId, DeviceId deviceId) {
@@ -109,7 +109,7 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe
return deviceDao.findByIdAsync(tenantId, deviceId.getId());
}
- @Cacheable(cacheNames = DEVICE_CACHE, key = "{#tenantId, #name}")
+// @Cacheable(cacheNames = DEVICE_CACHE, key = "{#tenantId, #name}")
@Override
public Device findDeviceByTenantIdAndName(TenantId tenantId, String name) {
log.trace("Executing findDeviceByTenantIdAndName [{}][{}]", tenantId, name);
@@ -118,7 +118,7 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe
return deviceOpt.orElse(null);
}
- @CacheEvict(cacheNames = DEVICE_CACHE, key = "{#device.tenantId, #device.name}")
+// @CacheEvict(cacheNames = DEVICE_CACHE, key = "{#device.tenantId, #device.name}")
@Override
public Device saveDevice(Device device) {
log.trace("Executing saveDevice [{}]", device);
@@ -173,8 +173,8 @@ public class DeviceServiceImpl extends AbstractEntityService implements DeviceSe
List<Object> list = new ArrayList<>();
list.add(device.getTenantId());
list.add(device.getName());
- Cache cache = cacheManager.getCache(DEVICE_CACHE);
- cache.evict(list);
+// Cache cache = cacheManager.getCache(DEVICE_CACHE);
+// cache.evict(list);
deviceDao.removeById(tenantId, deviceId.getId());
}
diff --git a/dao/src/main/java/org/thingsboard/server/dao/entityview/EntityViewServiceImpl.java b/dao/src/main/java/org/thingsboard/server/dao/entityview/EntityViewServiceImpl.java
index 189a9a3..549fa76 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/entityview/EntityViewServiceImpl.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/entityview/EntityViewServiceImpl.java
@@ -22,11 +22,11 @@ import com.google.common.util.concurrent.ListenableFuture;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.cache.Cache;
-import org.springframework.cache.CacheManager;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.cache.annotation.Caching;
+//import org.springframework.cache.Cache;
+//import org.springframework.cache.CacheManager;
+//import org.springframework.cache.annotation.CacheEvict;
+//import org.springframework.cache.annotation.Cacheable;
+//import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;
import org.thingsboard.server.common.data.Customer;
import org.thingsboard.server.common.data.EntitySubtype;
@@ -58,7 +58,7 @@ import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
-import static org.thingsboard.server.common.data.CacheConstants.ENTITY_VIEW_CACHE;
+//import static org.thingsboard.server.common.data.CacheConstants.ENTITY_VIEW_CACHE;
import static org.thingsboard.server.dao.model.ModelConstants.NULL_UUID;
import static org.thingsboard.server.dao.service.Validator.validateId;
import static org.thingsboard.server.dao.service.Validator.validatePageLink;
@@ -85,13 +85,13 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti
@Autowired
private CustomerDao customerDao;
- @Autowired
- private CacheManager cacheManager;
+// @Autowired
+// private CacheManager cacheManager;
- @Caching(evict = {
- @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityView.tenantId, #entityView.entityId}"),
- @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityView.tenantId, #entityView.name}"),
- @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityView.id}")})
+// @Caching(evict = {
+// @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityView.tenantId, #entityView.entityId}"),
+// @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityView.tenantId, #entityView.name}"),
+// @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityView.id}")})
@Override
public EntityView saveEntityView(EntityView entityView) {
log.trace("Executing save entity view [{}]", entityView);
@@ -100,7 +100,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti
return savedEntityView;
}
- @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityViewId}")
+// @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityViewId}")
@Override
public EntityView assignEntityViewToCustomer(TenantId tenantId, EntityViewId entityViewId, CustomerId customerId) {
EntityView entityView = findEntityViewById(tenantId, entityViewId);
@@ -108,7 +108,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti
return saveEntityView(entityView);
}
- @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityViewId}")
+// @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityViewId}")
@Override
public EntityView unassignEntityViewFromCustomer(TenantId tenantId, EntityViewId entityViewId) {
EntityView entityView = findEntityViewById(tenantId, entityViewId);
@@ -124,7 +124,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti
customerEntityViewsUnAssigner.removeEntities(tenantId, customerId);
}
- @Cacheable(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityViewId}")
+// @Cacheable(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityViewId}")
@Override
public EntityView findEntityViewById(TenantId tenantId, EntityViewId entityViewId) {
log.trace("Executing findEntityViewById [{}]", entityViewId);
@@ -132,7 +132,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti
return entityViewDao.findById(tenantId, entityViewId.getId());
}
- @Cacheable(cacheNames = ENTITY_VIEW_CACHE, key = "{#tenantId, #name}")
+// @Cacheable(cacheNames = ENTITY_VIEW_CACHE, key = "{#tenantId, #name}")
@Override
public EntityView findEntityViewByTenantIdAndName(TenantId tenantId, String name) {
log.trace("Executing findEntityViewByTenantIdAndName [{}][{}]", tenantId, name);
@@ -229,8 +229,9 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti
tenantIdAndEntityId.add(tenantId);
tenantIdAndEntityId.add(entityId);
- Cache cache = cacheManager.getCache(ENTITY_VIEW_CACHE);
- List<EntityView> fromCache = cache.get(tenantIdAndEntityId, List.class);
+// Cache cache = cacheManager.getCache(ENTITY_VIEW_CACHE);
+// List<EntityView> fromCache = cache.get(tenantIdAndEntityId, List.class);
+ List<EntityView> fromCache = null;
if (fromCache != null) {
return Futures.immediateFuture(fromCache);
} else {
@@ -239,7 +240,7 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti
new FutureCallback<List<EntityView>>() {
@Override
public void onSuccess(@Nullable List<EntityView> result) {
- cache.putIfAbsent(tenantIdAndEntityId, result);
+// cache.putIfAbsent(tenantIdAndEntityId, result);
}
@Override
@@ -251,15 +252,15 @@ public class EntityViewServiceImpl extends AbstractEntityService implements Enti
}
}
- @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityViewId}")
+// @CacheEvict(cacheNames = ENTITY_VIEW_CACHE, key = "{#entityViewId}")
@Override
public void deleteEntityView(TenantId tenantId, EntityViewId entityViewId) {
log.trace("Executing deleteEntityView [{}]", entityViewId);
validateId(entityViewId, INCORRECT_ENTITY_VIEW_ID + entityViewId);
deleteEntityRelations(tenantId, entityViewId);
EntityView entityView = entityViewDao.findById(tenantId, entityViewId.getId());
- cacheManager.getCache(ENTITY_VIEW_CACHE).evict(Arrays.asList(entityView.getTenantId(), entityView.getEntityId()));
- cacheManager.getCache(ENTITY_VIEW_CACHE).evict(Arrays.asList(entityView.getTenantId(), entityView.getName()));
+// cacheManager.getCache(ENTITY_VIEW_CACHE).evict(Arrays.asList(entityView.getTenantId(), entityView.getEntityId()));
+// cacheManager.getCache(ENTITY_VIEW_CACHE).evict(Arrays.asList(entityView.getTenantId(), entityView.getName()));
entityViewDao.removeById(tenantId, entityViewId.getId());
}
diff --git a/dao/src/main/java/org/thingsboard/server/dao/nosql/CassandraBufferedRateExecutor.java b/dao/src/main/java/org/thingsboard/server/dao/nosql/CassandraBufferedRateExecutor.java
index f58f035..9e100c6 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/nosql/CassandraBufferedRateExecutor.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/nosql/CassandraBufferedRateExecutor.java
@@ -43,7 +43,7 @@ public class CassandraBufferedRateExecutor extends AbstractBufferedRateExecutor<
@Autowired
private EntityService entityService;
- private Map<TenantId, String> tenantNamesCache = new HashMap<>();
+// private Map<TenantId, String> tenantNamesCache = new HashMap<>();
private boolean printTenantNames;
@@ -63,8 +63,8 @@ public class CassandraBufferedRateExecutor extends AbstractBufferedRateExecutor<
@Scheduled(fixedDelayString = "${cassandra.query.rate_limit_print_interval_ms}")
public void printStats() {
- log.info("Permits queueSize [{}] totalAdded [{}] totalLaunched [{}] totalReleased [{}] totalFailed [{}] totalExpired [{}] totalRejected [{}] " +
- "totalRateLimited [{}] totalRateLimitedTenants [{}] currBuffer [{}] ",
+ log.info("Permits queueSize [{}] totalAdded [{}] totalLaunched [{}] totalReleased [{}] totalFailed [{}] totalExpired [{}] totalRejected [{}] "
+ + "totalRateLimited [{}] totalRateLimitedTenants [{}] currBuffer [{}] ",
getQueueSize(),
totalAdded.getAndSet(0), totalLaunched.getAndSet(0), totalReleased.getAndSet(0),
totalFailed.getAndSet(0), totalExpired.getAndSet(0), totalRejected.getAndSet(0),
@@ -72,14 +72,20 @@ public class CassandraBufferedRateExecutor extends AbstractBufferedRateExecutor<
rateLimitedTenants.forEach(((tenantId, counter) -> {
if (printTenantNames) {
- String name = tenantNamesCache.computeIfAbsent(tenantId, tId -> {
- try {
- return entityService.fetchEntityNameAsync(TenantId.SYS_TENANT_ID, tenantId).get();
- } catch (Exception e) {
- log.error("[{}] Failed to get tenant name", tenantId, e);
- return "N/A";
- }
- });
+ String name;
+ try {
+ name = entityService.fetchEntityNameAsync(TenantId.SYS_TENANT_ID, tenantId).get();
+ } catch (Exception e) {
+ name = "N/A";
+ }
+// String name = tenantNamesCache.computeIfAbsent(tenantId, tId -> {
+// try {
+// return entityService.fetchEntityNameAsync(TenantId.SYS_TENANT_ID, tenantId).get();
+// } catch (Exception e) {
+// log.error("[{}] Failed to get tenant name", tenantId, e);
+// return "N/A";
+// }
+// });
log.info("[{}][{}] Rate limited requests: {}", tenantId, name, counter);
} else {
log.info("[{}] Rate limited requests: {}", tenantId, counter);
diff --git a/dao/src/main/java/org/thingsboard/server/dao/relation/BaseRelationService.java b/dao/src/main/java/org/thingsboard/server/dao/relation/BaseRelationService.java
index f3db254..7627f11 100644
--- a/dao/src/main/java/org/thingsboard/server/dao/relation/BaseRelationService.java
+++ b/dao/src/main/java/org/thingsboard/server/dao/relation/BaseRelationService.java
@@ -20,10 +20,10 @@ import com.google.common.util.concurrent.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
-import org.springframework.cache.CacheManager;
-import org.springframework.cache.annotation.CacheEvict;
-import org.springframework.cache.annotation.Cacheable;
-import org.springframework.cache.annotation.Caching;
+//import org.springframework.cache.CacheManager;
+//import org.springframework.cache.annotation.CacheEvict;
+//import org.springframework.cache.annotation.Cacheable;
+//import org.springframework.cache.annotation.Caching;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import org.thingsboard.server.common.data.Tenant;
@@ -49,7 +49,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.function.BiConsumer;
-import static org.thingsboard.server.common.data.CacheConstants.RELATIONS_CACHE;
+//import static org.thingsboard.server.common.data.CacheConstants.RELATIONS_CACHE;
/**
* Created by ashvayka on 28.04.17.
@@ -64,8 +64,8 @@ public class BaseRelationService implements RelationService {
@Autowired
private EntityService entityService;
- @Autowired
- private CacheManager cacheManager;
+// @Autowired
+// private CacheManager cacheManager;
@Override
public ListenableFuture<Boolean> checkRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup) {
@@ -74,7 +74,7 @@ public class BaseRelationService implements RelationService {
return relationDao.checkRelation(tenantId, from, to, relationType, typeGroup);
}
- @Cacheable(cacheNames = RELATIONS_CACHE, key = "{#from, #to, #relationType, #typeGroup}")
+// @Cacheable(cacheNames = RELATIONS_CACHE, key = "{#from, #to, #relationType, #typeGroup}")
@Override
public EntityRelation getRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup) {
try {
@@ -91,27 +91,27 @@ public class BaseRelationService implements RelationService {
return relationDao.getRelation(tenantId, from, to, relationType, typeGroup);
}
- @Caching(evict = {
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.to, #relation.type, #relation.typeGroup}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.type, #relation.typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.typeGroup, 'TO'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.type, #relation.typeGroup, 'TO'}")
- })
+// @Caching(evict = {
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.to, #relation.type, #relation.typeGroup}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.type, #relation.typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.typeGroup, 'TO'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.type, #relation.typeGroup, 'TO'}")
+// })
@Override
public boolean saveRelation(TenantId tenantId, EntityRelation relation) {
log.trace("Executing saveRelation [{}]", relation);
validate(relation);
return relationDao.saveRelation(tenantId, relation);
}
-
- @Caching(evict = {
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.to, #relation.type, #relation.typeGroup}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.type, #relation.typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.typeGroup, 'TO'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.type, #relation.typeGroup, 'TO'}")
- })
+//
+// @Caching(evict = {
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.to, #relation.type, #relation.typeGroup}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.type, #relation.typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.typeGroup, 'TO'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.type, #relation.typeGroup, 'TO'}")
+// })
@Override
public ListenableFuture<Boolean> saveRelationAsync(TenantId tenantId, EntityRelation relation) {
log.trace("Executing saveRelationAsync [{}]", relation);
@@ -119,13 +119,13 @@ public class BaseRelationService implements RelationService {
return relationDao.saveRelationAsync(tenantId, relation);
}
- @Caching(evict = {
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.to, #relation.type, #relation.typeGroup}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.type, #relation.typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.typeGroup, 'TO'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.type, #relation.typeGroup, 'TO'}")
- })
+// @Caching(evict = {
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.to, #relation.type, #relation.typeGroup}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.type, #relation.typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.typeGroup, 'TO'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.type, #relation.typeGroup, 'TO'}")
+// })
@Override
public boolean deleteRelation(TenantId tenantId, EntityRelation relation) {
log.trace("Executing deleteRelation [{}]", relation);
@@ -133,13 +133,13 @@ public class BaseRelationService implements RelationService {
return relationDao.deleteRelation(tenantId, relation);
}
- @Caching(evict = {
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.to, #relation.type, #relation.typeGroup}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.type, #relation.typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.typeGroup, 'TO'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.type, #relation.typeGroup, 'TO'}")
- })
+// @Caching(evict = {
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.to, #relation.type, #relation.typeGroup}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.type, #relation.typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.from, #relation.typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.typeGroup, 'TO'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#relation.to, #relation.type, #relation.typeGroup, 'TO'}")
+// })
@Override
public ListenableFuture<Boolean> deleteRelationAsync(TenantId tenantId, EntityRelation relation) {
log.trace("Executing deleteRelationAsync [{}]", relation);
@@ -147,13 +147,13 @@ public class BaseRelationService implements RelationService {
return relationDao.deleteRelationAsync(tenantId, relation);
}
- @Caching(evict = {
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #to, #relationType, #typeGroup}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #relationType, #typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#to, #typeGroup, 'TO'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#to, #relationType, #typeGroup, 'TO'}")
- })
+// @Caching(evict = {
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #to, #relationType, #typeGroup}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #relationType, #typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#to, #typeGroup, 'TO'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#to, #relationType, #typeGroup, 'TO'}")
+// })
@Override
public boolean deleteRelation(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup) {
log.trace("Executing deleteRelation [{}][{}][{}][{}]", from, to, relationType, typeGroup);
@@ -161,13 +161,13 @@ public class BaseRelationService implements RelationService {
return relationDao.deleteRelation(tenantId, from, to, relationType, typeGroup);
}
- @Caching(evict = {
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #to, #relationType, #typeGroup}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #relationType, #typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #typeGroup, 'FROM'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#to, #typeGroup, 'TO'}"),
- @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#to, #relationType, #typeGroup, 'TO'}")
- })
+// @Caching(evict = {
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #to, #relationType, #typeGroup}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #relationType, #typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#from, #typeGroup, 'FROM'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#to, #typeGroup, 'TO'}"),
+// @CacheEvict(cacheNames = RELATIONS_CACHE, key = "{#to, #relationType, #typeGroup, 'TO'}")
+// })
@Override
public ListenableFuture<Boolean> deleteRelationAsync(TenantId tenantId, EntityId from, EntityId to, String relationType, RelationTypeGroup typeGroup) {
log.trace("Executing deleteRelationAsync [{}][{}][{}][{}]", from, to, relationType, typeGroup);
@@ -186,7 +186,8 @@ public class BaseRelationService implements RelationService {
@Override
public ListenableFuture<Void> deleteEntityRelationsAsync(TenantId tenantId, EntityId entityId) {
- Cache cache = cacheManager.getCache(RELATIONS_CACHE);
+// Cache cache = cacheManager.getCache(RELATIONS_CACHE);
+ Cache cache = null;
log.trace("Executing deleteEntityRelationsAsync [{}]", entityId);
validate(entityId);
List<ListenableFuture<List<EntityRelation>>> inboundRelationsList = new ArrayList<>();
@@ -243,36 +244,36 @@ public class BaseRelationService implements RelationService {
fromToTypeAndTypeGroup.add(relation.getTo());
fromToTypeAndTypeGroup.add(relation.getType());
fromToTypeAndTypeGroup.add(relation.getTypeGroup());
- cache.evict(fromToTypeAndTypeGroup);
+// cache.evict(fromToTypeAndTypeGroup);
List<Object> fromTypeAndTypeGroup = new ArrayList<>();
fromTypeAndTypeGroup.add(relation.getFrom());
fromTypeAndTypeGroup.add(relation.getType());
fromTypeAndTypeGroup.add(relation.getTypeGroup());
fromTypeAndTypeGroup.add(EntitySearchDirection.FROM.name());
- cache.evict(fromTypeAndTypeGroup);
+// cache.evict(fromTypeAndTypeGroup);
List<Object> fromAndTypeGroup = new ArrayList<>();
fromAndTypeGroup.add(relation.getFrom());
fromAndTypeGroup.add(relation.getTypeGroup());
fromAndTypeGroup.add(EntitySearchDirection.FROM.name());
- cache.evict(fromAndTypeGroup);
+// cache.evict(fromAndTypeGroup);
List<Object> toAndTypeGroup = new ArrayList<>();
toAndTypeGroup.add(relation.getTo());
toAndTypeGroup.add(relation.getTypeGroup());
toAndTypeGroup.add(EntitySearchDirection.TO.name());
- cache.evict(toAndTypeGroup);
+// cache.evict(toAndTypeGroup);
List<Object> toTypeAndTypeGroup = new ArrayList<>();
toTypeAndTypeGroup.add(relation.getTo());
toTypeAndTypeGroup.add(relation.getType());
toTypeAndTypeGroup.add(relation.getTypeGroup());
toTypeAndTypeGroup.add(EntitySearchDirection.TO.name());
- cache.evict(toTypeAndTypeGroup);
+// cache.evict(toTypeAndTypeGroup);
}
- @Cacheable(cacheNames = RELATIONS_CACHE, key = "{#from, #typeGroup, 'FROM'}")
+// @Cacheable(cacheNames = RELATIONS_CACHE, key = "{#from, #typeGroup, 'FROM'}")
@Override
public List<EntityRelation> findByFrom(TenantId tenantId, EntityId from, RelationTypeGroup typeGroup) {
validate(from);
@@ -295,8 +296,9 @@ public class BaseRelationService implements RelationService {
fromAndTypeGroup.add(typeGroup);
fromAndTypeGroup.add(EntitySearchDirection.FROM.name());
- Cache cache = cacheManager.getCache(RELATIONS_CACHE);
- List<EntityRelation> fromCache = cache.get(fromAndTypeGroup, List.class);
+// Cache cache = cacheManager.getCache(RELATIONS_CACHE);
+// List<EntityRelation> fromCache = cache.get(fromAndTypeGroup, List.class);
+ List<EntityRelation> fromCache = null;
if (fromCache != null) {
return Futures.immediateFuture(fromCache);
} else {
@@ -305,7 +307,7 @@ public class BaseRelationService implements RelationService {
new FutureCallback<List<EntityRelation>>() {
@Override
public void onSuccess(@Nullable List<EntityRelation> result) {
- cache.putIfAbsent(fromAndTypeGroup, result);
+// cache.putIfAbsent(fromAndTypeGroup, result);
}
@Override
public void onFailure(Throwable t) {}
@@ -332,7 +334,7 @@ public class BaseRelationService implements RelationService {
});
}
- @Cacheable(cacheNames = RELATIONS_CACHE, key = "{#from, #relationType, #typeGroup, 'FROM'}")
+// @Cacheable(cacheNames = RELATIONS_CACHE, key = "{#from, #relationType, #typeGroup, 'FROM'}")
@Override
public List<EntityRelation> findByFromAndType(TenantId tenantId, EntityId from, String relationType, RelationTypeGroup typeGroup) {
try {
@@ -351,7 +353,7 @@ public class BaseRelationService implements RelationService {
return relationDao.findAllByFromAndType(tenantId, from, relationType, typeGroup);
}
- @Cacheable(cacheNames = RELATIONS_CACHE, key = "{#to, #typeGroup, 'TO'}")
+// @Cacheable(cacheNames = RELATIONS_CACHE, key = "{#to, #typeGroup, 'TO'}")
@Override
public List<EntityRelation> findByTo(TenantId tenantId, EntityId to, RelationTypeGroup typeGroup) {
validate(to);
@@ -374,8 +376,9 @@ public class BaseRelationService implements RelationService {
toAndTypeGroup.add(typeGroup);
toAndTypeGroup.add(EntitySearchDirection.TO.name());
- Cache cache = cacheManager.getCache(RELATIONS_CACHE);
- List<EntityRelation> fromCache = cache.get(toAndTypeGroup, List.class);
+// Cache cache = cacheManager.getCache(RELATIONS_CACHE);
+// List<EntityRelation> fromCache = cache.get(toAndTypeGroup, List.class);
+ List<EntityRelation> fromCache = null;
if (fromCache != null) {
return Futures.immediateFuture(fromCache);
} else {
@@ -384,7 +387,7 @@ public class BaseRelationService implements RelationService {
new FutureCallback<List<EntityRelation>>() {
@Override
public void onSuccess(@Nullable List<EntityRelation> result) {
- cache.putIfAbsent(toAndTypeGroup, result);
+// cache.putIfAbsent(toAndTypeGroup, result);
}
@Override
public void onFailure(Throwable t) {}
@@ -422,7 +425,7 @@ public class BaseRelationService implements RelationService {
});
}
- @Cacheable(cacheNames = RELATIONS_CACHE, key = "{#to, #relationType, #typeGroup, 'TO'}")
+// @Cacheable(cacheNames = RELATIONS_CACHE, key = "{#to, #relationType, #typeGroup, 'TO'}")
@Override
public List<EntityRelation> findByToAndType(TenantId tenantId, EntityId to, String relationType, RelationTypeGroup typeGroup) {
try {
diff --git a/dao/src/test/resources/application-test.properties b/dao/src/test/resources/application-test.properties
index a285676..55b717e 100644
--- a/dao/src/test/resources/application-test.properties
+++ b/dao/src/test/resources/application-test.properties
@@ -9,7 +9,7 @@ audit_log.by_tenant_partitioning=MONTHS
audit_log.default_query_period=30
audit_log.sink.type=none
-cache.type=caffeine
+#cache.type=caffeine
#cache.type=redis
caffeine.specs.relations.timeToLiveInMinutes=1440
diff --git a/dao/src/test/resources/cassandra-test.yaml b/dao/src/test/resources/cassandra-test.yaml
index e60f248..6bc8d76 100644
--- a/dao/src/test/resources/cassandra-test.yaml
+++ b/dao/src/test/resources/cassandra-test.yaml
@@ -68,7 +68,7 @@ authorizer: AllowAllAuthorizer
# expensive operation depending on the authorizer, CassandraAuthorizer is
# one example). Defaults to 2000, set to 0 to disable.
# Will be disabled automatically for AllowAllAuthorizer.
-permissions_validity_in_ms: 2000
+permissions_validity_in_ms: 0
# The partitioner is responsible for distributing rows (by key) across
@@ -127,7 +127,7 @@ disk_failure_policy: stop
# NOTE: if you reduce the size, you may not get you hottest keys loaded on startup.
#
# Default value is empty to make it "auto" (min(5% of Heap (in MB), 100MB)). Set to 0 to disable key cache.
-key_cache_size_in_mb:
+key_cache_size_in_mb: 0
# Duration in seconds after which Cassandra should
# safe the keys cache. Caches are saved to saved_caches_directory as
docker/tb-node.env 2(+1 -1)
diff --git a/docker/tb-node.env b/docker/tb-node.env
index 963943d..8138b5a 100644
--- a/docker/tb-node.env
+++ b/docker/tb-node.env
@@ -6,7 +6,7 @@ RPC_HOST=${TB_HOST}
TB_KAFKA_SERVERS=kafka:9092
JS_EVALUATOR=remote
TRANSPORT_TYPE=remote
-CACHE_TYPE=redis
+#CACHE_TYPE=redis
REDIS_HOST=redis
HTTP_LOG_CONTROLLER_ERROR_STACK_TRACE=false
docker-compose.yml 6(+6 -0)
diff --git a/docker-compose.yml b/docker-compose.yml
index f14e8c0..72d9368 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -3,10 +3,16 @@ services:
application:
build: .
container_name: thingsboard
+ environment:
+ - TRACER_SERIALISE_INTERNALS=false
+ - TRACER_VERBOSE=true
+ - TRACER_ENABLE=true
+ - TRACER_TRACES=/caching-approaches-comparison/applications/traces/thingsboard
volumes:
- application:/application
- /root/.m2:/root/.m2
- ~/.npm:/root/.npm
+ - ../../../:/caching-approaches-comparison
restart: unless-stopped
ports:
- 8080:8080
rule-engine/rule-engine-components/ignored 13(+13 -0)
diff --git a/rule-engine/rule-engine-components/ignored b/rule-engine/rule-engine-components/ignored
new file mode 100644
index 0000000..33ba22e
--- /dev/null
+++ b/rule-engine/rule-engine-components/ignored
@@ -0,0 +1,13 @@
+org.projectlombok.
+ch.qos.logback.
+com.amazonaws.
+com.google.code.gson.
+com.google.guava.
+com.rabbitmq.
+junit.
+org.apache.kafka.
+org.bouncycastle.
+org.cassandraunit.
+org.mockito.
+org.slf4j.
+org.springframework.
\ No newline at end of file
rule-engine/rule-engine-components/pom.xml 55(+54 -1)
diff --git a/rule-engine/rule-engine-components/pom.xml b/rule-engine/rule-engine-components/pom.xml
index 39dfc2c..be747f0 100644
--- a/rule-engine/rule-engine-components/pom.xml
+++ b/rule-engine/rule-engine-components/pom.xml
@@ -119,7 +119,11 @@
<artifactId>mockito-all</artifactId>
<scope>test</scope>
</dependency>
-
+ <dependency>
+ <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
+ <artifactId>ApplicationTracer</artifactId>
+ <version>1.0</version>
+ </dependency>
</dependencies>
<build>
@@ -157,6 +161,55 @@
</executions>
</plugin>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>aspectj-maven-plugin</artifactId>
+ <version>1.11</version>
+ <configuration>
+ <showWeaveInfo>false</showWeaveInfo>
+ <complianceLevel>1.8</complianceLevel>
+ <source>1.8</source>
+ <target>1.8</target>
+ <Xlint>ignore</Xlint>
+ <encoding>UTF-8</encoding>
+ <verbose>false</verbose>
+ <forceAjcCompile>true</forceAjcCompile>
+ <sources/>
+ <weaveDirectories>
+ <weaveDirectory>${project.build.directory}/classes</weaveDirectory>
+ </weaveDirectories>
+ <aspectLibraries>
+ <aspectLibrary>
+ <groupId>br.ufrgs.inf.prosoft.applicationtracer</groupId>
+ <artifactId>ApplicationTracer</artifactId>
+ </aspectLibrary>
+ </aspectLibraries>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>compile</goal>
+ <goal>test-compile</goal>
+ </goals>
+ </execution>
+ </executions>
+ <dependencies>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjrt</artifactId>
+ <version>1.9.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.aspectj</groupId>
+ <artifactId>aspectjtools</artifactId>
+ <version>1.9.1</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+
+
</plugins>
</build>
diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAbstractCustomerActionNode.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAbstractCustomerActionNode.java
index 8211152..1fff583 100644
--- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAbstractCustomerActionNode.java
+++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAbstractCustomerActionNode.java
@@ -15,9 +15,9 @@
*/
package org.thingsboard.rule.engine.action;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.CacheLoader;
-import com.google.common.cache.LoadingCache;
+//import com.google.common.cache.CacheBuilder;
+//import com.google.common.cache.CacheLoader;
+//import com.google.common.cache.LoadingCache;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import lombok.AllArgsConstructor;
@@ -43,17 +43,20 @@ public abstract class TbAbstractCustomerActionNode<C extends TbAbstractCustomerA
protected C config;
- private LoadingCache<CustomerKey, Optional<CustomerId>> customerIdCache;
+// private LoadingCache<CustomerKey, Optional<CustomerId>> customerIdCache;
+ private CustomerLoader customerLoader;
@Override
public void init(TbContext ctx, TbNodeConfiguration configuration) throws TbNodeException {
this.config = loadCustomerNodeActionConfig(configuration);
- CacheBuilder cacheBuilder = CacheBuilder.newBuilder();
- if (this.config.getCustomerCacheExpiration() > 0) {
- cacheBuilder.expireAfterWrite(this.config.getCustomerCacheExpiration(), TimeUnit.SECONDS);
- }
- customerIdCache = cacheBuilder
- .build(new CustomerCacheLoader(ctx, createCustomerIfNotExists()));
+// CacheBuilder cacheBuilder = CacheBuilder.newBuilder();
+// if (this.config.getCustomerCacheExpiration() > 0) {
+// cacheBuilder.expireAfterWrite(this.config.getCustomerCacheExpiration(), TimeUnit.SECONDS);
+// }
+// customerIdCache = cacheBuilder
+// .build(new CustomerCacheLoader(ctx, createCustomerIfNotExists()));
+ this.customerLoader=new CustomerLoader(ctx, createCustomerIfNotExists());
+
}
protected abstract boolean createCustomerIfNotExists();
@@ -82,7 +85,8 @@ public abstract class TbAbstractCustomerActionNode<C extends TbAbstractCustomerA
String customerTitle = TbNodeUtils.processPattern(this.config.getCustomerNamePattern(), msg.getMetaData());
CustomerKey key = new CustomerKey(customerTitle);
return ctx.getDbCallbackExecutor().executeAsync(() -> {
- Optional<CustomerId> customerId = customerIdCache.get(key);
+// Optional<CustomerId> customerId = customerIdCache.get(key);
+ Optional<CustomerId> customerId = customerLoader.load(key);
if (!customerId.isPresent()) {
throw new RuntimeException("No customer found with name '" + key.getCustomerTitle() + "'.");
}
@@ -100,17 +104,19 @@ public abstract class TbAbstractCustomerActionNode<C extends TbAbstractCustomerA
private String customerTitle;
}
- private static class CustomerCacheLoader extends CacheLoader<CustomerKey, Optional<CustomerId>> {
+// private static class CustomerCacheLoader extends CacheLoader<CustomerKey, Optional<CustomerId>> {
+ private static class CustomerLoader {
private final TbContext ctx;
private final boolean createIfNotExists;
- private CustomerCacheLoader(TbContext ctx, boolean createIfNotExists) {
+// private CustomerCacheLoader(TbContext ctx, boolean createIfNotExists) {
+ private CustomerLoader(TbContext ctx, boolean createIfNotExists) {
this.ctx = ctx;
this.createIfNotExists = createIfNotExists;
}
- @Override
+// @Override
public Optional<CustomerId> load(CustomerKey key) {
CustomerService service = ctx.getCustomerService();
Optional<Customer> customerOptional =
diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAbstractCustomerActionNodeConfiguration.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAbstractCustomerActionNodeConfiguration.java
index 3f587b5..05f07ac 100644
--- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAbstractCustomerActionNodeConfiguration.java
+++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAbstractCustomerActionNodeConfiguration.java
@@ -24,6 +24,6 @@ import lombok.Data;
public abstract class TbAbstractCustomerActionNodeConfiguration {
private String customerNamePattern;
- private long customerCacheExpiration;
+// private long customerCacheExpiration;
}
diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAssignToCustomerNodeConfiguration.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAssignToCustomerNodeConfiguration.java
index 7be9033..df34c58 100644
--- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAssignToCustomerNodeConfiguration.java
+++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbAssignToCustomerNodeConfiguration.java
@@ -28,7 +28,7 @@ public class TbAssignToCustomerNodeConfiguration extends TbAbstractCustomerActio
TbAssignToCustomerNodeConfiguration configuration = new TbAssignToCustomerNodeConfiguration();
configuration.setCustomerNamePattern("");
configuration.setCreateCustomerIfNotExists(false);
- configuration.setCustomerCacheExpiration(300);
+// configuration.setCustomerCacheExpiration(300);
return configuration;
}
}
diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbUnassignFromCustomerNodeConfiguration.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbUnassignFromCustomerNodeConfiguration.java
index 95bd87a..0e55e23 100644
--- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbUnassignFromCustomerNodeConfiguration.java
+++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbUnassignFromCustomerNodeConfiguration.java
@@ -25,7 +25,7 @@ public class TbUnassignFromCustomerNodeConfiguration extends TbAbstractCustomerA
public TbUnassignFromCustomerNodeConfiguration defaultConfiguration() {
TbUnassignFromCustomerNodeConfiguration configuration = new TbUnassignFromCustomerNodeConfiguration();
configuration.setCustomerNamePattern("");
- configuration.setCustomerCacheExpiration(300);
+// configuration.setCustomerCacheExpiration(300);
return configuration;
}
}