-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Device state rule node; device state service improvements #9030
Device state rule node; device state service improvements #9030
Conversation
...le-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbDeviceStateNode.java
Outdated
Show resolved
Hide resolved
...le-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbDeviceStateNode.java
Outdated
Show resolved
Hide resolved
...le-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbDeviceStateNode.java
Outdated
Show resolved
Hide resolved
application/src/main/java/org/thingsboard/server/service/state/DefaultDeviceStateService.java
Outdated
Show resolved
Hide resolved
...cation/src/test/java/org/thingsboard/server/service/state/DefaultDeviceStateServiceTest.java
Outdated
Show resolved
Hide resolved
...cation/src/test/java/org/thingsboard/server/service/state/DefaultDeviceStateServiceTest.java
Outdated
Show resolved
Hide resolved
...le-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbDeviceStateNode.java
Outdated
Show resolved
Hide resolved
The idea is great, but the implementation will not work in a microservices mode. Please note that |
...le-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbDeviceStateNode.java
Outdated
Show resolved
Hide resolved
ddc5db8
to
dd6f470
Compare
dd6f470
to
d670267
Compare
Closed by accident |
...le-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbDeviceStateNode.java
Outdated
Show resolved
Hide resolved
...le-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbDeviceStateNode.java
Outdated
Show resolved
Hide resolved
...le-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbDeviceStateNode.java
Outdated
Show resolved
Hide resolved
common/data/src/main/java/org/thingsboard/server/common/data/msg/TbMsgType.java
Outdated
Show resolved
Hide resolved
...ication/src/main/java/org/thingsboard/server/service/queue/DefaultTbCoreConsumerService.java
Outdated
Show resolved
Hide resolved
…ative to current activity time
…metadata ts property is not present
@Slf4j | ||
@Service | ||
@Primary | ||
@TbCoreComponent |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use partitionService.isMyPartition to detect routing strategy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use
public void pushMsgToCore(TopicPartitionInfo tpi, UUID msgId, ToCoreMsg msg, TbQueueCallback callback)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see c5c1820
...le-engine-components/src/main/java/org/thingsboard/rule/engine/action/TbDeviceStateNode.java
Outdated
Show resolved
Hide resolved
|
||
Duration elapsedSinceLastEventSent = now.minus(lastEventTs); | ||
if (elapsedSinceLastEventSent.compareTo(ONE_SECOND) < 0) { | ||
ctx.tellSuccess(msg); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rateLimit + add to annotation the corresponding relation types
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see e55d143
private static final Duration ENTRY_CLEANUP_PERIOD = Duration.ofHours(1L); | ||
|
||
private Stopwatch stopwatch; | ||
private ConcurrentMap<DeviceId, Duration> lastActivityEventTimestamps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ConcurrentReferenceHashMap<DeviceId, TbRateLimits> with SOFT
Make the rate limit configuration an env parameter. Default value: 1:1,30:60,60:3600.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see e55d143
Pull Request description
Case: data must be pulled from external REST API or new data is computed within the rule chain, device is being created inside the rule chain using relation node, for example etc.
Problem: device state service doesn’t know about artificially created device and considers it inactive, when in fact it is active.
Workaround: using integrations or custom-made rule chain just to handle this case is messy and less performant
Solution: add rule node for this case that will directly interact with device state service
Scope of changes: added device state rule node and tests for it; device state service: fixed concurrency bug, minor refactoring of some parts of service code, added tests to cover affected logic
PE PR
UI changes PR
Documentation PR WIP
Please close outdated PR and issue for this feature by @YuriyLytvynchuk
General checklist
Back-End feature checklist