How I specify the Fiware-Service and Fiware-Servic

2019-07-22 03:03发布

问题:

So far I have configured ContextBroker to send data to Cygnus which in turn saves data by default names in database.

But what if I want to target a specific database with a specific table?

I know I have to set:

dbName=<fiware-service> 
tableName=<fiware-servicePath>_<entityId>_<entityType>

I dont know where that file is, and I know it isnt in /etc/sysconfig/contextBroker because that folder doesnt exist.

EDIT1: here is my updatecontext:

(curl localhost:1026/NGSI10/updateContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Fiware-Service: FiwareDatabase' --header 'Fiware-ServicePath: /AllSensors' -d @- ) <<EOF
{
    "contextElements": [
        {
            "type": "Television",
            "isPattern": "false",
            "id": "TV2",
            "attributes": [
            {
                "name": "channel",
                "type": "integer",
                "value": "14"
            },
            {
                "name": "volume",
                "type": "float",
                "value": "9"
            }
            ]
        }
    ],
    "updateAction": "APPEND"
}
EOF

As I said the table does get automatically created but the database doesnt.

回答1:

Fiware-Service and Fiware-ServicePath are set at entity creation time using HTTP headers in the entity creation REST request. Please have a look to the following sections in the Orion User Manual:

  • Service
  • Service path

UPDATE: for example, in order to create an entity in service "servA" and service path "/path1" you could use the example shown in the create entity section in the manual adding two additionals HTTP headers to the curl line:

(curl localhost:1026/v1/updateContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Fiware-Service: servA' --header 'Fiware-ServicePath: /path1' -d @- | python -mjson.tool) <<EOF
...

That would make to insert information in the following MySQL database/table (assuming that Cygnus is well configured, subscriptions are correct, etc.):

dbName=servA
tableName=path1_<entityId>_<entityType>

Note that the default behaviour is to store the information for each entity in a different table. That default behaviour can be changed, but if you are interested in that possibility, please create a new question in StackOverflow for dealing with that.