ОРИОН: Как уменьшить время отклика для / v2 / лиц - PullRequest
1 голос
/ 14 марта 2019

Я развернул стек iot с помощью докера. Это использованные контейнеры:

  • fiware / Орион: 2.1.0

Используемые параметры командной строки: -corsOrigin __ALL -corsMaxAge 600 -dbhost mongo-orion -logLevel DEBUG -logForHumans -t 180-199

  • fiware / iotagent-JSON: 1.9.0

ПОДАРОК: Следующий шаблон устройства:

{
    "devices": [
        {
            "device_id": "sen-n",
            "entity_name": "sen-n",
            "entity_type": "sensor",
            "transport": "HTTP",
            "protocol": "IoTA-JSON",
            "endpoint": "http://nodered:1880/notification",
            "commands": [
                {
                    "name": "ping",
                    "type": "command"
                }
            ],
            "attributes": [
                {
                    "object_id": "status",
                    "name": "status",
                    "type": "Text"
                }
            ],
            "static_attributes": [
                {
                    "name": "name",
                    "type": "Text",
                    "value": "Sensor n"
                }
            ]
        }
    ]
}

WHEN: Зарегистрировать большое количество устройств на агенте IoT , на котором выполняется следующий сценарий оболочки:

# Bash execution example: sudo chmod +x run.sh --> ./run.sh 1100
# Sh execution example: sh run.sh 1100

#!/bin/bash
for n in $(seq "$1")
do
 echo "Inserting $n device"

 curl --request POST \
  --url 'http://localhost:4041/iot/devices' \
  --header 'Content-Type: application/json' \
  --header 'fiware-service: test' \
  --header 'fiware-servicepath: /test' \
  --data '{"devices":[{"device_id":"sen-'$n'","entity_name":"sen-'$n'","entity_type":"sensor","transport":"HTTP","protocol":"IoTA-JSON","endpoint":"http://nodered:1880/notification","commands":[{"name":"ping","type":"command"}],"attributes":[{"object_id":"status","name":"status","type":"Text"}],"static_attributes":[{"name":"name","type":"Text","value":"Sensor '$n'"}]}]}'

done

И: Попытка получить эти объекты из Ориона.

curl --request GET \
  --url 'http://localhost:1026/v2/entities/?limit=1000' \
  --header 'fiware-service: test' \
  --header 'fiware-servicepath: /test'

THEN: Время ответа слишком велико. Это между 13447мс и 15516мс .


  • Я проверил аргумент командной строки Orion -cprForwardLimit , равный 0 , но это приводит к тому, что выполнение команд не работает. Это через следующую 404 ошибку .
orion            | INFO@07:32:34  logMsg.h[1832]: Starting transaction from 172.18.0.1:38752/v1/updateContext
orion            | DEBUG@07:32:34  rest.cpp[1414]: Got 417 of payload of 417 bytes
orion            | INFO@07:32:34  rest.cpp[885]: Service Path 0: '/test'
orion            | INFO@07:32:34  connectionOperations.cpp[94]: Database Operation Successful (query: { _id.id: "sen1", _id.type: "sensor", _id.servicePath: { $in: [ /^/test$/ ] } })
orion            | INFO@07:32:34  connectionOperations.cpp[177]: Database Operation Successful (query: { query: { $or: [ { contextRegistration.entities: { $in: [ { id: "sen1", type: "sensor" }, { type: "sensor", id: "sen1" } ] } }, { contextRegistration.entities.id: { $in: [] } } ], expiration: { $gt: 1552548754 }, contextRegistration.attrs.name: { $in: [ "ping" ] }, servicePath: { $in: [ /^/test$/ ] } }, orderby: { _id: 1 } })
orion            | INFO@07:32:34  connectionOperations.cpp[177]: Database Operation Successful (query: { query: { $or: [ { contextRegistration.entities: { $in: [ { id: "sen1", type: "sensor" }, { type: "sensor", id: "sen1" } ] } }, { contextRegistration.entities.id: { $in: [] } } ], expiration: { $gt: 1552548754 }, servicePath: { $in: [ /^/test$/ ] } }, orderby: { _id: 1 } })
orion            | DEBUG@07:32:34  restReply.cpp[75]: Response 6: responding with 237 bytes, Status Code 200
orion            | DEBUG@07:32:34  restReply.cpp[76]: Response payload: '{"contextResponses":[{"contextElement":{"type":"sensor","isPattern":"false","id":"sen1","attributes":[{"name":"ping","type":"command","value":""}]},"statusCode":{"code":"404","reasonPhrase":"No context element found","details":"sen1"}}]}'
orion            | INFO@07:32:34  logMsg.h[1916]: Transaction ended

Итак, есть ли способ уменьшить это время отклика, не прерывая выполнение команды?

...