Coder Social home page Coder Social logo

Comments (7)

sbernard31 avatar sbernard31 commented on August 28, 2024

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.

JPSELC avatar JPSELC commented on August 28, 2024

@sbernard31 We are seeing this issue in an override sequence which goes something like

  1. Set Override timer
  2. Turn Light On
  3. 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.

sbernard31 avatar sbernard31 commented on August 28, 2024

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.

JPSELC avatar JPSELC commented on August 28, 2024

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.

sbernard31 avatar sbernard31 commented on August 28, 2024

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.

JPSELC avatar JPSELC commented on August 28, 2024

Thanks Simon. I think we can close the issue.
We need to work with the situation where the order is not determinate.

from leshan.

sbernard31 avatar sbernard31 commented on August 28, 2024

You're welcome. 🙂

Do not hesitate to reopen if needed.

from leshan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.