Comments (7)
Could you explain a bit more why order is important ?
I get that this is about client implementation but I'm curious to better understand this "client bug" ? 🤔
from leshan.
@sbernard31 We are seeing this issue in an override sequence which goes something like
- Set Override timer
- Turn Light On
- Set Light Brightness.
It's a sequence where 2 is dependent on 1 and 3 is dependent on 2.
We can of course do this in 3 separate writes, waiting for the acknowledges etc, but if we could do this with an ordered compound write, it would simplify it and be far faster, especially in a slow network.
Obviously we can add custom code which handles a compound write with these 3 attributes and executes them in the correct order, but in general it would be better if we could rely on the order of the commands in the compound write.
The issue really is that the LwM2M Spec doesn't indicate that the order of the writes is respected.
from leshan.
It's a sequence where 2 is dependent on 1 and 3 is dependent on 2.
I'm not sure to get what means "override timer"
But for "turn light on" and "set light brightness", I'm not sure to see why order should be critical. 🤔
At first sight, that's really looks like client implementation issue. (Maybe a good idea to try to also fix client at mid/long term ?)
The issue really is that the LwM2M Spec doesn't indicate that the order of the writes is respected.
Maybe I missed something but I can not see why this would be a specification issue.
Currently, I think is not wrong to state that Write Composite Operation should be considered as atomic.
It makes sense with Write Composite using CoAP iPatch
which is idempotent.
Not sure, but I guess your client should not like too much that you execute those WriteCompositeRequest
twice if order is important ? (so not really idempotent)
Obviously we can add custom code which handles a compound write with these 3 attributes and executes them in the correct order, but in general it would be better if we could rely on the order of the commands in the compound write.
Generally, I prefer letting user being able to provide custom code for their out of spec use case. (see Real Life is about dealing with non-compliant foreign peer behavior.)
But here a solution could be that we use LinkedHashMap
instead of HashMap
in WriteCompositeRequest
.
This would at cost of 2 additional object reference by maps entry : 2 x 32 bits or 64 bits (depends of JVM) by entry.
This would only keep order in WriteCompositeRequest
then no guarantee that decoder/encoder will respect it.
If we don't want to pay that cost, another solution would be to provide, a protected constructor in WriteCompositeRequest
which allow you to create a OrderedWriteCompositeRequest
using whatever map you want internally.
Oh I also just see that if you use this constructor : WriteCompositeRequest.WriteCompositeRequest(ContentFormat, Map<LwM2mPath, LwM2mNode>, Object)
order should be respected. (If I read the code correctly)
Let me know your opinion about that 🙏
We can of course do this in 3 separate writes, waiting for the acknowledges etc, but if we could do this with an ordered compound write, it would simplify it and be far faster, especially in a slow network.
Do you have numbers about how this will really impact in real world.
Keep free to give real numbers because in call cases (even if number seems very low) we will try to find a solution for you use case.
I just try to have a better vision of real world.
from leshan.
Maybe I missed something but I can not see why this would be a specification issue.
My point here is that because there is no mention of order of compound writes being respected in the spec, there is no onus on anyone to implement it that way, so in general one could not rely on that.
The fact that compound commands are atomic is great, and I guess that's the whole point of compound commands, but I think it would be more powerful if the order of commands was respected too.
As regards numbers on timing, Cat-NB has a maximum latency of 10 seconds, so sending 3 commands and waiting for acknowledges would take up to 60 seconds, versus 20 seconds, which might not seem a lot, but it becomes important when there is scale involved.
Regarding running the commands twice, that might work, but it might take 3 times to satisfy the dependencies.
Thanks for your consideration. I think we have the answers we need.
from leshan.
As regards numbers on timing, Cat-NB has a maximum latency of 10 seconds, so sending 3 commands and waiting for acknowledges would take up to 60 seconds, versus 20 seconds, which might not seem a lot, but it becomes important when there is scale involved.
Thx that's really help me to better understand this kind of use case.
Regarding running the commands twice, that might work, but it might take 3 times to satisfy the dependencies.
An idempotent function should have same result if it is applied 1 or several time.
In that case, if you send it 1 or 2 times, the state of the client should be the same.
So, Regarding your answer, I understand the implementation is not idempotent.
(But I agree, this is very theoretically and I can understand that some implementation doesn't full respect that)
Thanks for your consideration. I think we have the answers we need.
That means that using WriteCompositeRequest.WriteCompositeRequest(ContentFormat, Map<LwM2mPath, LwM2mNode>, Object)
works for you ?
If yes, let me know.
If you think this would be better to introduce LinkedHashMap
for the other constructor let me know too.
I wait for you confirmation before to close the issue.
Thx for taking time to share your issue, all feedback are welcome.
from leshan.
Thanks Simon. I think we can close the issue.
We need to work with the situation where the order is not determinate.
from leshan.
You're welcome. 🙂
Do not hesitate to reopen if needed.
from leshan.
Related Issues (20)
- FW update test HOT 3
- CoAP version 0 not supported HOT 3
- [Feature Request] Ability to monitor request-response lifecycle HOT 9
- Add new object HOT 3
- Plan for 2.0.0-M15 🎯 HOT 24
- Is OMA Object 9 resource 12 correct? HOT 2
- Is Leshan server ready for production in industry ? HOT 14
- [Firmware Update][Blockwise] HOT 8
- Should sending timestamped data in an observation request response be a supported use case? HOT 14
- The addition of a resource instance is not detected by LwM2mTestObject (3442) HOT 3
- Precision loss when deserialize BigDecimal with SenMLJSON / old JSON content format. HOT 1
- Fail to decode empty response to a Read operation HOT 4
- How Timstamp should be handled in LWM2M/Leshan ?
- ObservationListener.onError is no longer called on 5.00 responses HOT 5
- Increasing Leshan Contributor Community ?
- Issue with running Contiki-NG with latest release of Leshan (2.0.0-M15) HOT 9
- Plan for 2.0.0-M16 🎯 HOT 9
- How to address a tagged CBOR number value not being deserialized as base time in SenMLRecord? HOT 11
- update from `@CycloneDX/cyclonedx-node-yarn` project HOT 2
- Error log when receiving a Send with an empty payload HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from leshan.