100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Fixed attribute event timestamps check
Christian Bauer25fb20453529
diff --git a/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java b/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.javaindex 14cb50d72..6f38a0ebc 100644--- a/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java+++ b/manager/server/src/main/java/org/openremote/manager/server/agent/AgentService.java@@ -154,10 +154,12 @@ public class AgentService extends RouteBuilder implements ContainerService, Cons@Overridepublic void stop(Container container) throws Exception {+ /* TODO Accessing the database while shutting down is not a good thing, it will hang if the JDBC pool is shutting downsynchronized (protocolConfigurations) {new ArrayList<>(protocolConfigurations.values()).forEach(protocolConfigAndConsumer -> unlinkProtocolConfiguration(protocolConfigAndConsumer.key));}+ */}@Overridediff --git a/manager/server/src/main/java/org/openremote/manager/server/asset/AssetRoute.java b/manager/server/src/main/java/org/openremote/manager/server/asset/AssetRoute.javaindex cc3d42431..d0f57a745 100644--- a/manager/server/src/main/java/org/openremote/manager/server/asset/AssetRoute.java+++ b/manager/server/src/main/java/org/openremote/manager/server/asset/AssetRoute.java@@ -236,7 +236,7 @@ public final class AssetRoute {// Check the last update timestamp of the attribute, ignoring any event that is older than last update// TODO This means we drop out-of-sequence events but accept events with the same source timestamp// TODO Several attribute events can occur in the same millisecond, then order of application is undefined- lastStateEvent.map(Event::getTimestamp).filter(t -> t > 0 && eventTime <= t).ifPresent(+ lastStateEvent.map(Event::getTimestamp).filter(t -> t >= 0 && eventTime < t).ifPresent(lastStateTime -> {throw new AssetProcessingException(Reason.EVENT_OUTDATED,diff --git a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovyindex 41355d635..6ac72153b 100644--- a/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy+++ b/manager/test/src/test/groovy/org/openremote/test/rules/BasicRulesProcessingTest.groovy@@ -150,12 +150,22 @@ class BasicRulesProcessingTest extends Specification implements ManagerContainerthen: "no rule engines should have fired after a few seconds"new PollingConditions(initialDelay: 3).eventually assertNoRulesFired- when: "an old (stale) attribute event is pushed into the system"+ when: "the same attribute event is pushed into the system (same timestamp as last asset state)"resetRulesExecutionListeners()assetProcessingService.sendAttributeEvent(apartment2LivingRoomPresenceDetectedChange)- then: "no rule engines should have fired after a few seconds"- new PollingConditions(initialDelay: 3).eventually assertNoRulesFired+ then: "the rule engines in scope should fire the 'All' rule but not the 'All changed' rule"+ conditions.eventually {+ assert globalEngineFiredRules.size() == 1+ assert globalEngineFiredRules[0] == "All"+ assert masterEngineFiredRules.size() == 0+ assert customerAEngineFiredRules.size() == 1+ assert customerAEngineFiredRules[0] == "All"+ assert smartHomeEngineFiredRules.size() == 0+ assert apartment2EngineFiredRules.size() == 1+ assert apartment2EngineFiredRules[0] == "All"+ assert apartment3EngineFiredRules.size() == 0+ }when: "an attribute event with the same value as current value is pushed into the system"resetRulesExecutionListeners()