Orion failing to receive context notification from IoTAgent: response NOT OK - fiware-orion

Having a little difficulty understanding what is going wrong with IoTAgent-Orion subscription to publish context information to Orion. Orion service health check OK, but failed to recieve context with response NOT OK code 404. Orion log:
time=Thursday 28 Feb 14:25:57 2019.783Z | lvl=INFO | corr=c3b64466-3b64-11e9-b463-0242ac1d0005 | trans=1551363484-821-00000000032 | from=172.29.0.6 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=logMsg.h[1844]:lmTransactionStart | msg=Starting transaction to http://lightweightm2m-iotagent:4041/publish
time=Thursday 28 Feb 14:25:57 2019.783Z | lvl=INFO | corr=c3b64466-3b64-11e9-b463-0242ac1d0005 | trans=1551363484-821-00000000032 | from=172.29.0.6 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[592]:httpRequestSendWithCurl | msg=Sending message 3 to HTTP server: sending message of 576 bytes to HTTP server
time=Thursday 28 Feb 14:25:57 2019.791Z | lvl=INFO | corr=c3b64466-3b64-11e9-b463-0242ac1d0005 | trans=1551363484-821-00000000032 | from=172.29.0.6 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[612]:httpRequestSendWithCurl | msg=Notification Successfully Sent to http://lightweightm2m-iotagent:4041/publish
time=Thursday 28 Feb 14:25:57 2019.791Z | lvl=WARN | corr=c3b64466-3b64-11e9-b463-0242ac1d0005 | trans=1551363484-821-00000000032 | from=172.29.0.6 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[625]:httpRequestSendWithCurl | msg=Notification response NOT OK, http code: 404
EDIT:
I edited my question again to reproduce the scenario generating the error. Below is the agent log:
time=2019-02-28T15:15:53.810Z | lvl=DEBUG | corr=bd797a30-3b6b-11e9-98a6-0242c0a85005 | trans=b725da6c-8917-4dde-9d29-defa97970b1a | op=IoTAgentNGSI.DomainControl | srv=smartgondor | subsrv=/gardens | msg=response-time: 8 | comp=IoTAgent
time=2019-02-28T15:16:00.398Z | lvl=DEBUG | corr=05d60d9d-dd2e-4d0e-b80f-ad1c384431d7 | trans=05d60d9d-dd2e-4d0e-b80f-ad1c384431d7 | op=IoTAgentNGSI.GenericMiddlewares | srv=n/a | subsrv=n/a | msg=Request for path [/iot/about] from [localhost:4041] | comp=IoTAgent
time=2019-02-28T15:16:00.399Z | lvl=DEBUG | corr=05d60d9d-dd2e-4d0e-b80f-ad1c384431d7 | trans=05d60d9d-dd2e-4d0e-b80f-ad1c384431d7 | op=IoTAgentNGSI.DomainControl | srv=n/a | subsrv=n/a | msg=response-time: 1 | comp=IoTAgent
time=2019-02-28T15:16:13.255Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=LWM2MLib.InformationReporting | srv=n/a | subsrv=n/a | msg=New data on resource /3303/0/5700 in device [1] | comp=IoTAgent
time=2019-02-28T15:16:13.255Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IOTAgent.LWM2MHandlers | srv=n/a | subsrv=n/a | msg=Handling data from device [raspiSensorTV] | comp=IoTAgent
.
.
time=2019-02-28T15:16:13.256Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Looking for group params ["type"] with queryObj {"type":"Device"} | comp=IoTAgent
time=2019-02-28T15:16:13.260Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.MongoDBGroupRegister | srv=n/a | subsrv=n/a | msg=Device group for fields [["type"]] not found: [{"type":"Device"}] | comp=IoTAgent
time=2019-02-28T15:16:13.260Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.NGSIService | srv=n/a | subsrv=n/a | msg=error {"name":"DEVICE_GROUP_NOT_FOUND","message":"Couldn\t find device group","code":404} in get group device | comp=IoTAgent
.
.
time=2019-02-28T15:16:13.261Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.NGSIService | srv=n/a | subsrv=n/a | msg=Updating device value in the Context Broker at [http://orion:1026/v1/updateContext] | comp=IoTAgent
time=2019-02-28T15:16:13.261Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.NGSIService | srv=n/a | subsrv=n/a | msg=Using the following request:
{
"url": "http://orion:1026/v1/updateContext",
"method": "POST",
"headers": {
"fiware-service": "smartGondor",
"fiware-servicepath": "/gardens"
},
"json": {
"contextElements": [
{
"type": "Device",
"isPattern": "false",
"id": "Device:raspiSensorTV",
"attributes": [
{
"name": "Temperature Sensor#0",
"type": "string",
"value": "�\u0016DA�\u0000\u0000",
"metadatas": [
{
"name": "TimeInstant",
"type": "ISO8601",
"value": "2019-02-28T15:16:13.261Z"
}
]
},
{
"name": "TimeInstant",
"type": "ISO8601",
"value": "2019-02-28T15:16:13.261Z"
}
]
}
],
"updateAction": "UPDATE"
}
}
| comp=IoTAgent
time=2019-02-28T15:16:13.274Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.NGSIService | srv=n/a | subsrv=n/a | msg=Received the following request from the CB:
{
"contextResponses": [
{
"contextElement": {
"type": "Device",
"isPattern": "false",
"id": "Device:raspiSensorTV",
"attributes": [
{
"name": "Temperature Sensor#0",
"type": "string",
"value": "",
"metadatas": [
{
"name": "TimeInstant",
"type": "ISO8601",
"value": "2019-02-28T15:16:13.261Z"
}
]
},
{
"name": "TimeInstant",
"type": "ISO8601",
"value": ""
}
]
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
| comp=IoTAgent
time=2019-02-28T15:16:13.274Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IoTAgentNGSI.NGSIService | srv=n/a | subsrv=n/a | msg=Value updated successfully | comp=IoTAgent
time=2019-02-28T15:16:13.274Z | lvl=DEBUG | corr=e4633c8b-1db7-4207-b307-3e419f78223f | trans=e4633c8b-1db7-4207-b307-3e419f78223f | op=IOTAgent.LWM2MHandlers | srv=n/a | subsrv=n/a | msg=Data handled successfully | comp=IoTAgent
time=2019-02-28T15:16:13.282Z | lvl=DEBUG | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=e822ce3a-f639-4257-8179-a40804eb1ba7 | op=IoTAgentNGSI.GenericMiddlewares | srv=smartgondor | subsrv=/gardens | msg=Request for path [/publish] from [lightweightm2m-iotagent:4041] | comp=IoTAgent
time=2019-02-28T15:16:13.282Z | lvl=DEBUG | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=e822ce3a-f639-4257-8179-a40804eb1ba7 | op=IoTAgentNGSI.GenericMiddlewares | srv=smartgondor | subsrv=/gardens | msg=Body:
{
"subscriptionId": "5c77fb29a23ec2205a00b013",
"data": [
{
"id": "Device:raspiSensorTV",
"type": "Device",
"Temperature Sensor#0": {
"type": "string",
"value": "�\u0016DA�\u0000\u0000",
"metadata": {
"TimeInstant": {
"type": "ISO8601",
"value": "2019-02-28T15:16:13.261Z"
}
}
}
}
]
}
| comp=IoTAgent
time=2019-02-28T15:16:13.283Z | lvl=DEBUG | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=e822ce3a-f639-4257-8179-a40804eb1ba7 | op=IoTAgentNGSI.DomainControl | srv=smartgondor | subsrv=/gardens | msg=response-time: 4 | comp=IoTAgent
This scenario was reported in the agent log, while orion log shows the following:
time=Thursday 28 Feb 15:16:13 2019.269Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000018 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=logMsg.h[1844]:lmTransactionStart | msg=Starting transaction from 192.168.80.4:52068/v1/updateContext
time=Thursday 28 Feb 15:16:13 2019.269Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000018 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=rest.cpp[885]:servicePathSplit | msg=Service Path 0: '/gardens'
time=Thursday 28 Feb 15:16:13 2019.271Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000018 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=connectionOperations.cpp[94]:collectionQuery | msg=Database Operation Successful (query: { _id.id: "Device:raspiSensorTV", _id.type: "Device", _id.servicePath: { $in: [ /^/gardens$/ ] } })
time=Thursday 28 Feb 15:16:13 2019.272Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000018 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=connectionOperations.cpp[449]:collectionUpdate | msg=Database Operation Successful (update: <{ _id.id: "Device:raspiSensorTV", _id.type: "Device", _id.servicePath: { $in: [ /^/gardens$/ ] } }, { $set: { attrs.Temperature Sensor#0: { value: "�DA�>)
time=Thursday 28 Feb 15:16:13 2019.273Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000019 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=logMsg.h[1844]:lmTransactionStart | msg=Starting transaction to http://lightweightm2m-iotagent:4041/publish
time=Thursday 28 Feb 15:16:13 2019.273Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000018 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=logMsg.h[1874]:lmTransactionEnd | msg=Transaction ended
time=Thursday 28 Feb 15:16:13 2019.274Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000019 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[592]:httpRequestSendWithCurl | msg=Sending message 2 to HTTP server: sending message of 573 bytes to HTTP server
time=Thursday 28 Feb 15:16:13 2019.284Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000019 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[612]:httpRequestSendWithCurl | msg=Notification Successfully Sent to http://lightweightm2m-iotagent:4041/publish
time=Thursday 28 Feb 15:16:13 2019.284Z | lvl=WARN | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000019 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=httpRequestSend.cpp[625]:httpRequestSendWithCurl | msg=Notification response NOT OK, http code: 404
time=Thursday 28 Feb 15:16:13 2019.285Z | lvl=INFO | corr=c915945a-3b6b-11e9-b854-0242c0a85005 | trans=1551366811-541-00000000019 | from=192.168.80.4 | srv=smartgondor | subsrv=/gardens | comp=Orion | op=logMsg.h[1874]:lmTransactionEnd | msg=Transaction ended
I commit the following IoTAgent-Orion subscrption request:
$curl -iX POST localhost:1026/v2/subscriptions -s -S --header 'Content-Type: application/json' \
--header 'Accept: application/json' --header 'fiware-service: smartGondor' --header 'fiware-servicepath: /gardens' -d'
{
"subject": {
"entities": [
{
"idPattern": ".*",
"type": "Device"
}
],
"condition": {
"attrs": [ "Temperature Sensor#0" ]
}
},
"notification": {
"http": {
"url": "http://lightweightm2m-iotagent:4041/publish"
},
"attrs": [ "Temperature Sensor#0" ]
}
}'

Luckily, it is now working despite this error still appearing. At least it is working, nothing to worry.

Related

Grouping data of multiple rows into groups according to an id in codeigniter

I have a table like this in database
+---+-------------+--------------+
|id | service_name| doc_id |org_id|
+---+-------------+--------------+
| 1 | new service | 12 | 119 |
| | | | |
| 2 | new service | 24 | 119 |
| | | | |
| 3 | old service | 13 | 118 |
| | | | |
| 4 | old service | 14 | 118 |
| | | | |
| 5 | new service | 20 | 119 |
+---+-------------+--------------+
I want to group all the doc_id's according to service_name column
I have tried using
IN my controller
$where_person['org_id'] = $this->post('org_id');
$result_insert = $this->$model_name->fetch_doctor_services($where_person);
In my Model
function fetch_doctor_services($where){
$this->db->select('service_name,doc_id')->from('services');
$this->db->group_by('service_name');
$this->db->where($where);
return $this->db->get()->result();
}
But it does not output data as i desire, by grouping by service_name and all the doc_id's according to that service_name.
where am i going wrong here?
Currently my output is like this.
{ "data":
[ { "service_name": "new service", "doc_id": "12" },
{
"service_name": "old service", "doc_id": "13" }
]
}
You need to use GROUP_CONCAT. See below code on how to use it
$this->db->select('service_name, GROUP_CONCAT( doc_id) ')->from('services');
$this->db->group_by('service_name');
$this->db->where($where);
return $this->db->get()->result();

Get data based on latest date

Based on the dataset below, I'm trying to get the lastest cost based on the latest report date.
For example: When the report date=forecast date (column headers) then pick the values as on that report date which can be achived by this formula
IF [Report Date]=[Forecast Date] THEN [Forecasted Cost] END
but I also want to get the subsequent values as of the lastest report date i.e. 2/15/2019. How do I achieve this?
DESIRED OUTPUT
+------------+-----------+-----------+------------+------------+------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
| | 8/15/2018 | 9/15/2018 | 10/15/2018 | 11/15/2018 | 12/15/2018 | 1/15/2019 | 2/15/2019 | 3/15/2019 | 4/15/2019 | 5/15/2019 | 6/15/2019 | 7/15/2019 | 8/15/2019 |
+------------+-----------+-----------+------------+------------+------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
| Final Cost | 646.00 | 646.00 | 620.00 | 620.00 | 550.00 | 445.00 | 361.00 | 332.50 | 315.40 | 296.40 | 290.70 | 285.00 | 279.30 |
+------------+-----------+-----------+------------+------------+------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
DATASET
+------+-------------+-----------+-----------+------------+------------+------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
| Item | Report Date | 8/15/2018 | 9/15/2018 | 10/15/2018 | 11/15/2018 | 12/15/2018 | 1/15/2019 | 2/15/2019 | 3/15/2019 | 4/15/2019 | 5/15/2019 | 6/15/2019 | 7/15/2019 | 8/15/2019 |
+------+-------------+-----------+-----------+------------+------------+------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
| 4124 | 8/15/2018 | 646.00 | 646.00 | 658.00 | 658.00 | 658.00 | 658.00 | 658.00 | | | | | | |
| 4124 | 9/15/2018 | | 646 | 626 | 626 | 626 | 622 | 622 | 622 | | | | | |
| 4124 | 10/15/2018 | | | 620 | 620 | 620 | 585 | 585 | 585 | 555 | | | | |
| 4124 | 11/15/2018 | | | | 620 | 620 | 610 | 595 | 554.5 | 543.38 | 535.35 | | | |
| 4124 | 12/15/2018 | | | | | 550 | 535 | 505 | 490 | 490 | 490 | 490 | | |
| 4124 | 1/15/2019 | | | | | | 445 | 430 | 420 | 410 | 400 | 390 | 384 | |
| 4124 | 2/15/2019 | | | | | | | 361 | 332.5 | 315.4 | 296.4 | 290.7 | 285 | 279.3 |
+------+-------------+-----------+-----------+------------+------------+------------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+-----------+
First of all, you need to transpose your dataset, i.e. to have 4 columns "Item", "Report Date", "Forecast Date" and "Forecast Cost". Then you create a filter "forecast date >= report date" and show values by forecast date.
Now you will have multiple values for each forecast date. if you only want to get the latest value, then you can use table calculation window_min(date diff).

How to get the last record from multiple records which have the same value simultaneously in a given column mongodb

I have a table called places_log. The schema for places logs is as follows
{
'type': {
'type': 'string',
'required': True,
'allowed': ['in', 'out']
},
'fence_name': {
'type': 'string',
'required': True
},
'time': {
'type': 'datetime',
'required': True
}
}
When a query to get all the documents of this table sorted by fence name and time is made, say the output is as follows
+------------+---------+-----------+
| fence_name | type | time |
+------------+---------+-----------+
| abc | in | 08:30 |
| abc | in | 08:32 |
| abc | out | 09:45 |
| abc | in | 15:18 |
| abc | out | 16:20 |
| abc | out | 16:25 |
| lmn | in | 12:30 |
| pqr | in | 12:40 |
| pqr | out | 13:52 |
| pqr | out | 13:58 |
| xyz | out | 19:43 |
| xyz | out | 19:45 |
+-------------+--------+-----------+
I want a query which will return the following result. For each fence, when there are simultaneous ins, I want the latest in and when there are simultaneous outs, I want the latest out.
+------------+---------+-----------+
| fence_name | type | time |
+------------+---------+-----------+
| abc | in | 08:32 |
| abc | out | 09:45 |
| abc | in | 15:18 |
| abc | out | 16:25 |
| lmn | in | 12:30 |
| pqr | in | 12:40 |
| pqr | out | 13:58 |
| xyz | out | 19:45 |
+-------------+--------+-----------+
Basically there is a feature where the user can create multiple fences on the map we will store the times when the user's vehicle enters or exits the fence. Due to some edge cases, we are getting multiple 'in' events simultaneously without an 'out' event which is not possible. So I am trying to come up with a query where I can only take the last 'in' event (when there are simultaneous ins) and take that time as the time when the vehicle entered the fence.
But the vehicle can enter and exit a fence multiple times. So I have to get all those ins and outs also
Doing an aggregation using group and last will not consider ins and outs which are not simultaneous, for the following aggregation
[
{ "$sort": { "fence_name": 1, "time": 1 } },
{
'$group': {
"_id": {
"fence_name": "$fence_name",
"type": "$type"
},
"time": {
"$last": "$time"
}
}
}
]
We will get a something like this
+------------+---------+-----------+
| fence_name | type | time |
+------------+---------+-----------+
| abc | in | 15:18 |
| abc | out | 16:25 |
| lmn | in | 12:30 |
| pqr | in | 12:40 |
| pqr | out | 13:58 |
| xyz | out | 19:45 |
+-------------+--------+-----------+
Here, I don't get the second time the vehicle entered and exited the fence 'abc'
I want to get multiple ins and outs which are not simultaneous.
And even better if I can get something like this
+------------+---------+-----------+
| fence_name | in | out |
+------------+---------+-----------+
| abc | 08:32 | 09:45 |
| abc | 15:18 | 16:25 |
| lmn | 12:30 | null |
| pqr | 12:40 | 13:58 |
| xyz | null | 19:45 |
+-------------+--------+-----------+

How can I make my dataframe sample in each run using apache spark

I have a peculiar scenario in which the sample obtained in two consecutive samplings are not consistent even when I've provided a seed value. I'm using the following code (Which was an outcome of a discussion here:
var conversionSample = sortedConversionSubset.sample(true, (sampleSize + 0.05), 3*x).limit((conversionCount * sampleSize).toInt)
var nonConversionSample = sortedNonConversionSubset.sample(true, (sampleSize + 0.05), 3*x).limit((nonConversionCount * sampleSize).toInt)
Here
'sampleSize' is a constant fraction value less than 0.8
'x' is a constant int, which represents xth iteration in a for loop
'conversionCount' and 'nonConversionCount' are int values representing number of rows in each subset
Now the observation being that in two successive runs the sample generated is different in both cases which was not the expected behavior.
sortedConversionSubset
+--------------------------------------+----------+
|clientid |Conversion|
+--------------------------------------+----------+
|02438b66-2de4-4765-bae3-de7453647ea7_1|1 |
|203865ed-f02a-4ed9-9098-82691de707a4_0|1 |
|203865ed-f02a-4ed9-9098-82691de707a4_1|1 |
|674e2337-aec5-434e-b56e-8c2efcc42894_1|1 |
|6d6036d3-c161-4f5d-8557-80b85dd87bd9_0|1 |
|6d6036d3-c161-4f5d-8557-80b85dd87bd9_1|1 |
|7797aba3-3eea-4556-856e-753812b4b551_0|1 |
|7797aba3-3eea-4556-856e-753812b4b551_1|1 |
|870ab2a5-0650-42b8-9e6f-bde3859f64fd_0|1 |
|870ab2a5-0650-42b8-9e6f-bde3859f64fd_1|1 |
|9b606693-4ffa-44a5-bd7c-cc6974ce3e83_0|1 |
|be218b72-c664-40cf-adf5-e3519095e941_0|1 |
|e7dc7fd9-32df-46a1-b3bd-793bbda09f6f_0|1 |
|eaf434da-6a8f-4ab0-a744-62bea663ed5e_0|1 |
|eaf434da-6a8f-4ab0-a744-62bea663ed5e_1|1 |
+--------------------------------------+----------+
sortedNonConversionSubset
+--------------------------------------+----------+
|clientid |Conversion|
+--------------------------------------+----------+
|03358d8f-9b9c-4258-9c99-234ab102c29b_1|0 |
|040d213c-e91a-42f4-9bf7-90671670dc17_0|0 |
|04fe5148-1c56-4c88-aed0-1f01220bffd6_0|0 |
|0ed2e621-9ba4-46f0-8793-a84d32538c39_0|0 |
|0f9bcf42-e7fa-49a0-9d75-6c9bbc38b4d5_0|0 |
|108c5478-abc0-44d9-968b-47f81c4f5a37_0|0 |
|129eb883-159d-49be-b8ae-9aa44a3e2919_0|0 |
|13e3d779-026b-4d12-8619-aa5fe6ca99ed_0|0 |
|14497295-eebd-44aa-9f26-fc5e4810fb54_0|0 |
|1855d96d-3647-4c4f-a20f-7e46f7635798_0|0 |
|1911caf0-a470-4898-9b62-57c604422727_0|0 |
|1b91b8dc-09b8-47e2-b892-f5c14b650019_0|0 |
|1dfa820c-77e0-4927-8a39-ecd8e842b09b_0|0 |
|1e48e346-4ada-4a8d-896b-7658cc2499cd_0|0 |
|252be902-4204-40a5-9d3c-dd3a7d0f0355_0|0 |
|2995b49d-525b-43e9-ab36-8b8910a4607c_0|0 |
|2bc06b59-4624-4ddd-87a3-ed04cba88233_0|0 |
|2d4538a5-20e6-4742-ae46-aad0a5ed3fff_0|0 |
|31563716-9380-4662-90e5-7f63a1ab9072_0|0 |
|34442a3e-0437-4c41-86fb-1ac55062993a_0|0 |
|35151629-2f86-4917-90d2-42daa5ae4f5c_0|0 |
|3c37e066-dff5-4bd9-84ab-b9e73f3f3fdd_0|0 |
|3e998096-3a4b-4b57-a1de-69d2dbd19abd_0|0 |
|3f8ace3c-d378-4423-97a0-3d9cf35ba256_0|0 |
|49a0cfb8-490f-4252-84fa-2b9e250e9333_0|0 |
|4c3f11fa-e3ba-4eb1-977a-06f034bf8a54_0|0 |
|4ee484f4-e877-44c3-9390-c4e4072c5dee_0|0 |
|4fa035b3-dcd5-40e1-9107-0a0c943ff597_1|0 |
|529704d2-5a60-4718-a03f-639e040f6634_0|0 |
|560f6978-028b-4a37-9f97-d97e93976bf7_0|0 |
|57b47c74-b071-4278-89c9-f7b4cb1225d1_0|0 |
|58305773-f944-4039-8452-f5eb8d62f0cf_0|0 |
|58dfa9dd-43cf-4eb7-ade6-7235004a9815_0|0 |
|5b146218-9bb6-46f0-8c83-df131d78f591_0|0 |
|5ca3b5bc-35a9-42a5-bd37-a8fc94366dc6_0|0 |
|5d5f2ea0-aed9-4c2d-8c22-68859ec35e8e_0|0 |
|5f9ebf92-3b1b-4628-b949-44a32e6d3659_0|0 |
|64822b8c-009e-48ab-b6ca-1a7ece1106fa_0|0 |
|6b352714-af74-4773-854b-073e644e8684_0|0 |
|6e528e49-472e-48c7-baa9-edc25303e427_0|0 |
|73203f58-8be2-4716-b8f0-79c64400c57b_0|0 |
|741630e0-1c99-497d-a127-5c4c562952c5_0|0 |
|778e3b8a-2ca5-469a-9697-f646962e8308_0|0 |
|8029c542-d933-43fb-b359-f2438dcd5660_0|0 |
|8b06ba24-2af3-4eec-811a-4d1779f37876_0|0 |
|8fb43dff-260d-4ece-85e2-3bc2cb636ac1_0|0 |
|90f8a4cb-1956-43c4-ac7d-8c6514cd023a_0|0 |
|916f2e2a-6135-4004-8d54-d80b822ce394_0|0 |
|968a7ca3-1649-4586-9e60-b7e8565e708a_0|0 |
|a32782cc-8c4c-403b-aa83-09f1cec45fdb_0|0 |
|a63f44d5-a4d5-45a0-8a4b-cebf05df810b_0|0 |
|a6f958bc-e050-4216-b981-d51f1c0ff60d_0|0 |
|a7dba1bb-d7ff-44e6-9c4c-997ae59a2337_1|0 |
|ac33d675-d9cc-43b5-94fb-7d412773db14_0|0 |
|b1227816-9bf2-474f-8e82-5739acf6c895_0|0 |
|b1c27a2e-6efc-4869-880b-9ce0a4962edc_0|0 |
|b4ff6d43-cf0a-4f1d-9431-1edcb8ee1fb6_0|0 |
|b9e477ab-2065-42bb-832b-5d0e98ee05c7_0|0 |
|ba8c4efe-e71c-468c-b1bf-37efff596907_0|0 |
|c21eefc8-43d0-4be0-a252-b9fc4dbb7ad0_0|0 |
|c3785311-87c8-43bc-99a8-01d64f5eaa87_0|0 |
|c543bde7-deb8-4484-b0be-353c44baf6eb_1|0 |
|ca31e550-9d28-4628-bfe8-53648a2007f7_0|0 |
|cbc33697-20cb-4f8b-accd-0a6396a4ea41_0|0 |
|cc7810aa-08fc-44e7-acdc-ac948a28f9b9_0|0 |
|d1efdc7c-afb0-4995-bbbd-a76f731d2492_0|0 |
|d6a4b928-e576-41d7-9628-18709765199d_0|0 |
|d7311ec7-6c50-448d-8a6e-f690c3070d57_1|0 |
|d86b09f9-70a0-4101-a13b-129fe3a37b86_0|0 |
|d911be5b-aceb-45c8-a79e-73ccfa1b96f0_0|0 |
|db0c7b10-80f7-4071-aa53-fe0e2dc5ebce_0|0 |
|dce14c51-fa57-4e98-987d-708e2a9aa293_0|0 |
|dd026fb8-f818-4d1e-aaa4-4c9b3fd24994_0|0 |
|dfa9c55c-1e75-4010-be86-a6b1eb723672_0|0 |
|ea29f600-9e85-40f4-9f88-dcef46beb0c1_0|0 |
|eb5e58fc-eaac-4059-8ebc-1fab1ccf3555_1|0 |
|eb7568ab-83ac-45a7-bf4b-3b048d6c7c53_0|0 |
|f5b1cfc4-e397-4699-adab-0af6ee0e1b76_0|0 |
|facbfc8c-d477-4b27-bf15-52a56c26cbf6_0|0 |
|ffd03bca-ef40-4fa4-913e-73c002f29796_0|0 |
+--------------------------------------+----------+
1st Run Sample
+--------------------------------------+----------+
|clientid |Conversion|
+--------------------------------------+----------+
|203865ed-f02a-4ed9-9098-82691de707a4_1|1 |
|6d6036d3-c161-4f5d-8557-80b85dd87bd9_0|1 |
|6d6036d3-c161-4f5d-8557-80b85dd87bd9_1|1 |
|02438b66-2de4-4765-bae3-de7453647ea7_1|1 |
|7797aba3-3eea-4556-856e-753812b4b551_0|1 |
|870ab2a5-0650-42b8-9e6f-bde3859f64fd_0|1 |
|1dfa820c-77e0-4927-8a39-ecd8e842b09b_0|0 |
|252be902-4204-40a5-9d3c-dd3a7d0f0355_0|0 |
|2995b49d-525b-43e9-ab36-8b8910a4607c_0|0 |
|2bc06b59-4624-4ddd-87a3-ed04cba88233_0|0 |
|31563716-9380-4662-90e5-7f63a1ab9072_0|0 |
|5ca3b5bc-35a9-42a5-bd37-a8fc94366dc6_0|0 |
|5d5f2ea0-aed9-4c2d-8c22-68859ec35e8e_0|0 |
|5f9ebf92-3b1b-4628-b949-44a32e6d3659_0|0 |
|5f9ebf92-3b1b-4628-b949-44a32e6d3659_0|0 |
|5f9ebf92-3b1b-4628-b949-44a32e6d3659_0|0 |
|6b352714-af74-4773-854b-073e644e8684_0|0 |
|6e528e49-472e-48c7-baa9-edc25303e427_0|0 |
|6e528e49-472e-48c7-baa9-edc25303e427_0|0 |
|741630e0-1c99-497d-a127-5c4c562952c5_0|0 |
|03358d8f-9b9c-4258-9c99-234ab102c29b_1|0 |
|040d213c-e91a-42f4-9bf7-90671670dc17_0|0 |
|040d213c-e91a-42f4-9bf7-90671670dc17_0|0 |
|04fe5148-1c56-4c88-aed0-1f01220bffd6_0|0 |
|129eb883-159d-49be-b8ae-9aa44a3e2919_0|0 |
|1855d96d-3647-4c4f-a20f-7e46f7635798_0|0 |
|3c37e066-dff5-4bd9-84ab-b9e73f3f3fdd_0|0 |
|3e998096-3a4b-4b57-a1de-69d2dbd19abd_0|0 |
|3f8ace3c-d378-4423-97a0-3d9cf35ba256_0|0 |
|49a0cfb8-490f-4252-84fa-2b9e250e9333_0|0 |
|4fa035b3-dcd5-40e1-9107-0a0c943ff597_1|0 |
|4fa035b3-dcd5-40e1-9107-0a0c943ff597_1|0 |
|529704d2-5a60-4718-a03f-639e040f6634_0|0 |
|560f6978-028b-4a37-9f97-d97e93976bf7_0|0 |
|560f6978-028b-4a37-9f97-d97e93976bf7_0|0 |
|560f6978-028b-4a37-9f97-d97e93976bf7_0|0 |
|778e3b8a-2ca5-469a-9697-f646962e8308_0|0 |
|8b06ba24-2af3-4eec-811a-4d1779f37876_0|0 |
+--------------------------------------+----------+
2nd Run Sample
+--------------------------------------+----------+
|clientid |Conversion|
+--------------------------------------+----------+
|02438b66-2de4-4765-bae3-de7453647ea7_1|1 |
|7797aba3-3eea-4556-856e-753812b4b551_0|1 |
|870ab2a5-0650-42b8-9e6f-bde3859f64fd_0|1 |
|870ab2a5-0650-42b8-9e6f-bde3859f64fd_1|1 |
|be218b72-c664-40cf-adf5-e3519095e941_0|1 |
|be218b72-c664-40cf-adf5-e3519095e941_0|1 |
|1dfa820c-77e0-4927-8a39-ecd8e842b09b_0|0 |
|252be902-4204-40a5-9d3c-dd3a7d0f0355_0|0 |
|2995b49d-525b-43e9-ab36-8b8910a4607c_0|0 |
|2bc06b59-4624-4ddd-87a3-ed04cba88233_0|0 |
|31563716-9380-4662-90e5-7f63a1ab9072_0|0 |
|5ca3b5bc-35a9-42a5-bd37-a8fc94366dc6_0|0 |
|5d5f2ea0-aed9-4c2d-8c22-68859ec35e8e_0|0 |
|5f9ebf92-3b1b-4628-b949-44a32e6d3659_0|0 |
|5f9ebf92-3b1b-4628-b949-44a32e6d3659_0|0 |
|5f9ebf92-3b1b-4628-b949-44a32e6d3659_0|0 |
|6b352714-af74-4773-854b-073e644e8684_0|0 |
|6e528e49-472e-48c7-baa9-edc25303e427_0|0 |
|6e528e49-472e-48c7-baa9-edc25303e427_0|0 |
|741630e0-1c99-497d-a127-5c4c562952c5_0|0 |
|03358d8f-9b9c-4258-9c99-234ab102c29b_1|0 |
|040d213c-e91a-42f4-9bf7-90671670dc17_0|0 |
|040d213c-e91a-42f4-9bf7-90671670dc17_0|0 |
|04fe5148-1c56-4c88-aed0-1f01220bffd6_0|0 |
|129eb883-159d-49be-b8ae-9aa44a3e2919_0|0 |
|1855d96d-3647-4c4f-a20f-7e46f7635798_0|0 |
|3c37e066-dff5-4bd9-84ab-b9e73f3f3fdd_0|0 |
|3e998096-3a4b-4b57-a1de-69d2dbd19abd_0|0 |
|3f8ace3c-d378-4423-97a0-3d9cf35ba256_0|0 |
|49a0cfb8-490f-4252-84fa-2b9e250e9333_0|0 |
|4fa035b3-dcd5-40e1-9107-0a0c943ff597_1|0 |
|4fa035b3-dcd5-40e1-9107-0a0c943ff597_1|0 |
|529704d2-5a60-4718-a03f-639e040f6634_0|0 |
|560f6978-028b-4a37-9f97-d97e93976bf7_0|0 |
|560f6978-028b-4a37-9f97-d97e93976bf7_0|0 |
|560f6978-028b-4a37-9f97-d97e93976bf7_0|0 |
|778e3b8a-2ca5-469a-9697-f646962e8308_0|0 |
|8b06ba24-2af3-4eec-811a-4d1779f37876_0|0 |
+--------------------------------------+----------+
The two samples being different could be a road blocker for me and just want to check how I could make these consistent

Integration orion-cygnus-cartodb - No data stored on cartodb

I'm integrating orion(1.5.0)-cygnus(1.5.0)-cartodb (using carto.com endpoint).
The performed steps are:
Create an entity on orion
Create a v2/subscriptions on orion in order to notify cygnus when an attribute changes using the Orion NGSIv2 subscription that notifies cygnus in NGSIv1
Cygnus uses the channels cartodb-channel ckan-channel in order to store data on ckan and cartodb:
cygnus-ngsi.sinks = cartodb-sink ckan-sink
cygnus-ngsi.channels = cartodb-channel ckan-channel
In case of ckan the process ends OK.
In case of cartodb the process returns RESPONSE /notify 200 but no data is stored on cartodb, the process seems to stop on cartodb-sink processing.
Here the log:
time=2016-11-11T14:28:55.188Z | lvl=DEBUG | corr=2cddd09c-a81b-11e6-ba15-fa163e00324f | trans=f0966198-d439-4351-9bd0-ecabc3c2b762 | srv=parking | subsrv=/car | comp=cygnus-ngsi | op=intercept | msg=com.telefonica.iot.cygnus.interceptors.NGSIGroupingInterceptor[158] : Event put in the channel, id=1766793715
time=2016-11-11T14:28:55.188Z | lvl=DEBUG | corr=2cddd09c-a81b-11e6-ba15-fa163e00324f | trans=f0966198-d439-4351-9bd0-ecabc3c2b762 | srv=parking | subsrv=/car | comp=cygnus-ngsi | op=processNewBatches | msg=com.telefonica.iot.cygnus.sinks.NGSISink[512] : Event got from the channel (id=1766793715, headers=
{notified-entities=testparking_parking, timestamp=1478874535186, fiware-correlator=2cddd09c-a81b-11e6-ba15-fa163e00324f, grouped-servicepaths=/car, fiware-service=parking, fiware-servicepath=/car, transaction-id=f0966198-d439-4351-9bd0-ecabc3c2b762, grouped-entities=testparking_parking}
, bodyLength=454)
time=2016-11-11T14:28:55.189Z | lvl=DEBUG | corr=2cddd09c-a81b-11e6-ba15-fa163e00324f | trans=f0966198-d439-4351-9bd0-ecabc3c2b762 | srv=parking | subsrv=/car | comp=cygnus-ngsi | op=processNewBatches | msg=com.telefonica.iot.cygnus.sinks.NGSISink[543] : Batch completed, persisting it
time=2016-11-11T14:28:55.189Z | lvl=DEBUG | corr=2cddd09c-a81b-11e6-ba15-fa163e00324f | trans=f0966198-d439-4351-9bd0-ecabc3c2b762 | srv=parking | subsrv=/car | comp=cygnus-ngsi | op=persistBatch | msg=com.telefonica.iot.cygnus.sinks.NGSICartoDBSink[285] : [cartodb-sink] Processing sub-batch regarding the parking_/car_testparking_parking destination
time=2016-11-11T14:28:55.190Z | lvl=DEBUG | corr=2cddd09c-a81b-11e6-ba15-fa163e00324f | trans=f0966198-d439-4351-9bd0-ecabc3c2b762 | srv=parking | subsrv=/car | comp=cygnus-ngsi | op=aggregate | msg=com.telefonica.iot.cygnus.sinks.NGSICartoDBSink$CartoDBAggregator[456] : [cartodb-sink] Processing context element (id=testparking, type=parking)
time=2016-11-11T14:28:55.190Z | lvl=DEBUG | corr=2cddd09c-a81b-11e6-ba15-fa163e00324f | trans=f0966198-d439-4351-9bd0-ecabc3c2b762 | srv=parking | subsrv=/car | comp=cygnus-ngsi | op=aggregate | msg=com.telefonica.iot.cygnus.sinks.NGSICartoDBSink$CartoDBAggregator[478] : [cartodb-sink] Processing context attribute (name=full, type=number)
time=2016-11-11T14:28:55.190Z | lvl=DEBUG | corr=2cddd09c-a81b-11e6-ba15-fa163e00324f | trans=f0966198-d439-4351-9bd0-ecabc3c2b762 | srv=parking | subsrv=/car | comp=cygnus-ngsi | op=processNewBatches | msg=com.telefonica.iot.cygnus.sinks.NGSISink[557] : [java.util.ArrayList.rangeCheck(Unknown Source), java.util.ArrayList.get(Unknown Source), com.telefonica.iot.cygnus.sinks.NGSICartoDBSink$CartoDBAggregator.getRows(NGSICartoDBSink.java:358), com.telefonica.iot.cygnus.sinks.NGSICartoDBSink.persistRawAggregation(NGSICartoDBSink.java:499), com.telefonica.iot.cygnus.sinks.NGSICartoDBSink.persistBatch(NGSICartoDBSink.java:310), com.telefonica.iot.cygnus.sinks.NGSISink.processNewBatches(NGSISink.java:544), com.telefonica.iot.cygnus.sinks.NGSISink.process(NGSISink.java:330), org.apache.flume.sink.DefaultSinkProcessor.process(DefaultSinkProcessor.java:68), org.apache.flume.SinkRunner$PollingRunner.run(SinkRunner.java:147), java.lang.Thread.run(Unknown Source)]
time=2016-11-11T14:28:55.190Z | lvl=WARN | corr=2cddd09c-a81b-11e6-ba15-fa163e00324f | trans=f0966198-d439-4351-9bd0-ecabc3c2b762 | srv=parking | subsrv=/car | comp=cygnus-ngsi | op=processNewBatches | msg=com.telefonica.iot.cygnus.sinks.NGSISink[575] : Index: 0, Size: 0
time=2016-11-11T14:28:55.191Z | lvl=DEBUG | corr=2cddd09c-a81b-11e6-ba15-fa163e00324f | trans=f0966198-d439-4351-9bd0-ecabc3c2b762 | srv=parking | subsrv=/car | comp=cygnus-ngsi | op=debug | msg=org.mortbay.log.Slf4jLog[40] : RESPONSE /notify 200
time=2016-11-11T14:28:55.191Z | lvl=DEBUG | corr=2cddd09c-a81b-11e6-ba15-fa163e00324f | trans=f0966198-d439-4351-9bd0-ecabc3c2b762 | srv=parking | subsrv=/car | comp=cygnus-ngsi | op=debug | msg=org.mortbay.log.Slf4jLog[40] : EOF
There is no geolocation-related attribute in your entity. Carto is a geolocation DB, thus, an attribute follwing any of these options must be sent in order the insertion has sense:
geo:point, in this case the geolocated attribute is about a single point.
geo:json, despite a GeoJson can describe any geometry, from a simple point to a complex polygon, it must represent a single point.
location metadata, in this case the geolocated attribute is about a single point.
EDIT 1:
I'll add a complete example:
Cygnus configuration:
cygnus-ngsi.sources = http-source
cygnus-ngsi.sinks = raw-sink rawsnapshot-sink distance-sink
cygnus-ngsi.channels = raw-channel rawsnapshot-channel distance-channel
cygnus-ngsi.sources.http-source.channels = raw-channel rawsnapshot-channel distance-channel
cygnus-ngsi.sources.http-source.type = org.apache.flume.source.http.HTTPSource
cygnus-ngsi.sources.http-source.port = 5050
cygnus-ngsi.sources.http-source.handler = com.telefonica.iot.cygnus.handlers.NGSIRestHandler
cygnus-ngsi.sources.http-source.handler.notification_target = /notify
cygnus-ngsi.sources.http-source.handler.default_service = default
cygnus-ngsi.sources.http-source.handler.default_service_path = /
cygnus-ngsi.sources.http-source.interceptors = ts gi
cygnus-ngsi.sources.http-source.interceptors.ts.type = timestamp
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 = /path/to/grouping_rules.conf
cygnus-ngsi.sources.http-source.interceptors.gi.enable_new_encoding = false
cygnus-ngsi.sinks.raw-sink.channel = raw-channel
cygnus-ngsi.sinks.raw-sink.type = com.telefonica.iot.cygnus.sinks.NGSICartoDBSink
cygnus-ngsi.sinks.raw-sink.enable_grouping = false
cygnus-ngsi.sinks.raw-sink.keys_conf_file = /path/to/cartodb_keys.conf
cygnus-ngsi.sinks.raw-sink.flip_coordinates = false
cygnus-ngsi.sinks.raw-sink.enable_raw = true
cygnus-ngsi.sinks.raw-sink.enable_distance = false
cygnus-ngsi.sinks.raw-sink.enable_raw_snapshot = false
cygnus-ngsi.sinks.raw-sink.data_model = dm-by-entity
cygnus-ngsi.sinks.raw-sink.batch_size = 50
cygnus-ngsi.sinks.raw-sink.batch_timeout = 5
cygnus-ngsi.sinks.raw-sink.batch_ttl = 0
cygnus-ngsi.sinks.rawsnapshot-sink.channel = rawsnapshot-channel
cygnus-ngsi.sinks.rawsnapshot-sink.type = com.telefonica.iot.cygnus.sinks.NGSICartoDBSink
cygnus-ngsi.sinks.rawsnapshot-sink.enable_grouping = false
cygnus-ngsi.sinks.rawsnapshot-sink.keys_conf_file = /path/to/cartodb_keys.conf
cygnus-ngsi.sinks.rawsnapshot-sink.flip_coordinates = false
cygnus-ngsi.sinks.rawsnapshot-sink.enable_raw = false
cygnus-ngsi.sinks.rawsnapshot-sink.enable_distance = false
cygnus-ngsi.sinks.rawsnapshot-sink.enable_raw_snapshot = true
cygnus-ngsi.sinks.rawsnapshot-sink.data_model = dm-by-entity
cygnus-ngsi.sinks.rawsnapshot-sink.batch_size = 50
cygnus-ngsi.sinks.rawsnapshot-sink.batch_timeout = 5
cygnus-ngsi.sinks.rawsnapshot-sink.batch_ttl = 0
cygnus-ngsi.sinks.distance-sink.channel = distance-channel
cygnus-ngsi.sinks.distance-sink.type = com.telefonica.iot.cygnus.sinks.NGSICartoDBSink
cygnus-ngsi.sinks.distance-sink.enable_grouping = false
cygnus-ngsi.sinks.distance-sink.keys_conf_file = /path/to/cartodb_keys.conf
cygnus-ngsi.sinks.distance-sink.flip_coordinates = false
cygnus-ngsi.sinks.distance-sink.enable_raw = false
cygnus-ngsi.sinks.distance-sink.enable_distance = true
cygnus-ngsi.sinks.distance-sink.enable_raw_snapshot = false
cygnus-ngsi.sinks.distance-sink.data_model = dm-by-entity
cygnus-ngsi.sinks.distance-sink.batch_size = 50
cygnus-ngsi.sinks.distance-sink.batch_timeout = 5
cygnus-ngsi.sinks.distance-sink.batch_ttl = 0
cygnus-ngsi.channels.raw-channel.type = com.telefonica.iot.cygnus.channels.CygnusMemoryChannel
cygnus-ngsi.channels.raw-channel.capacity = 10000
cygnus-ngsi.channels.raw-channel.transactionCapacity = 1000
cygnus-ngsi.channels.rawsnapshot-channel.type = com.telefonica.iot.cygnus.channels.CygnusMemoryChannel
cygnus-ngsi.channels.rawsnapshot-channel.capacity = 10000
cygnus-ngsi.channels.rawsnapshot-channel.transactionCapacity = 1000
cygnus-ngsi.channels.distance-channel.type = com.telefonica.iot.cygnus.channels.CygnusMemoryChannel
cygnus-ngsi.channels.distance-channel.capacity = 10000
cygnus-ngsi.channels.distance-channel.transactionCapacity = 1000
Notification script (this is just to emulate an Orion's real notification):
#!/bin/sh
URL=$1
if [ "$2" != "" ]
then
SERVICE=$2
else
SERVICE=default
fi
if [ "$3" != "" ]
then
SERVICE_PATH=$3
else
SERVICE_PATH=/
fi
curl $URL -v -s -S --header 'Content-Type: application/json; charset=utf-8' --header 'Accept: application/json' --header 'User-Agent: orion/0.10.0' --header "Fiware-Service: $SERVICE" --header "Fiware-ServicePath: $SERVICE_PATH" -d #- <<EOF
{
"subscriptionId" : "51c0ac9ed714fb3b37d7d5a8",
"originator" : "localhost",
"contextResponses" : [
{
"contextElement" : {
"attributes" : [
{
"name" : "speed",
"type" : "float",
"value" : "$6"
},
{
"name" : "the_geom",
"type" : "geometry",
"value" : "$4, $5",
"metadatas": [
{
"name": "location",
"type": "string",
"value": "WGS84"
}
]
}
],
"type" : "car",
"isPattern" : "false",
"id" : "car1"
},
"statusCode" : {
"code" : "200",
"reasonPhrase" : "OK"
}
}
]
}
EOF
Notification sending:
$ ./notification.sh http://localhost:5050/notify mycartoid /traffic 40.361 -3.4099 78
* Trying ::1...
* Connected to localhost (::1) port 5050 (#0)
> POST /notify HTTP/1.1
> Host: localhost:5050
> Content-Type: application/json; charset=utf-8
> Accept: application/json
> User-Agent: orion/0.10.0
> Fiware-Service: mycartoid
> Fiware-ServicePath: /traffic
> Content-Length: 741
>
* upload completely sent off: 741 out of 741 bytes
< HTTP/1.1 200 OK
< Transfer-Encoding: chunked
< Server: Jetty(6.1.26)
<
* Connection #0 to host localhost left intact
Cygnus logs:
time=2016-11-29T08:49:10.033UTC | lvl=INFO | corr=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | trans=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | srv=mycartoid | subsrv=/traffic | comp=cygnus-ngsi | op=getEvents | msg=com.telefonica.iot.cygnus.handlers.NGSIRestHandler[282] : [NGSIRestHandler] Starting internal transaction (ebbc3df9-b8e0-4ff1-9980-75c69ca272c9)
time=2016-11-29T08:49:10.034UTC | lvl=INFO | corr=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | trans=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | srv=mycartoid | subsrv=/traffic | comp=cygnus-ngsi | op=getEvents | msg=com.telefonica.iot.cygnus.handlers.NGSIRestHandler[299] : [NGSIRestHandler] Received data ({ "subscriptionId" : "51c0ac9ed714fb3b37d7d5a8", "originator" : "localhost", "contextResponses" : [ { "contextElement" : { "attributes" : [ { "name" : "speed", "type" : "float", "value" : "78" }, { "name" : "the_geom", "type" : "geometry", "value" : "40.361, -3.4099", "metadatas": [ { "name": "location", "type": "string", "value": "WGS84" } ] } ], "type" : "car", "isPattern" : "false", "id" : "car1" }, "statusCode" : { "code" : "200", "reasonPhrase" : "OK" } } ]})
time=2016-11-29T08:49:14.110UTC | lvl=INFO | corr=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | trans=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | srv=mycartoid | subsrv=/traffic | comp=cygnus-ngsi | op=rawUpdateEvent | msg=com.telefonica.iot.cygnus.sinks.NGSICartoDBSink[748] : [rawsnapshot-sink] Updating data at NGSICartoDBSink. Schema (mycartoid), Table (x002ftrafficxffffrawsnapshot), Sets (speed='78',speed_md='[]',the_geom=ST_SetSRID(ST_MakePoint(40.361,-3.4099), 4326)), Where (fiwareServicePath='/traffic' AND entityId='car1' AND entityType='car')
time=2016-11-29T08:49:14.111UTC | lvl=INFO | corr=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | trans=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | srv=mycartoid | subsrv=/traffic | comp=cygnus-ngsi | op=persistRawAggregation | msg=com.telefonica.iot.cygnus.sinks.NGSICartoDBSink[553] : [raw-sink] Persisting data at NGSICartoDBSink. Schema (mycartoid), Table (x002ftrafficxffffcar1xffffcar), Data (('2016-11-29T08:49:10.99Z','/traffic','car1','car',ST_SetSRID(ST_MakePoint(40.361,-3.4099), 4326),'78','[]'))
time=2016-11-29T08:49:15.243UTC | lvl=INFO | corr=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | trans=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | srv=mycartoid | subsrv=/traffic | comp=cygnus-ngsi | op=processNewBatches | msg=com.telefonica.iot.cygnus.sinks.NGSISink[514] : Finishing internal transaction (ebbc3df9-b8e0-4ff1-9980-75c69ca272c9)
time=2016-11-29T08:49:15.243UTC | lvl=INFO | corr=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | trans=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | srv=mycartoid | subsrv=/traffic | comp=cygnus-ngsi | op=persistDistanceEvent | msg=com.telefonica.iot.cygnus.sinks.NGSICartoDBSink[678] : [distance-sink] Persisting data at NGSICartoDBSink. Schema (mycartoid), Table (x002ftrafficxffffcar1xffffcarxffffdistance), Data ((1480409350099,'/traffic','car1','car',(SELECT point FROM geom),(SELECT stage_distance FROM calcs),(SELECT stage_time FROM calcs),(SELECT stage_speed FROM speed),(SELECT sum_dist FROM inserts),(SELECT sum_time FROM inserts),(SELECT sum_speed FROM inserts),(SELECT sum2_dist FROM inserts),(SELECT sum2_time FROM inserts),(SELECT sum2_speed FROM inserts),(SELECT max_distance FROM inserts),(SELECT min_distance FROM inserts),(SELECT max_time FROM inserts),(SELECT min_time FROM inserts),(SELECT max_speed FROM inserts),(SELECT min_speed FROM inserts),(SELECT num_samples FROM inserts)))
time=2016-11-29T08:49:15.243UTC | lvl=INFO | corr=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | trans=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | srv=mycartoid | subsrv=/traffic | comp=cygnus-ngsi | op=processNewBatches | msg=com.telefonica.iot.cygnus.sinks.NGSISink[514] : Finishing internal transaction (ebbc3df9-b8e0-4ff1-9980-75c69ca272c9)
time=2016-11-29T08:49:15.475UTC | lvl=INFO | corr=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | trans=ebbc3df9-b8e0-4ff1-9980-75c69ca272c9 | srv=mycartoid | subsrv=/traffic | comp=cygnus-ngsi | op=processNewBatches | msg=com.telefonica.iot.cygnus.sinks.NGSISink[514] : Finishing internal transaction (ebbc3df9-b8e0-4ff1-9980-75c69ca272c9)
Querying Carto (raw historic and distance historic):
$ curl -G "https://mycartoid.cartodb.com/api/v2/sql?api_key=xxx" --data-urlencode "q=SELECT * FROM 4wheels_car1_car"
{"rows":[
{
"cartodb_id":1,
"the_geom":"0101000020E61000006891ED7C3F350BC0D7A3703D0A374440",
"the_geom_webmercator":"0101000020110F000060EF4D5A961B17C1A59940B...",
"recvtime":"2016-11-28T08:29:35.44Z”,"fiwareservicepath":"/4wheels",
"entityid":"car1”,"entitytype":"car”,"speed":112.9,"speed_md":"[]"
},
{
"cartodb_id":2,
"the_geom":"0101000020E61000009EEFA7C64B370BC03108AC1C5A344440",
"the_geom_webmercator":"0101000020110F0000A58776A1531D17C1CBEB3D11...",
"recvtime":"2016-11-28T08:30:35.977Z","fiwareservicepath":”/4wheels",
"entityid":"car1","entitytype":"car","speed":95,"speed_md":"[]"
},
{
...
}]
}
$ curl -G "https://mycartoid.cartodb.com/api/v2/sql?api_key=xxx" --data-urlencode "q=SELECT * FROM 4wheels_car1_car_distance"
{"rows":[
{
"cartodb_id":1,
"the_geom":"0101000020E610000080B74082E2470BC05839B4C8762E4440",
"the_geom_webmercator":"0101000020110F0000F9F1D8616A2B17C18CA42D61...",
"recvtimems":1480342611051,"fiwareservicepath":”/4wheels",
"entityid":"car1","entitytype":"car","stagedistance":0,
"stagetime":0,"stagespeed":0,"sumdistance":0,"sumtime":0,
"sumspeed":0,"sum2distance":0,"sum2time":0,"sum2speed":0,
"maxdistance":1.4e-45,"mindistance":3.4028235e+38,"maxtime":1.4e-45,
"mintime":3.4028235e+38,"maxspeed":1.4e-45,"minspeed":3.4028235e+38,
"numsamples":1
},
{
"cartodb_id":2,
"the_geom":"0101000020E61000000F0BB5A679470BC091ED7C3F352E4440",
"the_geom_webmercator":"0101000020110F000051A09D53112B17C17D410E55...",
"recvtimems":1480342698000,"fiwareservicepath":”/4wheels",
"entityid":"car1","entitytype":"car","stagedistance":222.732003988,
"stagetime":86949,"stagespeed":0.0025616396276898,
"sumdistance":222.732003988,"sumtime":86949,
"sumspeed":0.0025616396276898,"sum2distance":49609.5456005104,
"sum2time":7560128601,"sum2speed":0.00000656199758215071,
"maxdistance":222.732003988,"mindistance":222.732003988,
"maxtime":86949,"mintime":86949,"maxspeed":0.0025616396276898,
"minspeed":0.0025616396276898,"numsamples":2
},
{
...
}]
}