iotagent-json icon indicating copy to clipboard operation
iotagent-json copied to clipboard

Keep order from a multimeasure to Orion CB

Open danielvillalbamota opened this issue 9 months ago • 3 comments

Component

Feature enhancement

Is your feature request related to a problem? Please describe

When sending a multimeasure like this:

[
	{"TimeInstant": "2024-04-10T10:00:00Z","temperatureExitLevel": 14,"flowExitLevel": 18,"vol":5},
	{"TimeInstant": "2024-04-10T10:05:00Z","temperatureExitLevel": 12,"flowExitLevel": 18,"vol":10},
	{"TimeInstant": "2024-04-10T10:10:00Z","temperatureExitLevel": 13,"flowExitLevel": 18,"vol":15},
	{"TimeInstant": "2024-04-10T10:15:00Z","temperatureExitLevel": 18,"flowExitLevel": 18,"vol":20},
	{"TimeInstant": "2024-04-10T10:20:00Z","temperatureExitLevel": 11,"flowExitLevel": 18,"vol":25},
	{"TimeInstant": "2024-04-10T10:25:00Z","temperatureExitLevel": 15,"flowExitLevel": 18,"vol":30},
	{"TimeInstant": "2024-04-10T10:30:00Z","temperatureExitLevel": 14,"flowExitLevel": 18,"vol":35},
	{"TimeInstant": "2024-04-10T10:35:00Z","temperatureExitLevel": 32,"flowExitLevel": 18,"vol":40},
	{"TimeInstant": "2024-04-10T10:40:00Z","temperatureExitLevel": 30,"flowExitLevel": 18,"vol":45},
	{"TimeInstant": "2024-04-10T10:45:00Z","temperatureExitLevel": 28,"flowExitLevel": 18,"vol":50},
	{"TimeInstant": "2024-04-10T10:50:00Z","temperatureExitLevel": 27,"flowExitLevel": 18,"vol":55}
]

The CB receive the requests split in multiple individual requests out of order.

As example:

...
time=2024-04-30T09:25:56.037Z | lvl=INFO | corr=a5a8cbe8-06d3-11ef-8763-0242ac11001d | trans=1714136430-004-00001108489 | from=172.17.0.32 | srv=... | subsrv=/abc | comp=Orion | op=logTracing.cpp[211]:logInfoRequestWithPayload | msg=Request received: POST /v2/entities?options=upsert, request payload (295 bytes): {"id":"pruebamejoras","type":"WaterPipe","TimeInstant":{"type":"DateTime","value":"2024-04-11T10:25:00.000Z","metadata":{}},"flowExitLevel":{"type":"Number","value":6,"metadata":{}},"temperatureExitLevel":{"type":"Number","value":6,"metadata":{}},"vol":{"type":"Number","value":6,"metadata":{}}}, response code: 204
time=2024-04-30T09:25:56.038Z | lvl=INFO | corr=a5a8c7d8-06d3-11ef-82e9-0242ac11001d | trans=1714136430-004-00001108488 | from=172.17.0.32 | srv=... | subsrv=/abc | comp=Orion | op=logTracing.cpp[211]:logInfoRequestWithPayload | msg=Request received: POST /v2/entities?options=upsert, request payload (295 bytes): {"id":"pruebamejoras","type":"WaterPipe","TimeInstant":{"type":"DateTime","value":"2024-04-11T10:20:00.000Z","metadata":{}},"flowExitLevel":{"type":"Number","value":5,"metadata":{}},"temperatureExitLevel":{"type":"Number","value":5,"metadata":{}},"vol":{"type":"Number","value":5,"metadata":{}}}, response code: 204
...

Describe the solution you'd like

Would be interesting receiving the array in the same order, for example, one batch request op/update in the Orion CB, containing the array in the same order.

Describe alternatives you've considered

No response

The systemd version you checked that didn't have the feature you are asking for

No response

danielvillalbamota avatar Apr 30 '24 10:04 danielvillalbamota

Multimeasures are processed one by one measures in this loop:

https://github.com/telefonicaid/iotagent-json/blob/86d7cc4d61893e729e7242a8c630aaa194521978/lib/bindings/HTTPBinding.js#L358-L391

One single measure is able to generate multiple updates to CB (i.e. multientity) which are sent in a /v2/op/update (Batch) to CB

iotagent-node lib function sendUpdateValue is not able to allow multiple measures, just one measure

Not sure if that loop is keeping or loosing measures order or not; this could be the reason of this issue.

AlvaroVega avatar Apr 30 '24 10:04 AlvaroVega

I understand that the ability to order the measures in some order is out of the scope of this issue (i.e. a new issue as continuation of the present one will be created).

fgalan avatar Apr 30 '24 10:04 fgalan

I understand that the ability to order the measures in some order is out of the scope of this issue (i.e. a new issue as continuation of the present one will be created).

Yes, the point is to keep the order received in the multimeasures array

danielvillalbamota avatar Apr 30 '24 14:04 danielvillalbamota

Fixed in PR #826 (+ twin PR https://github.com/telefonicaid/iotagent-ul/pull/677 for IOTA-UL)

fgalan avatar May 23 '24 11:05 fgalan