Skip to content
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

Keep order from a multimeasure to Orion CB #825

Closed
danielvillalbamota opened this issue Apr 30, 2024 · 4 comments · Fixed by telefonicaid/iotagent-node-lib#1607
Closed

Comments

@danielvillalbamota
Copy link
Contributor

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

@AlvaroVega
Copy link
Member

AlvaroVega commented Apr 30, 2024

Multimeasures are processed one by one measures in this loop:

for (const j in attributeArr) {
attributeValues = attributeArr[j];
config
.getLogger()
.debug(
context,
'Processing measure device %s with attributeArr %j attributeValues %j',
device.name,
attributeArr,
attributeValues
);
if (req.isCommand) {
const executions = [];
for (const k in attributeValues) {
executions.push(
iotAgentLib.setCommandResult.bind(
null,
device.name,
config.getConfig().iota.defaultResource,
req.apiKey,
attributeValues[k].name,
attributeValues[k].value,
constants.COMMAND_STATUS_COMPLETED,
device
)
);
}
async.parallel(executions, updateCommandHandler);
} else if (attributeValues.length > 0) {
iotAgentLib.update(device.name, device.type, '', attributeValues, device, updateCommandHandler);
} else {
finishSouthBoundTransaction(next);
}
}

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.

@fgalan
Copy link
Member

fgalan commented Apr 30, 2024

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).

@danielvillalbamota
Copy link
Contributor Author

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

@fgalan
Copy link
Member

fgalan commented May 23, 2024

Fixed in PR #826 (+ twin PR telefonicaid/iotagent-ul#677 for IOTA-UL)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants