我正在尝试天鹅座订阅猎户座。然而,它取得了成功,但是在更新价值观之前,没有任何通知被发送到天鹅座。告诉我如何查看收到天鹅座的通知?此外,有没有任何方法来检查猎户座和天鹅座之间的成功连接。 ORION&的配置和日志CYGNUS如下:
用于创建orion的POST方法:(版本 - v1)
{
"contextElements": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1",
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "39.5"
}
]
}
],
"updateAction": "UPDATE"
}
**对ORION **订阅CYGNUS如下:
{
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1"
}
],
"attributes": [
"temperature"
],
"reference": "http://cygnus:5050",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"temperature"
]
}
],
"throttling": "PT60S"
}
我在Cygnus中的agent.conf文件是这样的:
# ============================================
# # OrionCKANSink configuration
# # channel name from where to read notification events
cygnusagent.sinks.ckan-sink.channel = ckan-channel
#
# # sink class, must not be changed
cygnusagent.sinks.ckan-sink.type = com.telefonica.iot.cygnus.sinks.OrionCKANSink
#
# # true if the grouping feature is enabled for this sink, false otherwise
cygnusagent.sinks.ckan-sink.enable_grouping = false
#
# # true if lower case is wanted to forced in all the element names, false otherwise
cygnusagent.sinks.hdfs-sink.enable_lowercase = false
#
# # the CKAN API key to use
cygnusagent.sinks.ckan-sink.api_key = 1ae97e2f-1589-4bdf-8a3f-b3683fc66a5a
#
# # the FQDN/IP address for the CKAN API endpoint
cygnusagent.sinks.ckan-sink.ckan_host = demo.ckan.org
#
# # the port for the CKAN API endpoint
cygnusagent.sinks.ckan-sink.ckan_port = 5000
#
# # Orion URL used to compose the resource URL with the convenience operation URL to query it
cygnusagent.sinks.ckan-sink.orion_url = http://localhost:1026
# # how the attributes are stored, either per row either per column (row, column)
cygnusagent.sinks.ckan-sink.attr_persistence = column
#
# # enable SSL for secure Http transportation; 'true' or 'false'
cygnusagent.sinks.ckan-sink.ssl = false
#
# # number of notifications to be included within a processing batch
cygnusagent.sinks.ckan-sink.batch_size = 100
#
# # timeout for batch accumulation
cygnusagent.sinks.ckan-sink.batch_timeout = 60
#
# # number of retries upon persistence error
cygnusagent.sinks.ckan-sink.batch_ttl = 10
我的天鹅座日志:CYGNUS VERSION - 1.7
/5/2018 3:37:07 PMtime=2018-06-05T10:07:07.572Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=startAllComponents | msg=org.apache.flume.node.Application[145] : Starting Channel ckan-channel
6/5/2018 3:37:07 PMtime=2018-06-05T10:07:07.572Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=startAllComponents | msg=org.apache.flume.node.Application[160] : Waiting for channel: ckan-channel to start. Sleeping for 500 ms
6/5/2018 3:37:08 PMtime=2018-06-05T10:07:08.139Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=main | msg=com.telefonica.iot.cygnus.nodes.CygnusApplication[324] : Starting a Jetty server listening on 0.0.0.0:8081 (Management Interface)
6/5/2018 3:37:08 PMtime=2018-06-05T10:07:08.193Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=register | msg=org.apache.flume.instrumentation.MonitoredCounterGroup[119] : Monitored counter group for type: CHANNEL, name: ckan-channel: Successfully registered new MBean.
6/5/2018 3:37:08 PMtime=2018-06-05T10:07:08.250Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=start | msg=org.apache.flume.instrumentation.MonitoredCounterGroup[95] : Component type: CHANNEL, name: ckan-channel started
6/5/2018 3:37:08 PMtime=2018-06-05T10:07:08.251Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=startAllComponents | msg=org.apache.flume.node.Application[173] : Starting Sink ckan-sink
6/5/2018 3:37:08 PMtime=2018-06-05T10:07:08.253Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=startAllComponents | msg=org.apache.flume.node.Application[184] : Starting Source http-source
6/5/2018 3:37:08 PMtime=2018-06-05T10:07:08.392Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=<init> | msg=com.telefonica.iot.cygnus.interceptors.CygnusGroupingRules[53] : Grouping rules read:
6/5/2018 3:37:08 PMtime=2018-06-05T10:07:08.561Z | lvl=WARN | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=<init> | msg=com.telefonica.iot.cygnus.interceptors.CygnusGroupingRules[61] : Grouping rules syntax has errors. Details: null
6/5/2018 3:37:08 PMtime=2018-06-05T10:07:08.581Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=<init> | msg=com.telefonica.iot.cygnus.interceptors.CygnusGroupingRules[53] : Grouping rules read:
6/5/2018 3:37:08 PMtime=2018-06-05T10:07:08.591Z | lvl=WARN | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=<init> | msg=com.telefonica.iot.cygnus.interceptors.CygnusGroupingRules[61] : Grouping rules syntax has errors. Details: null
6/5/2018 3:37:09 PMtime=2018-06-05T10:07:09.917Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=register | msg=org.apache.flume.instrumentation.MonitoredCounterGroup[119] : Monitored counter group for type: SOURCE, name: http-source: Successfully registered new MBean.
6/5/2018 3:37:09 PMtime=2018-06-05T10:07:09.917Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=start | msg=org.apache.flume.instrumentation.MonitoredCounterGroup[95] : Component type: SOURCE, name: http-source started
6/5/2018 3:37:11 PMtime=2018-06-05T10:07:11.828Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=<init> | msg=com.telefonica.iot.cygnus.backends.http.HttpClientFactory[81] : Setting max total connections (500)
6/5/2018 3:37:11 PMtime=2018-06-05T10:07:11.828Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=<init> | msg=com.telefonica.iot.cygnus.backends.http.HttpClientFactory[82] : Setting default max connections per route (100)
6/5/2018 3:37:11 PMtime=2018-06-05T10:07:11.866Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=<init> | msg=com.telefonica.iot.cygnus.backends.http.HttpClientFactory[81] : Setting max total connections (500)
6/5/2018 3:37:11 PMtime=2018-06-05T10:07:11.867Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=<init> | msg=com.telefonica.iot.cygnus.backends.http.HttpClientFactory[82] : Setting default max connections per route (100)
6/5/2018 3:37:11 PMtime=2018-06-05T10:07:11.868Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnus-ngsi | op=start | msg=com.telefonica.iot.cygnus.sinks.NGSISink[354] : [ckan-sink] Startup completed
为了测试目的,我按照以下链接
之后,在天鹅座上配置测试代理:
http://fiware-cygnus.readthedocs.io/en/1.2.2/cygnus-ngsi/quick_start_guide/index.html
/opt/fiware-cygnus/cygnus-ngsi/src/main/resources/cygnus-flume-ng agent --conf /opt/apache-flume/conf/ -f /opt/apache-flume/conf/agent_test.conf -n cygnusagent -Dflume.root.logger=INFO,console
Warning: JAVA_HOME is not set!
+ exec /usr/bin/java -Xmx20m -Dflume.root.logger=INFO,console -cp '/opt/apache-flume/conf:/opt/apache-flume/lib/*:/opt/apache-flume/plugins.d/cygnus/lib/*:/opt/apache-flume/plugins.d/cygnus/libext/*' -Djava.library.path= com.telefonica.iot.cygnus.nodes.CygnusApplication -f /opt/apache-flume/conf/agent_test.conf -n cygnusagent
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/apache-flume/lib/slf4j-log4j12-1.6.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/apache-flume/plugins.d/cygnus/lib/cygnus-ngsi-1.7.0-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/apache-flume/plugins.d/cygnus/libext/cygnus-common-1.7.0-jar-with-dependencies.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
time=2018-05-05T08:21:21.573Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp= | op=main | msg=com.telefonica.iot.cygnus.nodes.CygnusApplication[189] : Starting Cygnus, version 1.7.0.9df0d4d857488c4dd72e9c5dfd2b5e41083b64b9
time=2018-05-05T08:21:21.792Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=main | msg=com.telefonica.iot.cygnus.nodes.CygnusApplication[312] : Waiting for valid Flume components references...
time=2018-05-05T08:21:21.793Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=start | msg=org.apache.flume.node.PollingPropertiesFileConfigurationProvider[61] : Configuration provider starting
time=2018-05-05T08:21:21.799Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=run | msg=org.apache.flume.node.PollingPropertiesFileConfigurationProvider$FileWatcherRunnable[133] : Reloading configuration file:/opt/apache-flume/conf/agent_test.conf
time=2018-05-05T08:21:21.823Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=addProperty | msg=org.apache.flume.conf.FlumeConfiguration$AgentConfiguration[1016] : Processing:test-sink
time=2018-05-05T08:21:21.824Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=addProperty | msg=org.apache.flume.conf.FlumeConfiguration$AgentConfiguration[1016] : Processing:test_sink
time=2018-05-05T08:21:21.824Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=addProperty | msg=org.apache.flume.conf.FlumeConfiguration$AgentConfiguration[1016] : Processing:test-sink
time=2018-05-05T08:21:21.824Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=addProperty | msg=org.apache.flume.conf.FlumeConfiguration$AgentConfiguration[1016] : Processing:test-sink
time=2018-05-05T08:21:21.824Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=addProperty | msg=org.apache.flume.conf.FlumeConfiguration$AgentConfiguration[930] : Added sinks: test-sink Agent: cygnusagent
time=2018-05-05T08:21:21.837Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=validateConfiguration | msg=org.apache.flume.conf.FlumeConfiguration[140] : Post-validation flume configuration contains configuration for agents: [cygnusagent]
time=2018-05-05T08:21:21.838Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=loadChannels | msg=org.apache.flume.node.AbstractConfigurationProvider[150] : Creating channels
time=2018-05-05T08:21:21.848Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=create | msg=org.apache.flume.channel.DefaultChannelFactory[40] : Creating instance of channel test-channel type memory
time=2018-05-05T08:21:21.854Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=loadChannels | msg=org.apache.flume.node.AbstractConfigurationProvider[205] : Created channel test-channel
time=2018-05-05T08:21:21.855Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=create | msg=org.apache.flume.source.DefaultSourceFactory[39] : Creating instance of source http-source, type org.apache.flume.source.http.HTTPSource
time=2018-05-05T08:21:21.926Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=configure | msg=com.telefonica.iot.cygnus.handlers.NGSIRestHandler[156] : [NGSIRestHandler] Startup completed
time=2018-05-05T08:21:21.939Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=create | msg=org.apache.flume.sink.DefaultSinkFactory[40] : Creating instance of sink: test-sink, type: com.telefonica.iot.cygnus.sinks.NGSITestSink
time=2018-05-05T08:21:21.948Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=getConfiguration | msg=org.apache.flume.node.AbstractConfigurationProvider[119] : Channel test-channel connected to [http-source, test-sink]
time=2018-05-05T08:21:21.962Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=startAllComponents | msg=org.apache.flume.node.Application[138] : Starting new configuration:{ sourceRunners:{http-source=EventDrivenSourceRunner: { source:org.apache.flume.source.http.HTTPSource{name:http-source,state:IDLE} }} sinkRunners:{test-sink=SinkRunner: { policy:org.apache.flume.sink.DefaultSinkProcessor@56bb46b7 counterGroup:{ name:null counters:{} } }} channels:{test-channel=org.apache.flume.channel.MemoryChannel{name: test-channel}} }
time=2018-05-05T08:21:21.962Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=startAllComponents | msg=org.apache.flume.node.Application[145] : Starting Channel test-channel
time=2018-05-05T08:21:21.962Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=startAllComponents | msg=org.apache.flume.node.Application[160] : Waiting for channel: test-channel to start. Sleeping for 500 ms
time=2018-05-05T08:21:22.010Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=register | msg=org.apache.flume.instrumentation.MonitoredCounterGroup[119] : Monitored counter group for type: CHANNEL, name: test-channel: Successfully registered new MBean.
time=2018-05-05T08:21:22.010Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=start | msg=org.apache.flume.instrumentation.MonitoredCounterGroup[95] : Component type: CHANNEL, name: test-channel started
time=2018-05-05T08:21:22.463Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=startAllComponents | msg=org.apache.flume.node.Application[173] : Starting Sink test-sink
time=2018-05-05T08:21:22.464Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=startAllComponents | msg=org.apache.flume.node.Application[184] : Starting Source http-source
time=2018-05-05T08:21:22.466Z | lvl=WARN | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=<init> | msg=com.telefonica.iot.cygnus.interceptors.CygnusGroupingRules[49] : No grouping rules have been read. Details: /Applications/apache-flume-1.4.0-bin/conf/grouping_rules.conf (No such file or directory)
time=2018-05-05T08:21:22.467Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=start | msg=com.telefonica.iot.cygnus.sinks.NGSISink[354] : [test-sink] Startup completed
time=2018-05-05T08:21:22.476Z | lvl=WARN | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=<init> | msg=com.telefonica.iot.cygnus.interceptors.CygnusGroupingRules[49] : No grouping rules have been read. Details: /Applications/apache-flume-1.4.0-bin/conf/grouping_rules.conf (No such file or directory)
time=2018-05-05T08:21:22.626Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=register | msg=org.apache.flume.instrumentation.MonitoredCounterGroup[119] : Monitored counter group for type: SOURCE, name: http-source: Successfully registered new MBean.
time=2018-05-05T08:21:22.627Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=start | msg=org.apache.flume.instrumentation.MonitoredCounterGroup[95] : Component type: SOURCE, name: http-source started
time=2018-05-05T08:21:22.794Z | lvl=INFO | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=main | msg=com.telefonica.iot.cygnus.nodes.CygnusApplication[324] : Starting a Jetty server listening on 0.0.0.0:8081 (Management Interface)
time=2018-05-05T08:21:52.477Z | lvl=WARN | corr= | trans= | srv= | subsrv= | comp=cygnusagent | op=<init> | msg=com.telefonica.iot.cygnus.interceptors.CygnusGroupingRules[49] : No grouping rules have been read. Details: /Applications/apache-flume-1.4.0-bin/conf/grouping_rules.conf (No such file or directory)
现在,如果我执行此文件notification.sh
URL=$1
curl $URL -v -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' --header "Fiware-Service: qsg" --header "Fiware-ServicePath: testsink" -d @- <<EOF
{
"subscriptionId" : "51c0ac9ed714fb3b37d7d5a8",
"originator" : "localhost",
"contextResponses" : [
{
"contextElement" : {
"attributes" : [
{
"name" : "temperature",
"type" : "float",
"value" : "26.5"
}
],
"type" : "Room",
"isPattern" : "false",
"id" : "Room1"
},
"statusCode" : {
"code" : "200",
"reasonPhrase" : "OK"
}
}
]
}
EOF
我收到回复:
* Connected to CYGNUS_IP (CYGNUS_IP) port 5053 (#0)
> POST /notify HTTP/1.1
> User-Agent: curl/7.29.0
> Host: CYGNUS_IP:5053
> Content-Type: application/json
> Accept: application/json
> Fiware-Service: qsg
> Fiware-ServicePath: testsink
> Content-Length: 615
>
* upload completely sent off: 615 out of 615 bytes
* Recv failure: Connection reset by peer
* Closing connection 0
curl: (56) Recv failure: Connection reset by peer
答案 0 :(得分:0)
您可以执行以下操作以了解您的订阅是否已被激活(因此,确保Orion正在向Cygnus发送通知):
GET /v2/subscriptions
如果您不知道订阅的ID。在这种情况下,您将获得所有订阅的信息,您必须找到用于Cygnus的信息。GET /v2/subscriptions/<subscriptionId
如果您知道订阅ID。响应中的以下字段可能有所帮助(有关详细信息,请参阅NGSIv2 specification):
status
:active
(对于有效订阅)或inactive
(对于非活动订阅)[..]。此外,对于遇到通知问题的订阅,状态设置为failed
。通知再次开始工作后,状态将更改回active
。
timesSent
(不可编辑,仅在GET操作中出现):由于此订阅而发送的通知数。
lastNotification
(不可编辑,仅在GET操作中出现):ISO8601格式的上次通知时间戳。
lastFailure
(不可编辑,仅在GET操作中出现):ISO8601格式的上次失败时间戳。如果订阅从未出现过通知问题,则不存在。
lastSuccess
(不可编辑,仅在GET操作中出现):ISO8601格式的上次成功通知的时间戳。如果订阅从未成功通知,则不存在。
因此,如果一切顺利,timesSent
应该包含每次更新,则状态不应为failed
且lastNotification
应等于lastSuccess
。