201410 2 fiware-orion-contextbroker
Transcript of 201410 2 fiware-orion-contextbroker
![Page 1: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/1.jpg)
Managing Context Information at large scale(Introduction)
Contact twitter @fermingalan @LeandroJGuillen
Contact [email protected]
(Reference Orion Context Broker version: 0.15.0)
![Page 2: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/2.jpg)
Introduction
• Context Management in FIWARE• Orion Context Broker• Creating and pulling data• Pushing data and notifications• Convenience operations
Orion Context Broker
2
![Page 3: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/3.jpg)
Context Management in FIWARE
The value of the attributes that characterize entities relevant to applications
3
API
Bus• Location• No. passengers• Driver• Licence plate
Person• Name-Surname• Birthday• Preferences• Location• ToDo list
Shop• Location• Business name• Franchise• offerings
My Application
Context Information
![Page 4: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/4.jpg)
Context Management in FIWARE
Context information may come from many sources using different interfaces and protocols … but programmers should just care about entities and their attributes …
4
API
A sensor in a pedestrian street
The Public Bus Transport
Management system
A person from his smartphone
It’s too hot!
What’s the current temperature?
Context Information
Context Information
Context Information
![Page 5: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/5.jpg)
Context Management in FIWARE
Get notified when an update on context information takes place
5
Bus = “X”, last_stop = “A”, arrived= “Yes”
push
Notify me when bus “X” arrives at the bus
stop “A” API
![Page 6: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/6.jpg)
Context Management in FIWARE
Acting on devices can be as easy as changing the value of attributes linked to its corresponding entity
6
Street lamp = “lamp1”, status= “on”
Street Lamp lamp1.status “on”
API
![Page 7: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/7.jpg)
Orion Context Broker
• Main functions:– Context availability management (NGSI9)
– Context management (NGSI10)
• HTTP and REST-based– XML payload support
– JSON payload support
• Context in NGSI is based in an entity-attribute model:
7
Attributes• Name• Type• Value
Entity
• EntityId• EntityType
1 n
“has”
![Page 8: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/8.jpg)
Orion Context Broker in a nutshell
8
Orion Context Broker
ContextProducers
ContextConsumers
subscriptions
update
query
notify
notify
update
update
DB
1026
1026
![Page 9: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/9.jpg)
curl <cb_host>:1026/version
<orion> <version>0.14.1</version> <uptime>0 d, 0 h, 0 m, 11 s</uptime> <git_hash>3fdb55b96913b3e4d9f9a344e990164650f69b91</git_hash> <compile_time>Wed Sep 30 15:31:29 CET 2014</compile_time> <compiled_by>fermin</compiled_by> <compiled_in>centollo</compiled_in> </orion>
9
Orion Context Broker – check health
![Page 10: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/10.jpg)
Orion Context Broker - Operations
10
Functions Operations
NGSI9• Register, • Search and• Subscribe for context sources
• registerContext• discoverContextAvailability• subscribeContextAvailability• updateContextAvailabilitySubscription• unsubscribeContextAvailability
NGSI10• Query,• Update and• Subscribe to context elements
• updateContext• queryContext• subscribeContext• updateContextSubscription• unsubscribeContextSubscription
![Page 11: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/11.jpg)
Context Broker operations: create & pull data
• Context Producers publish data/context elements by invoking the updateContext operation on a Context Broker.
• Context Consumers can retrieve data/context elements by invoking the queryContext operation on a Context Broker
11
Context Consumer
queryContext
Context Producer
updateContext
Context Broker
![Page 12: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/12.jpg)
Quick Usage Example: Car Create
POST localhost:1026/NGSI10/updateContext... { "contextElements": [ { "type": "Car", "isPattern": "false", "id": "Car1", "attributes": [ { "name": "speed", "type": "km/h", "value": “98" } ] } ], "updateAction": “APPEND"}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "speed", "type": "km/h", "value": "" } ], "id": "Car1", "isPattern": "false", "type": "Car" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
12
![Page 13: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/13.jpg)
Quick Usage Example: Car UpdateContext (1)
POST localhost:1026/NGSI10/updateContext... { "contextElements": [ { "type": "Car", "isPattern": "false", "id": "Car1", "attributes": [ { "name": "speed", "type": "km/h", "value": "110" } ] } ], "updateAction": "UPDATE"}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "speed", "type": "km/h", "value": "" } ], "id": "Car1", "isPattern": "false", "type": "Car" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
13
![Page 14: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/14.jpg)
Quick Usage Example: Car QueryContext (1)
POST <cb_host>:1026/NGSI10/queryContext... { "entities": [ { "type": "Car", "isPattern": "false", "id": "Car1" } ]}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "speed", "type": "km/h", "value": "110" } ], "id": "Car1", "isPattern": "false", "type": "Car" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
14
![Page 15: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/15.jpg)
Quick Usage Example: Car UpdateContext (2)
POST localhost:1026/NGSI10/updateContext... { "contextElements": [ { "type": "Car", "isPattern": "false", "id": "Car1", "attributes": [ { "name": "speed", "type": "km/h", "value": "115" } ] } ], "updateAction": "UPDATE"}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "speed", "type": "km/h", "value": "" } ], "id": "Car1", "isPattern": "false", "type": "Car" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
15
![Page 16: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/16.jpg)
Quick Usage Example: Car QueryContext (2)
16
POST <cb_host>:1026/NGSI10/queryContext... { "entities": [ { "type": "Car", "isPattern": "false", "id": "Car1" } ]}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "speed", "type": "km/h", "value": "115" } ], "id": "Car1", "isPattern": "false", "type": "Car" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
![Page 17: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/17.jpg)
Quick Usage Example: Room Create (1)
17
POST localhost:1026/NGSI10/updateContext... { "contextElements": [ { "type": "Room", "isPattern": "false", "id": "Room1", "attributes": [ { "name": "temperature", "type": "centigrade", "value": "24" }, { "name": "pressure", "type": "mmHg", "value": "718" }
] } ], "updateAction": "APPEND"}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "centigrade", "value": "" }, { "name": "pressure", "type": "mmHg", "value": "" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
![Page 18: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/18.jpg)
Quick Usage Example: Room UpdateContext (2)
POST localhost:1026/NGSI10/updateContext... { "contextElements": [ { "type": "Room", "isPattern": "false", "id": "Room1", "attributes": [ { "name": "temperature", "type": "centigrade", "value": "25" }, { "name": "pressure", "type": "mmHg", "value": "720" }
] } ], "updateAction": "UPDATE"}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "centigrade", "value": "" }, { "name": "pressure", "type": "mmHg", "value": "" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
18
![Page 19: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/19.jpg)
Quick Usage Example: Room QueryContext (1)
19
POST <cb_host>:1026/NGSI10/queryContext... { "entities": [ { "type": "Room", "isPattern": "false", "id": "Room1" } , "attributes": [ "temperature" ] ]}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "centigrade", "value": "25" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
![Page 20: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/20.jpg)
Quick Usage Example: Room QueryContext (2)
20
POST <cb_host>:1026/NGSI10/queryContext... { "entities": [ { "type": "Room", "isPattern": "false", "id": "Room1" } ]}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "centigrade", "value": "25" }, { "name": "pressure", "type": "mmHg", "value": "720" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
![Page 21: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/21.jpg)
Quick Usage Example: Room Create (2)
21
POST localhost:1026/NGSI10/updateContext... { "contextElements": [ { "type": "Room", "isPattern": "false", "id": "Room2", "attributes": [ { "name": "temperature", "type": "centigrade", "value": "33" }, { "name": "pressure", "type": "mmHg", "value": "722" }
] } ], "updateAction": "APPEND"}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "centigrade", "value": "" }, { "name": "pressure", "type": "mmHg", "value": "" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
![Page 22: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/22.jpg)
Quick Usage Example: Room UpdateContext (2)
POST localhost:1026/NGSI10/updateContext... { "contextElements": [ { "type": "Room", "isPattern": "false", "id": "Room2", "attributes": [ { "name": "temperature", "type": "centigrade", "value": "29" }, { "name": "pressure", "type": "mmHg", "value": "730" }
] } ], "updateAction": "UPDATE"}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "centigrade", "value": "" }, { "name": "pressure", "type": "mmHg", "value": "" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
22
![Page 23: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/23.jpg)
Quick Usage Example: Room QueryContext (3)
23
POST <cb_host>:1026/NGSI10/queryContext... { "entities": [ { "type": "Room", "isPattern": "true", "id": "Room.*" } , "attributes": [ "temperature" ] ]}
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "centigrade", "value": "25" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } }, { "contextElement": { "attributes": [ { "name": "temperature", "type": "centigrade", "value": "29" } ], "id": "Room2", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ]}
![Page 24: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/24.jpg)
Context Broker operations: push data
• Context Consumers can subscribe to receive context information that satisfy certain conditions using the subscribeContext. Such subscriptions may have a duration.
• The Context Broker notifies updates on context information to subscribed Context Consumers by invoking the notifyContext operation they export
24
subscription_id = subscribeContext (consumer, expr, duration)
Context Consumer
notifyContext (subscription_id, data/context)
Context Broker
Application
![Page 25: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/25.jpg)
Quick Usage Example: SubscriptionPOST <cb_host>:1026/NGSI10/subscribeContext…{ "entities": [ { "type": "Room", "isPattern": "false", "id": "Room1" } ], "attributes": [ "temperature" ], "reference": "http://<host>:<port>/publish", "duration": "P1M", "notifyConditions": [ { "type": "ONCHANGE", "condValues": [ "temperature" ] } ], "throttling": "PT5S"}
200 OK... { "subscribeResponse": { "duration": "P1M", "subscriptionId": "51c0ac9ed714fb3b37d7d5a8", "throttling": "PT5S" }}
25
![Page 26: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/26.jpg)
25
19
Quick Usage Example: Notification
26
![Page 27: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/27.jpg)
POST http://<host>:<port>/publish…{ "subscriptionId" : "51c0ac9ed714fb3b37d7d5a8", "originator" : "localhost", "contextResponses" : [ { "contextElement" : { "attributes" : [ { "name" : "temperature", "type" : "centigrade", "value" : "19" } ], "type" : "Room", "isPattern" : "false", "id" : "Room1" }, "statusCode" : { "code" : "200", "reasonPhrase" : "OK" } } ]}
Quick Usage Example: Notification
27
![Page 28: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/28.jpg)
Convenience Operations
• They are equivalent to previous standard operations in functionality
• Avoid the need for POST-ing payloads in many cases or simplifying them considerably
• Simple to write, more REST-like
• They are not a substitute but a complement to standard NGSI operations
• Four examples (there are many others):
– Entities
– Attributes
– Subscriptions
– Types
28
![Page 29: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/29.jpg)
Convenience Operations – Example 1
Entities• GET /v1/contextEntities/{entityID}
• Retrieves an entity• POST /v1/contextEntities/{entityID}
• Creates an entity• PUT /v1/contextEntities/{entityID}
• Updates an entity• DELETE /v1/contextEntities/{entityID}
• Deletes an entity
![Page 30: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/30.jpg)
Convenience Operations – Example 2
Attributes• GET /v1/contextEntities/{entityID}/attributes/{attrID}
• Retrieves an attribute’s value• POST /v1/contextEntities/{entityID}/attributes/{attrID}
• Creates a new attribute for an entity• PUT /v1/contextEntities/{entityID}/attributes/{attrID}
• Updates an attribute’s value• DELETE /v1/contextEntities/{entityID}/attributes/{attrID}
• Deletes an attribute
![Page 31: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/31.jpg)
Convenience Operations – Example 3
Subscriptions• POST /NGSI10/contextSubscriptions
• Creates a subscription• PUT /NGSI10/contextSubscriptions/{subID}
• Updates a subscription• DELETE /NGSI10/contextSubscriptions/{subID}
• Cancel a subscription
![Page 32: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/32.jpg)
Convenience Operations – Example 4
Entity Types• GET /v1/contextTypes
• Retrieve a list of all entity types currently in Orion, including their corresponding attributes
• GET /v1/contextTypes/{typeID}• Retrieve attributes associated to an entity type
PRO TIP
GET /v1/contextTypes?collapse=trueRetrieves a list of all entity types without attribute info
![Page 33: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/33.jpg)
Managing Context Information at large scale
(Advanced Topics)
Contact wwitter @fermingalan @LeandroJGuillen
Contact [email protected]
(Reference Orion Context Broker version: 0.15.0)
![Page 34: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/34.jpg)
Advanced Features
• Pagination• Compound attribute values• Geo-location• Metadata• Registrations & context providers• Multitenancy • Entity service paths
Orion Context Broker
34
![Page 35: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/35.jpg)
• Pagination helps clients organize query and discovery requests with a large number of responses.
• Three URI parameters:– limit
• Number of elements per page (default: 20, max: 1000)
– offset• Number of elements to skip (default: 0)
– details• Returns total elements (default: "off")
Pagination
35
![Page 36: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/36.jpg)
Pagination
• Example, querying the first 100 entries:POST <orion_host>:1026/NGSI10/queryContext?limit=100&details=on
• The first 100 elements are returned, along with the following errorCode in the response:
<errorCode> <code>200</code> <reasonPhrase>OK</reasonPhrase> <details>Count: 322</details></errorCode>
• Now we now there are 322 entities, we can keep querying the broker for them:
– POST <orion_host>:1026/NGSI10/queryContext?offset=100&limit=100– POST <orion_host>:1026/NGSI10/queryContext?offset=200&limit=100– POST <orion_host>:1026/NGSI10/queryContext?offset=300&limit=100
36
![Page 37: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/37.jpg)
Compound Attribute Values
• An attribute can have a structured value. Vectors and key-value maps are supported.
• It maps directly to JSON's objects and arrays.
37
![Page 38: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/38.jpg)
Compound Attribute Values
• Example: we have a car whose four wheels' pressure we want to represent as a compound attribute for a car entity. We would create the car entity like this:
{ "contextElements": [ { "type": "Car", "isPattern": "false", "id": "Car1", "attributes": [ { "name": "tirePressure", "type": "kPa", "value": { "frontRight": "120", "frontLeft": "110", "backRight": "115", "backLeft": "130" } } ] } ], "updateAction": "APPEND"}
38
![Page 39: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/39.jpg)
Metadata
• Users may attach metadata to attributes• Reserved metadatas: ID, Location, creDate and modDate• Examples:
39
…"attributes": [ { "name": "temperature", "type": "centigrade", "value": "26.5", "metadatas": [ { "name": "accuracy", "type": "float", "value": "0.9" } ] } ]…
…"attributes": [ { "name": "temperature", "type": "centigrade", "value": "26.5", "metadatas": [ { "name": "average", "type": "centigrade", "value": "22.4" } ] } ]…
![Page 40: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/40.jpg)
Geo-location
• Entities can have an attribute that specifies its location
– Using a "location" metadata
• Example: create an entity called Madrid
…and create a couple more towns:
• Leganés• Alcobendas
POST <cb_host>:1026/NGSI10/updateContext{ "contextElements": [ { "type": "City", "isPattern": "false", "id": "Madrid", "attributes": [ { "name": "position", "type": "coords", "value": "40.418889, -3.691944", "metadatas": [ { "name": "location", "type": "string", "value": "WSG84" } ] } ] } ], "updateAction": "APPEND"}
40
![Page 41: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/41.jpg)
Geo-location – Circle
41
![Page 42: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/42.jpg)
Geo-location – Circle
13.5 km radius
42
POST <cb_host>:1026/NGSI10/queryContext…{ "entities": [ { "type": "City", "isPattern": "true", "id": ".*" } ], "restriction": { "scopes": [ { "type" : "FIWARE_Location", "value" : { "circle": { "centerLatitude": "40.418889", "centerLongitude": "-3.691944", "radius": "13500" } } } ] }}
![Page 43: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/43.jpg)
Geo-location – Inverse Circle
13.5 km radius
43
POST <cb_host>:1026/NGSI10/queryContext…{ "entities": [ { "type": "City", "isPattern": "true", "id": ".*" } ], "restriction": { "scopes": [ { "type" : "FIWARE_Location", "value" : { "circle": { "centerLatitude": "40.418889", "centerLongitude": "-3.691944", "radius": "13500", "inverted": "true" } } } ] }}
![Page 44: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/44.jpg)
Registration & Context Providers
• Uncached queries and updates
44
Application
ContextBroker ContextProvider
1. registerContext(provider= )
db
2. queryContext(id) 3. queryContext(id)
4. data5. data
ContextConsumer
![Page 45: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/45.jpg)
POST <cb_host>:1026/NGSI9/registerContext…{ "contextRegistrations": [ { "entities": [ { "type": "Car", "isPattern": "false", "id": "Car1" }, "attributes": [ { "name": "speed", "type": "km/h", "isDomain": "false" } ], "providingApplication": "http://contextprovider.com/Cars" } ], "duration": "P1M"}
200 OK... { "duration" : "P1M", "registrationId" : "52a744b011f5816465943d58"}
45
Registration & Context Providers
![Page 46: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/46.jpg)
46
POST <cb_host>:1026/NGSI10/queryContext... { "entities": [ { "type": "Car", "isPattern": "false", "id": "Car1" } ]}
Registration & Context Providers
ContextBroker ContextProvider
db
queryContext(id)
data
200 OK... { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "speed", "type": "km/h", "value": "100" } ], "id": "Car1", "isPattern": "false", "type": "Car" }, "statusCode": { "code": "200", "details": "Redirected to context provider http://contextprovider.com/Cars", "reasonPhrase": "OK" } } ]}
![Page 47: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/47.jpg)
Multitenancy
• Simple multitenant model based on logical database separation.
• It eases tenant-based authorization provided by other components.
• Just use an additional HTTP header called "Fiware-Service", whose value is the tenant name. Example:Fiware-Service: Tenant1
Context Broker
Tenant1
Tenant2
…
47
![Page 48: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/48.jpg)
Entity Service Paths
• A service path is a hierarchical scope assigned to an entity at creation time (with updateContext).
48
![Page 49: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/49.jpg)
Entity Service Paths
• In order to use a service path we put in a new HTTP header called "ServicePath". For example:ServicePath: Madrid/Gardens/ParqueNorte/Parterre1
• Properties:– A query on a service path only searches on the tree down the
specified node. • For example, a query on ParqueNorte for street lights will return all street
lights contained in ParqueNorte, ParqueNorte/Parterre1 and ParqueNorte/Parterre2
ParqueNorte
Parterre2Parterre1
ParqueOesteParqueSur
49
![Page 50: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/50.jpg)
Entity Service Paths
• Properties (continued):– You can OR a query using a comma (,)
operator in the header• For example, to query all street lights that are either
in ParqueSur or in ParqueOeste you would use: ServicePath: Madrid/Gardens/ParqueSur, Madrid/Gardens/ParqueOeste• You can OR up to 10 different scopes.
– Maximum scope levels: 10• Scope1/Scope2/.../Scope10
– You can have the same element IDs in different scopes (be careful with this!)
– You can't change scope once the element is created
– One entity can belong to only one scope
ParqueNorte
Parterre1light1
light1
A B
A or B
50
![Page 51: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/51.jpg)
Thanks!Thanks!
![Page 52: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/52.jpg)
BACKUP SLIDESBackup slides
52
![Page 53: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/53.jpg)
Integration with existing systems
• Context adapters will be developed to interface with existing systems (e.g., municipal services management systems in a smart city) acting as Context Providers, Context Producers, or both
• Some attributes from a given entity may be linked to a Context Provider while other attributes may be linked to Context Producers
53
queryContext (e1, attr1, attr2)
Context Provider
queryContext (e1, attr1)
Context Consumer
updateContext (e1, attr2)
Application
Context BrokerSystem BSystem A
![Page 54: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/54.jpg)
Integration with sensor networks
• The backend IoT Device Management GE enables creation and configuration of NGSI IoT Agents that connect to sensor networks
• Each NGSI IoT Agent can behave as Context Consumers or Context Providers, or both
54
FIWARE Context Broker
IoT Agent-1
IoT Agent-2
IoT Agent-n
IoT Agent
Manager
create/monitor
FIWARE Backend IoT
Device Management
OMA NGSI API (northbound interface)
(southbound interfaces)
MQTTETSI M2M IETF CoAP
![Page 55: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/55.jpg)
55
• Federation of infrastructures (private/public regions)• Automated GE deploymentCloud• Complete Context Management Platform• Integration of Data and Media ContentData• Easy plug&play of devices using multiple protocols• Automated Measurements/Action Context updatesIoT• Visualization of data (operation dashboards)• Publication of data sets/servicesApps• Easy support of UIs with advanced web-based 3D and AR
capabilities• Visual representation of context information.
Web UI
• Advanced networking capabilities (SDN) and Middleware• Interface to robotsI2ND• Security Monitoring• Built-in Identity/Access/Privacy ManagementSecurity
Context Management in FIWARE
![Page 56: 201410 2 fiware-orion-contextbroker](https://reader035.fdocuments.net/reader035/viewer/2022062303/558bd5ffd8b42aa8158b4638/html5/thumbnails/56.jpg)
FI-WARE Context/Data Management Platform
56
Context/Data Management Platform
Applications
OMA NGSI-9/10Processing/Analysis
Algorithms
Gathered data is injected for
processing/analysis
Distributed Context Sources Complex Event Processing
(PROTON)
BigData(COSMOS)
Processed data is injected for
processing/analysis
Data generated either by CEP or BigData is published
Gathered data injected for CEP-like processing
Direct bigdata
injection
Programming of rules