【问题标题】:How I specify the Fiware-Service and Fiware-ServicePath fields at Orion that set the name of MySQL database and table in Cygnus?如何在 Orion 中指定 Fiware-Service 和 Fiware-ServicePath 字段来设置 Cygnus 中 MySQL 数据库和表的名称?
【发布时间】:2015-04-23 07:12:39
【问题描述】:

到目前为止,我已将 ContextBroker 配置为向 Cygnus 发送数据,而 Cygnus 又以默认名称将数据保存在数据库中。

但是如果我想使用特定表来定位特定数据库怎么办?

我知道我必须设置:

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

我不知道那个文件在哪里,我知道它不在 /etc/sysconfig/contextBroker 因为那个文件夹不存在。

EDIT1:这是我的更新上下文:

(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

正如我所说,表会自动创建,但数据库不会。

【问题讨论】:

  • 没有可以设置 dbName 和 tableName 的地方,因为这些是 Cygnus 根据 fiware-servicefiware-servicePathentityIdentityType 通知值自动推断的值。因此,您需要知道如何在 Orion 上设置这些值,特别是 fiware-servicefiware-servicePath(fgalan 将为您提供有关这方面的确切细节)。

标签: fiware fiware-orion fiware-cygnus


【解决方案1】:

Fiware-Service 和 Fiware-ServicePath 在实体创建时使用实体创建 REST 请求中的 HTTP 标头设置。请查看 Orion 用户手册中的以下部分:

UPDATE:例如,为了在服务“servA”和服务路径“/path1”中创建一个实体,您可以使用the create entity section in the manual 中显示的示例,向卷曲线:

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

这将在以下 MySQL 数据库/表中插入信息(假设 Cygnus 配置良好,订阅正确等):

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

请注意,默认行为是将每个实体的信息存储在不同的表中。可以更改该默认行为,但如果您对这种可能性感兴趣,请在 StackOverflow 中创建一个新问题以进行处理。

【讨论】:

  • 我读到了,但我仍然不明白我到底该怎么做如果我想以 MySql 数据库为目标,在我的示例中名为:“FIware_Test”。然后我想将所有数据存储在一个名为 Sensors_Data 的表中,而不管 entetyID 是什么。换句话说,我不希望每个 entetyID 都有一个新表,我希望所有这些都在一个表中。
  • 只是想知道如何修改我之前的答案更清楚...我应该明白你知道并理解什么是 HTTP 标头吗?
  • 好的,假设你知道这个话题,我已经修改了我的答案;)但是,有很多关于它的信息,在你的情况下(例如:code.tutsplus.com/tutorials/http-headers-for-dummies--net-8039
  • 好的,我只在 updateContext 中这样做?我不必再在 subscribeContext 中做吗?
  • 记住我们前几天说的:如果使用 Cygnus 的行模式,数据库和表是由 Cygnus 自动创建的。如果不工作,那是由于一些配置错误(我们会抓住它;))
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多