Я не могу заставить Ориона общаться с Лебедем? - PullRequest
0 голосов
/ 05 июня 2018

Я пытаюсь подписаться на Ориона.Однако это дает успех, но при обновлении значения для orion нет уведомлений, отправляемых Cygnus.Подскажите, как я могу проверить получение уведомления Cygnus?Кроме того, есть ли способ проверить успешную связь между Орионом и Лебедем.Конфигурация и журналы ORION & CYGNUS приведены ниже:

ПОЧТОВЫЙ МЕТОД на орионе для создания: (ВЕРСИЯ - v1)

{
    "contextElements": [
        {
            "type": "Room",
            "isPattern": "false",
            "id": "Room1",
            "attributes": [
                {
                    "name": "temperature",
                    "type": "float",
                    "value": "39.5"
                }
            ]
        }
    ],
    "updateAction": "UPDATE"
} 

** ПОДПИСКА CYGNUS НА ORION ** выглядит следующим образом:

{
    "entities": [
        {
            "type": "Room",
            "isPattern": "false",
            "id": "Room1"
        }
    ],
    "attributes": [
        "temperature"
    ],
    "reference": "http://cygnus:5050",
    "duration": "P1M",
    "notifyConditions": [
        {
            "type": "ONCHANGE",
            "condValues": [
                "temperature"
            ]
        }
    ],
    "throttling": "PT60S"
}

Мой файл agent.conf в Cygnus это:

# ============================================
# # 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: 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

-------------------------------------------------------------

Для целей тестирования я перешел по ссылке ниже

После настройки агента тестирования на Cygnus:

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)

и теперь,если я выполню этот файл уведомлений.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

1 Ответ

0 голосов
/ 06 июня 2018

Вы можете сделать следующее, чтобы узнать, активируется ли ваша подписка (таким образом, гарантируя, что Orion отправляет уведомления Cygnus):

  • GET /v2/subscriptions, если вы не знаете идентификаторподписка.В этом случае вы получите информацию обо всех подписках, и вам нужно будет найти ту, которая используется для Cygnus.
  • GET /v2/subscriptions/<subscriptionId, если вы знаете идентификатор подписки.

Могут помочь следующие поля в ответе (подробности см. в спецификации NGSIv2 ):

  • status: либо active (для активных подписок), либо inactive(для неактивных подписок) [..].Кроме того, для подписок, испытывающих проблемы с уведомлениями, устанавливается статус failed.Как только уведомления снова начинают работать, статус снова изменяется на active.
  • timesSent (не редактируется, присутствует только в операциях GET): количество уведомлений, отправленных по этой подписке.

  • lastNotification (недоступно для редактирования, присутствует только в операциях GET): отметка времени последнего уведомления в формате ISO8601.

  • lastFailure (недоступно для редактирования, присутствует только в операциях GET): отметка времени последнего сбоя в формате ISO8601.Отсутствует, если в подписке никогда не было проблем с уведомлениями.

  • lastSuccess (недоступно для редактирования, присутствует только в операциях GET): отметка времени в формате ISO8601 для последнего успешного уведомления.Отсутствует, если подписка никогда не имела успешного уведомления.

Так что, если все идет хорошо, timesSent должно отображать каждое обновление, статус не должен быть failed и lastNotification должно быть равно lastSuccess.

...