下午好!
根据exists()
的文档,我创建了两个conf,如下所示:
cygnus_instance_1.conf (编辑:2017/11/23更新)
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://$IP_PUBLIC:1026/v2/subscriptions");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, FALSE);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"description\": \"One subscription to rule them all\",
\"subject\": {
\"entities\": [
{
\"idPattern\": \".*\",
\"type\": \"ExerciseAction\"
}
],
\"condition\": {
\"attrs\": [
\"startTime\"
]
}
},
\"notification\": {
\"http\": {
\"url\": \"http://$IP_PUBLIC:5050/notify\"
},
\"attrs\": [
\"startTime\"
]
},
\"expires\": \"2020-04-05T14:00:00.00Z\"
}");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json"
));
$response = curl_exec($ch);
curl_close($ch);
var_dump($response);
agent_1.conf (编辑:2017/12/1更新)
time=2017-12-01T12:52:50.539Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:52:53.031Z | lvl=INFO | corr=8b61fc74-d696-11e7-a933-fa163ec68c31 | trans=ccb60fea-10f8-46eb-82fa-8864f9352e41 | srv=default | subsrv=/ | comp=cygnus-ngsi | op=getEvents |
msg=com.telefonica.iot.cygnus.handlers.NGSIRestHandler[286] : [NGSIRestHandler] Starting internal transaction (ccb60fea-10f8-46eb-82fa-8864f9352e41)
time=2017-12-01T12:52:53.042Z | lvl=INFO | corr=8b61fc74-d696-11e7-a933-fa163ec68c31 | trans=ccb60fea-10f8-46eb-82fa-8864f9352e41 | srv=default | subsrv=/ | comp=cygnus-ngsi | op=getEvents |
msg=com.telefonica.iot.cygnus.handlers.NGSIRestHandler[304] : [NGSIRestHandler] Received data ({ "subscriptionId" : "5a2150a4d3258a6d7c656d26", "originator" : "localhost", "contextResponses" : [ { "contextElement" : {
"type" : "ExerciseAction", "isPattern" : "false", "id" : "75", "attributes" : [ { "name" : "startTime", "type" : "Text", "value" : "30/11/2017 14:38:40" } ]
}, "statusCode" : { "code" : "200", "reasonPhrase" : "OK" } } ]})
time=2017-12-01T12:52:55.546Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:00.548Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:05.550Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:10.551Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:15.554Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:20.558Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:25.559Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:30.561Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:35.568Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:40.569Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:45.570Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:50.571Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:53:55.574Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:54:00.575Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:54:05.576Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:54:10.580Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
time=2017-12-01T12:54:15.588Z | lvl=ERROR | corr=cdeca432-d695-11e7-9c51-fa163ec68c31 | trans=fe9234ec-055b-483d-876d-e15d442a0efe | srv=default | subsrv=/ | comp=cygnus-ngsi | op=run | msg=org.apache.flume.SinkRunner$PollingRunner[160]
: Unable to deliver event. Exception follows.
java.lang.IllegalStateException: begin() called when transaction is OPEN!
at com.google.common.base.Preconditions.checkState(Preconditions.java:145)
at org.apache.flume.channel.BasicTransactionSemantics.begin(BasicTransactionSemantics.java:131)
at com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:476)
at com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:368)
at org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68)
at org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147)
at java.lang.Thread.run(Thread.java:748)
我之前创建了我的订阅,这样当活动发生变化时,之前的实体就保存在MySQL中。
Icon
更新实体后cygnus.log
react-native
有人可以帮助我并告诉我为什么我的Cygnus和MySQL之间的连接不起作用? 非常感谢你!!!
答案 0 :(得分:1)
根据您的日志,配置中存在错误。这一行:
cygnus-ngsi.sources.http-source.interceptors.gi.type = com.telefonica.iot.cygnus.interceptors.NGSIGroupingInterceptor
必须:
cygnus-ngsi.sources.http-source.interceptors.gi.type = com.telefonica.iot.cygnus.interceptors.NGSIGroupingInterceptor$Builder
此外,您必须在此变量中授予该文件:
cygnus-ngsi.sources.http-source.interceptors.gi.grouping_rules_conf_file = /Applications/apache-flume-1.4.0-bin/conf/grouping_rules.conf
无论如何,这是使用分组拦截的原因,这是一项高级功能(以及不推荐使用的功能;建议使用名称映射)。因此,我建议删除这些行并仅保留时间戳拦截:
cygnus-ngsi.sources.http-source.interceptors = ts
cygnus-ngsi.sources.http-source.interceptors.ts.type = timestamp