This presentation describes how context management is implemented in FIWARE platform, base don Orion Context Broker GEri. Both basic usage of Context Broker and advanced topics are included.
HáťC TáťT TIáşžNG ANH 11 THEO CHĆŻĆ NG TRĂNH GLOBAL SUCCESS ÄĂP ĂN CHI TIáşžT - CẢ NÄ...
Â
FIWARE: Managing Context Information at large scale
1. Managing Context Information at
Large Scale: Introduction
FermĂn GalĂĄn MĂĄrquez - fermin.galanmarquez@telefonica.com
Ken Gunnar Zangelin - kengunnar.zangelin@telefonica.com
(Reference Orion Context Broker version: 1.7.0)
2. ⢠Context Management in FIWARE
⢠Orion Context Broker
⢠Creating and pulling data
⢠Pushing data and notifications
⢠Batch operations
2
Introduction
3. Being âSmartâ requires first being âAwareâ
Boiler
⢠Manufacturer
⢠Last revision
⢠Product id
⢠temperature
Users
⢠Name-Surname
⢠Birthday
⢠Preferences
⢠Location
Flowerpot
⢠Humidity
⢠Watering plan
Context Information
Application
3
⢠Implementing a Smart Application requires gathering and
managing context information, referring to values of
attributes characterizing relevant entities
⢠There are many application domains where management of
context info is relevant: smart home, smart agrifood, smart
industry, smart logistics, smart cities
standard API
4. Being âSmartâ requires first being âAwareâ
4
⢠Implementing a Smart Application requires gathering and
managing context information, referring to values of
attributes characterizing relevant entities
⢠There are many application domains where management of
context info is relevant: smart home, smart agrifood, smart
industry, smart logistics, smart cities
Ship
⢠Company
⢠Speed
⢠Location
⢠âŚ
Truck
⢠Driver
⢠Location
⢠âŚ
Container
⢠Dimension
⢠Temperature
⢠âŚ
Context Information
Application
standard API
5. Being âSmartâ requires first being âAwareâ
⢠Implementing a Smart Application requires gathering and
managing context information, referring to values of
attributes characterizing relevant entities
⢠There are many application domains where management of
context info is relevant: smart home, smart agrifood, smart
industry, smart logistics, smart cities
Bus
⢠Location
⢠No. passengers
⢠Driver
⢠Licence plate
Citizen
⢠Name-Surname
⢠Birthday
⢠Preferences
⢠Location
Shop
⢠Location
⢠Business name
⢠Franchise
⢠offerings
Context Information
Application
5
standard API
6. Context Information Management in Smart Cities
⢠Systems dealing with management of city services or third-
party apps (subject to access control policies) can consume
and produce context info
⢠Overall city governance can rely on context information
available (real-time and historic) to monitor KPIs and run
BigData analysis
6
City Services
Bus
⢠Location
⢠No. passengers
⢠Driver
⢠Licence plate
Citizen
⢠Name-Surname
⢠Birthday
⢠Preferences
⢠Location
Shop
⢠Location
⢠Business name
⢠Franchise
⢠offerings
Context Information
City Governance System
City Services
Third-party Apps
7. Different sources of context need to be handle
⢠Context information may come from many sources:
â Existing systems
â Users, through mobile apps
â Sensor networks
⢠Source of info for a given entity may vary over time
Place = âXâ, temperature = 30Âş
Whatâs the current temperature in place âXâ?
A sensor in a
pedestrian street
The Public Bus Transport
Management systemA person from his smartphone
Itâs too hot!
7
standard API
8. Different sources of context need to be handle
⢠Context information may come from many sources:
â Existing systems
â Users, through mobile apps
â Sensor networks
⢠Source of info for a given entity may vary over time
8
Street = âXâ, traffic = high
Whatâs the current traffic in
street âXâ?
Standard API
A sensor in a pedestrian street
The Public Bus Transport
Management system Citizenâs car app or
smartphone
Notify me the changes of
traffic in street âXâ
9. A non-intrusive approach is required
⢠Capable to integrate with existing or future systems without impact
in their architectures, but bringing a common context information
hub
⢠Info about attributes of one entity may come from different
systems, which work either as Context Producers or Context
Providers
Application/Service
Standard API
System A System B
Context Producer Context Provider
attribute âlocationâ attribute âdriverâ
9
10. Context Management in FIWARE
⢠The FIWARE Context Broker GE implements the NGSI API: a
simple yet powerful standard API for managing Context
information complying with the requirements of a smart
enabled system
⢠The FIWARE NGSI API is Restful: any web/backend
programmer gets quickly used to it
Application/Service
Context Broker
NGSI API
Boiler
⢠Manufacturer
⢠Last revision
⢠Product id
⢠temperature
Users
⢠Name-Surname
⢠Birthday
⢠Preferences
⢠Location
Flowerpot
⢠Humidity
⢠Watering plan
10
11. FIWARE NGSI: âThe SNMP for IoTâ
⢠Capturing data from, or Acting upon, IoT devices becomes
as easy as to read/change the value of attributes linked to
context entities using a Context Broker
Context Broker
NGSI APINGSI API
GET /v2/entities/lamp1/attrs/presenceSensor
PUT /v2/entities/lamp1/attrs/status/value
âlight onâ
Setting up the value of attribute
âstatusâ to âlight onâ triggers
execution of a function in the IoT
device that switches the lamp on
Issuing a get operation on the
âpresenceSensorâ attribute
enables the application to get
info about presence of people
near the lamp
11
12. Connecting to the Internet of Things
⢠Capturing data from, or Acting upon, IoT devices becomes
as easy as to read/change the value of attributes linked to
context entities using a Context Broker
Context Broker
GET /v2/entities/lamp1/attrs/humidity
PUT /v2/entities/lamp1/attrs/status/value
âwateringâ
Setting up the value of attribute
âstatusâ to âwateringâ triggers
execution of a function in the IoT
device that waters the plant
Issuing a get operation on the
âhumidityâ attribute enables the
application to find out whether
the plant has to be watered
12
NGSI APINGSI API
13. ⢠Main functions:
â Context management
â Context availability management (advanced topic) (not yet in NGSIv2)
⢠HTTP and REST-based
â JSON payload support
⢠Context in NGSI is based in an entity-attribute model:
Attributes
⢠Name
⢠Type
⢠Value
Entity
⢠EntityId
⢠EntityType
1 n
âhasâ
13
Orion Context Broker
14. ⢠NGSIv1
â Original NGSI RESTful binding of OMA-NGSI
â Implemented in 2013
â Uses the /v1 prefix in resource URL
⢠NGSIv2
â A revamped, simplified binding of OMA-NGSI
⢠Simple things must be easy
⢠Complex things should be possible
⢠Agile, implementation-driven approach
⢠Make it as developer-friendly as possible (RESTful, JSON, âŚ)
â Enhanced functionality compared with NGSIv1 (eg. filtering)
â Stable, ready for production, version already available
⢠Current NGSIv2 version is Release Candidate 2016.10 http://telefonicaid.github.io/fiware-
orion/api/v2/stable
⢠New features coming (http://telefonicaid.github.io/fiware-orion/api/v2/stable)
â Uses the /v2 prefix in resource URL
⢠Introduction to NGSIv2
â https://docs.google.com/presentation/d/1_fv9dB5joCsOCHlb4Ld6A-
QmeIYhDzHgFHUWreGmvKU/edit#slide=id.g53c31d7074fd7bc7_0
14
Two âflavorsâ of NGSI API
15. ⢠NGSIv2 is in ârelease candidateâ status
â By "release candidate" we mean that the specification is quite stable,
but changes may occur with regard to new release candidates or the
final version. In particular changes may be of two types:
⢠Extensions to the functionality currently specified by this
document. Note that in this case there isn't any risk of breaking
backward compatibility on existing software implementations.
⢠Slight modifications in the functionality currently specified by this
document, as a consequence of ongoing discussions. Backward
compatibility will be taken into account in this case, trying to
minimize the impact on existing software implementations. In
particular, only completely justified changes impacting backward
compatibility will be allowed and "matter of taste" changes will not
be allowed.
15
NGSIv2 status (AKA the âNGSIv2 disclaimerâ)
16. ⢠In general, it is always preferable to use NGSIv2
⢠However, you would need to use NGSIv1 if
â You need register/discovery operations (context management
availability functionality)
⢠Not yet implemented in NGSIv2 (in roadmap)
â Zero tolerance to changes in software interacting with Orion
⢠Even if you use NGSIv1, you can still use NGSIv2 advanced
functionality
â See âConsiderations on NGSIv1 and NGSIv2 coexistenceâ
section at Orion manual
⢠For a NGSIv1-based version of this presentation have a
look to
â http://bit.ly/fiware-orion-ngsiv1
16
So⌠when should I use NGSIv1 or NGSIv2?
18. GET <cb_host>:1026/version
{
"orion" : {
"version" : "1.6.0",
"uptime" : "7 d, 21 h, 33 m, 39 s",
"git_hash" : "aee96414cc3594bba161afb400f69d101978b39c",
"compile_time" : "Mon Dec 5 08:38:58 CET 2016",
"compiled_by" : "fermin",
"compiled_in" : "centollo"
}
}
18
Orion Context Broker â check health
19. 19
Orion Context Broker Basic Operations
Entities
⢠GET /v2/entities
⢠Retrieve all entities
⢠POST /v2/entities
⢠Creates an entity
⢠GET /v2/entities/{entityID}
⢠Retrieves an entity
⢠[PUT|PATCH|POST] /v2/entities/{entityID}
⢠Updates an entity (different âflavorsâ)
⢠DELETE /v2/entities/{entityID}
⢠Deletes an entity
20. 20
Orion Context Broker Basic Operations
Attributes
⢠GET /v2/entities/{entityID}/attrs/{attrName}
⢠Retrieves an attributeâs data
⢠PUT /v2/entities/{entityID}/attrs/{attrName}
⢠Updates an attributeâs data
⢠DELETE /v2/entities/{entityID}/attrs/{attrName}
⢠Deletes an attribute
⢠GET /v2/entities/{entityID}/attrs/{attrName}/value
⢠Retrieves an attributeâs value
⢠PUT /v2/entities/{entityID}/attrs/{attrName}/value
⢠Updates an attributeâs value
21. Context Broker operations: create & pull data
⢠Context Producers publish data/context elements by invoking the update
operations on a Context Broker.
⢠Context Consumers can retrieve data/context elements by invoking the query
operations on a Context Broker
Context Consumer
query
Context Producer
update
Context Broker
21
22. Quick Usage Example: Car Create
201 Created
22
POST <cb_host>:1026/v2/entities
Content-Type: application/json
...
{
"id": "Car1",
"type": "Car",
"speed": {
"type": "Float",
"value": 98
}
}
23. Quick Usage Example: Car Speed Update (1)
PUT <cb_host>:1026/v2/entities/Car1/attrs/speed
Content-Type: application/json
...
{
"type": "Float",
"value": 110
}
204 No Content
âŚ
23
In the case of id ambiguity, you can use
"?type=Car" to specify entity type
24. Quick Usage Example: Car Speed Query (1)
200 OK
Content-Type: application/json
...
{
"type": "Float",
"value": 110,
"metadata": {}
}
24
You can get all the attributes of the entity using the
entity URL:
GET/v2/entities/Car1/attrs
GET <cb_host>:1026/v2/entities/Car1/attrs/speed
25. Quick Usage Example: Car Speed Update (2)
PUT <cb_host>:1026/v2/entities/Car1/attrs/speed/value
Content-Type: text/plain
...
115
204 No Content
âŚ
25
26. Quick Usage Example: Car Speed Query (2)
26
200 OK
Content-Type: text/plain
...
115.000000
GET <cb_host>:1026/v2/entities/Car1/attrs/speed/value
Accept: text/plain
33. Quick Usage Example: Filters (2)
33
200 OK
Content-Type: application/json
...
[
{
"id": "Room1",
"pressure": 720,
"temperature": 25,
"type": "Room"
}
]
GET <cb_host>:1026/v2/entities?options=keyValues&q=pressure==715..725
The full description of the Simple
Query Language for filtering can be
found in the NGSIv2 Specification
document
34. Context Broker operations: push data
⢠Context Consumers can subscribe to receive context information that satisfy
certain conditions using the subscribe operation. Such subscriptions may
have an expiration time.
⢠The Context Broker notifies updates on context information to subscribed
Context Consumers by invoking the notify operation they export
subId = subscribeContext (consumer, expr, expiration)
Context Consumer
notify (subId, data/context)
Context Broker
Application
34
38. List existing subscriptions
38
200 OK
Content-Type: application/json
âŚ
[{
"id": " 51c0ac9ed714fb3b37d7d5a8 ",
"expires": "2026-04-05T14:00:00.00Z",
"status": "active",
"subject": {
"entities": [{
"id": "Room1",
"type": "Room"
}],
"condition": {
"attrs": ["temperature"]
}
},
"notification": {
"timesSent": 3,
"lastNotification": "2016-05-31T11:19:32.00Z",
"lastSuccess": "2016-05-31T11:19:32.00Z",
"attrs": ["temperature"],
"attrsFormat": "normalized",
"http": {
"url": "http://localhost:1028/publish"
}
}
}]
The full description of the
subscription object (including all
its fields) can be found in the
NGSIv2 Specification
GET <cb_host>:1026/v2/subscriptions
39. Orion Context Broker batch operations
39
⢠Batch query and batch update
⢠They are equivalent in functionality to previously described RESTful
operations
⢠All them use POST as verb and the /v2/op URL prefix, including
operation parameters in the JSON payload
⢠They implement extra functionality that cannot be achieved with
RESTful operations, e.g. to create several entities with the same
operation
⢠They are not a substitute but a complement to RESTful operations
41. How to get Orion? (Virtual Machines)
41
⢠FIWARE Lab image
â Image: orion-psb-image-R<x>.<y>
⢠VirtualBox image
â http://bit.ly/fiware-orion024-vbox (itâs big!)
â User/pass:
⢠fiware/fiware
⢠root/fiware
⢠Hint: update Orion package once the VM is deployed
42. How to get Orion? (Docker containers)
42
⢠Assuming docker is installed in your system
⢠Documentation in https://github.com/telefonicaid/fiware-
orion/tree/develop/docker
⢠Quick guide
git clone https://github.com/telefonicaid/fiware-orion.git
cd fiware-orion/docker
sudo docker-compose up
⢠Thatâs all!
â curl localhost:1026/version
⢠Installing Orion docker in less than 1 minute
â https://www.youtube.com/watch?v=6taR7e20H9U
43. Would you like to play with this?
43
⢠Have a look to the FIWARE Reference Tutorial
application
â git clone https://github.com/Fiware/tutorials.TourGuide-
App.git
â cd tutorials.TourGuide-App/
â docker-compose up orion
â curl localhost:1026/version
⢠Self-explanatory README.md at root directory
⢠Open a Postman session and rock and roll
â Postman collection:
https://github.com/Fiware/tutorials.TourGuide-
App/blob/develop/contrib/CampusParty2016.postman_coll
ection
44. Orion Context Broker to Backbone Sync
44
⢠https://github.com/digitalilusion/o2bb
45. NGSI Context Adaptor for Carto
45
Show your entities in a map with no effort, create history animations,
heat maps and clusters representations
⢠https://github.com/telefonicaid/fiware-dataviz
46. NGSI Plugin for Freeboard
46
Create a real time dashboard for your entities, representing gauges,
spark lines and maps. No coding required!
⢠https://github.com/telefonicaid/fiware-dataviz
In addition, Freeboard freemium version integrates Orion off-the-shelf
47. Would you like to know more?
47
⢠The easy way
â This presentation: google for âfermingalan slideshareâ and search the one
named âManaging Context Information at large scaleâ
â Orion User Manual: google for âOrion FIWARE manualâ and use the first hit
â Orion Catalogue page: google for âOrion FIWARE catalogueâ and use the first
hit
⢠References
â NGSIv2 Specification
⢠http://fiware.github.io/specifications/ngsiv2/stable
⢠http://fiware.github.io/specifications/ngsiv2/latest
â NGSIv2 for NGSIv1 developers
⢠http://bit.ly/ngsiv2-vs-ngsiv1
â This presentation
⢠http://www.slideshare.net/fermingalan/fiware-managing-context-information-at-large-
scale
â Orion Catalogue:
⢠http://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context-
broker
â Orion support trhough StackOverflow
⢠Ask your questions using the âfiware-orionâ tag
⢠Look for existing questions at http://stackoverflow.com/questions/tagged/fiware-orion
48. Managing Context Information at
Large Scale: Advanced Topics
FermĂn GalĂĄn MĂĄrquez - fermin.galanmarquez@telefonica.com
Ken Gunnar Zangelin - kengunnar.zangelin@telefonica.com
(Reference Orion Context Broker version: 1.7.0)
49. 49
Orion functionality
49
Pagination
Metadata
Compound attribute/metadata values
Type browsing
Geo-location
Query filters
DateTime support
Custom notifications
Notification status
Attribute/metadata filtering
Special attribute/metadata
Registrations & context providers
Multitenancy
Creating & pulling data
Pushing data
Subscriptions & Notifications
Batch operations
50. ⢠Pagination
⢠Metadata
⢠Compound attribute/metadata values
⢠Type browsing
⢠Geo-location
⢠Query filters
⢠DateTime support
⢠Custom notifications
⢠Notification status
⢠Attribute/metadata filtering and special
attribute/metadata
⢠Registrations & context providers
⢠Multitenancy
⢠Service paths
⢠CORS
⢠Notifying services in private networks
50
Advanced Features
51. ⢠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)
â count (option)
⢠Returns total elements (default: not return)
51
Pagination
52. ⢠Example, querying the first 100 entries:
â GET <orion_host>:1026/v2/entities?limit=100&options=count
⢠The first 100 elements are returned, along with the
following header in the response:
â Fiware-Total-Count: 322
⢠Now we now there are 322 entities, we can keep querying
the broker for them:
â GET <orion_host>:1026/v2/entities?offset=100&limit=100
â GET <orion_host>:1026/v2/entities?offset=200&limit=100
â GET <orion_host>:1026/v2/entities?offset=300&limit=100
52
Pagination
53. ⢠By default, results are ordered by entity creation date
⢠This behavior can be overridden using orderBy URI parameter
â A comma-separated list of attributes. Results are ordered by the first
attribute. On ties, the results are ordered by the second attribute and
so on. A "!" before the attribute name means that the order is
reversed.
⢠Example: get the first 10 entities ordered by temp in ascending
order, then humidity in descending order
GET <orion_host>:1026/v2/entities?limit=20&offset=0&orderBy=temp,!humidity
⢠dateCreated and dateModified can be used to ordering by
entity creation and modification date, respectively
53
Pagination
55. Attributes
⢠Name
⢠Type
⢠Value
Entity
⢠EntityId
⢠EntityType
1 n
âhasâ
Metadata
⢠Name
⢠Type
⢠Value1 n
âhasâ
55
Complete NGSI Model
56. ⢠Attributes and metadata can have a structured
value. Vectors and key-value maps are
supported.
⢠It maps directly to JSON's objects and arrays.
56
Compound Attribute/Metadata Values
57. ⢠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:
{
"type": "Car",
"id": "Car1",
"tirePressure": {
"type": "kPa",
"value": {
"frontRight": 120,
"frontLeft": 110,
"backRight": 115,
"backLeft": 130
}
}
}
57
Compound Attribute/Metadata Values
58. ⢠GET /v2/types
⢠Retrieve a list of all entity types currently in Orion,
including their corresponding attributes and entities
count
⢠GET /v2/types/{typeID}
⢠Retrieve attributes and entities count associated to an
entity type
PRO TIP
GET /v2/contextTypes?options=values
Retrieves just a list of all entity types without any extra info
58
Type Browsing
59. ⢠Entities can have an attribute
that specifies its location
⢠Several attribute types can be
used
â geo:point (for points)
â geo:line (for lines)
â geo:box (for boxes)
â geo:polygon (for polygons)
â geo:json (for arbitrary geometries, in
GeoJson standard)
⢠Example: create an entity called
Madrid
âŚand create a couple more towns:
⢠LeganÊs
⢠Alcobendas
POST <cb_host>:1026/v2/entities
{
"type": "City",
"id": "Madrid",
"position": {
"type": "geo:point",
"value": "40.418889, -3.691944"
}
}
59
Geo-location
61. Geo-location â Max distance
61
GET <cb_host>:1026/v2/entities?
idPattern=.*&
type=City&
georel=near;maxDistance:13500&
geometry=point&
coords=40.418889,-3691944
62. Geo-location â Min distance
62
GET <cb_host>:1026/v2/entities?
idPattern=.*&
type=City&
georel=near;minDistance:13500&
geometry=point&
coords=40.418889,-3691944
63. ⢠Apart from near, the following georel can be
used
â georel=coveredBy
â georel=intersects
â georel=equals
â georel=disjoint
⢠See NGSIv2 Specification for a detailed
description
63
More geo-relationships
64. ⢠For the GET /v2/entities operation
⢠By entity type
⢠By entity id list
⢠By entity id pattern (regex)
⢠By entity type pattern (regex)
⢠By geographical location
â Described in detail in previous slides
⢠Filters can be used simultaneously (i.e. like AND condition)
64
GET <cb_host>:1026/v2/entities?type=Room
GET <cb_host>:1026/v2/entities?id=Room1,Room2
GET <cb_host>:1026/v2/entities?idPattern=^Room[2-5]
GET <cb_host>:1026/v2/entities?typePattern=T[ABC]
Query filters
65. ⢠By attribute value (q)
⢠By metadata value (mq)
⢠See full details about q and mq query language in NGSIv2 specification
65
GET <cb_host>:1026/v2/entities?q=temperature>25
GET <cb_host>:1026/v2/entities?q=tirePressure.frontRight >130
attribute name
attribute sub-key (for compound attribute values only)
GET <cb_host>:1026/v2/entities?mq=temperature.avg>25
GET <cb_host>:1026/v2/entities?mq=tirePressure.accuracy.frontRight >90
metadata sub-key (for compound
metadata values only)
attribute name
metadata name
Query filters
66. 66
POST <cb_host>:1026/v2/subscriptions
âŚ
{
"subject": {
"entities": [
{
"id": âCar5",
"type": "Car"
},
{
"idPattern": "^Room[2-5]",
"type": "Room"
},
{
"id": "D37",
"typePattern": "Type[ABC]"
},
],
"condition": {
"attrs": [ "temperature" ],
"expression": {
"q": "temperature>40",
"mq": "humidity.avg==80..90",
"georel": "near;maxDistance:100000",
"geometry": "point",
"coords": "40.418889,-3.691944"
}
}
},
âŚ
}
⢠Filters can be also used in
subscriptions
â id
â type
â id pattern
â type pattern
â attribute values
â metadata value
â geographical location
Query filters
67. ⢠Orion implements date support
â Based on ISO ISO8601 format, including partial
representations and timezones
⢠See https://fiware-
orion.readthedocs.io/en/master/user/ngsiv2_implementati
on_notes/index.html#datetime-support for syntax details
â Use reserved attribute type DateTime to express a date
â Date-based filters are supported
67
Datetime support
68. ⢠Attribute value arithmetic filters can be used with dates as if they
were numbers
⢠Entity dateModified and dateCreated special attributes, to get
entity creation and last modification timestamps
â They are shown in query responses using
attrs=dateModified,dateCreated
⢠Entity dateModified and dateCreated special metadata, to get
attribute creation and last modification timestamps
â They are shown in query responses using
metadata=dateModified,dateCreated
68
POST /v2/entities
âŚ
{
"id": "John",
"birthDate": {
"type": "DateTime",
"value": "1979-10-14T07:21:24.238Z"
}
}
GET /v2/entities?q=birthDate<1985-01-01T00:00:00
Example: create entity John,
with birthDate attribute using
type DateTime
Datetime support
69. ⢠Apart from the standard formats defined in the
previous slides NGSIv2 allows to re-define all the
notification aspects
⢠httpInfo is used instead of http, with the
following subfields
â URL query parameters
â HTTP method
â HTTP headers
â Payload (not necessarily JSON!)
⢠A simple macro substitution language based on ${..}
syntax can be used to âfill the gapsâ with entity data (id,
type or attribute values)
â Exception: this cannot be used in HTTP method field
69
Custom notifications
70. 70
âŚ
"httpCustom": {
"url": "http://foo.com/entity/${id}",
"headers": {
"Content-Type": "text/plain"
},
"method": "PUT",
"qs": {
"type": "${type}"
},
"payload": "The temperature is ${temp} degrees"
}
âŚ
PUT http://foo.com/entity/DC_S1-D41?type=Room
Content-Type: text/plain
Content-Length: 31
The temperature is 23.4 degrees
PUT /v2/entities/DC_S1-D41/attrs/temp/value?type=Room
âŚ
23.4
Custom notification configuration
update
notificaiton
Custom notifications
71. ⢠Status failed means that last
attempt to notify failed
â E.g. the endpoint is not reachable
⢠Detailed information in the
notifications element
â timesSent: total number of
notifications attempts (both
successful and failed)
â lastSuccess: last time that
notification was successfully sent
â lastFailure: last time that
notification was tried and failed
â lastNotification: last time the
notification was sent (either success
or failure)
⢠Corollary: lastNotification value is the
same than either lastFailure or
lastSuccess
71
200 OK
Content-Type: application/json
âŚ
[{
"id": " 51c0ac9ed714fb3b37d7d5a8 ",
"expires": "2026-04-05T14:00:00.00Z",
"status": "failed",
"subject": { ⌠},
"notification": {
"timesSent": 3,
"lastNotification": "2016-05-31T11:19:32.00Z",
"lastSuccess": "2016-05-31T10:07:32.00Z",
"lastFailure": "2016-05-31T11:19:32.00Z",
âŚ
}
}]
Notification status
72. ⢠By default all attribute are included in query
responses or notifications
⢠The attrs field (as parameter in GET operations
and as notification sub-field in subscriptions)
can be used to specify a filtering list
⢠The attrs field can be also used to explicitly
include some special attributes (not included by
default)
â dateCreated, dateModified: described in previous
slide
⢠The â*â can be used as an alias of âall the
(regular) attributesâ
72
Attributes filtering and special attributes
73. ⢠Examples
â Include only attributes temp and lum
⢠In queries: GET /v2/entities?attrs=temp,lum
⢠In subscriptions: "attrs": [ "temp", "lum" ]
â Include dateCreated and not any other attribute
⢠In queries: GET /v2/entities?attrs=dateCreated
⢠In subscriptions: "attrs": [ "dateCreated" ]
â Include dateModified and all the other (regular)
attributes
⢠In queries: GET /v2/entities?attrs=dateModified,*
⢠In subscriptions: "attrs": [ "dateModified", "*" ]
â Include all attributes (same effect that not using attrs,
not very interesting)
⢠In queries: GET /v2/entities?attrs=*
⢠In subscriptions: "attrs": [ "*" ]
73
Attributes filtering and special attributes
74. ⢠By default all attribute metadata are included in query responses
and notifications
⢠The metadata field (as parameter in GET operations and as
notification sub-field in subscriptions) can be used to specify a
filtering list
⢠The metadata field can be also used to explicitly include some
special metadata (not included by default)
â dateCreated, dateModified: described in previous slide
â actionType: which value is the action type corresponding to the
update triggering the notification: âupdateâ, âappendâ or âdeleteâ (*)
â previousValue: which provides the value of the attribute previous to
processing the update that triggers the notification
⢠The â*â can be used as an alias of âall the (regular) metadataâ
74
(*) actionType âdeleteâ not yet supported by Orion in 1.7.0.
Metadata filtering and special metadata
75. ⢠Examples
â Include only metadata MD1 and MD2
⢠In queries: GET /v2/entities?metadata=MD1,MD2
⢠In subscriptions: "metadata": [ "MD1", "MD2" ]
â Include previousValue and not any other metadata
⢠In queries: GET /v2/entities?metadata=previousValue
⢠In subscriptions: "attrs": [ "previousValue" ]
â Include actionType and all the other (regular) metadata
⢠In queries: GET /v2/entities?metadata=actionType,*
⢠In subscriptions: "attrs": [ "actionType", "*" ]
â Include all metadatata (same effect that not using
metadata, not very interesting)
⢠In queries: GET /v2/entities?metadata=*
⢠In subscriptions: "metadata": [ "*" ]
75
Metadata filtering and special metadata
76. ⢠Uncached queries and updates
76
Application
ContextBroker ContextProvider
1. registerContext(provider= )
db
2. query 3. query
4. data5. data
Context
Consumer
Registration & Context Providers
77. POST <cb_host>:1026/v1/registry/registerContext
âŚ
{
"contextRegistrations": [
{
"entities": [
{
"type": "Car",
"isPattern": "false",
"id": "Car1"
},
"attributes": [
{
"name": "speed",
"type": "float",
"isDomain": "false"
}
],
"providingApplication": "http://contextprovider.com/Cars"
}
],
"duration": "P1M"
}
200 OK
...
{
"duration" : "P1M",
"registrationId" : "52a744b011f5816465943d58"
}
77
Context management availability functionality not
yet specified in NGSIv2. Thus, a NGSIv1 operation is
used to create the registration.
Registration & Context Providers
79. ⢠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
âŚ
79
Multitenancy
80. ⢠A service path is a hierarchical scope assigned to an entity
at creation time (with POST /v2/entities).
80
Service Paths
81. ⢠In order to use a service path we put in a new HTTP header
called "Fiware-ServicePath". For example:
Fiware-ServicePath: /Madrid/Gardens/ParqueNorte/Parterre1
⢠Properties:
â A query on a service path will look only into the specified node
â Use "ParentNode/#" to include all child nodes
â Queries without Fiware-ServicePath resolve to "/#"
â Entities will fall in the "/" node by default
ParqueNorte
Parterre2Parterre1
81
Service Paths
82. ⢠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
â It works not only with queries, but also with
subscriptions/notifications
â It works not only in NGSI10, but also with
registrations/discoveries (NGSI9)
ParqueNorte
Parterre1
light1
light1
A B
A or B
82
Service Paths
83. ⢠Useful for programming clients that run entirely in browser
without backend
⢠Support in GET requests
⢠Controlled by the -corsOrigin CLI parameter at boot time
83
200 OK
Access-Control-Allow-Origin: *
...
{
âspeed": [
âŚ.
}
GET <cb_host>:1026/v2/entities/Car1
Cross-Origin Resource Sharing (CORS)
85. ⢠The easy way
â This presentation: google for âfermingalan slideshareâ and search the one
named âManaging Context Information at large scaleâ
â Orion User Manual: google for âOrion FIWARE manualâ and use the first hit
â Orion Catalogue page: google for âOrion FIWARE catalogueâ and use the first
hit
⢠References
â NGSIv2 Specification
⢠http://fiware.github.io/specifications/ngsiv2/stable
⢠http://fiware.github.io/specifications/ngsiv2/latest
â NGSIv2 for NGSIv1 developers
⢠http://bit.ly/ngsiv2-vs-ngsiv1
â This presentation
⢠http://www.slideshare.net/fermingalan/fiware-managing-context-information-at-large-
scale
â Orion Catalogue:
⢠http://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context-
broker
â Orion support trhough StackOverflow
⢠Ask your questions using the âfiware-orionâ tag
⢠Look for existing questions at http://stackoverflow.com/questions/tagged/fiware-orion
85
Would you like to know more?
87. 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
queryContext (e1,
attr1, attr2)
Context Provider
queryContext (e1,
attr1)
Context Consumer
updateContext (e1,
attr2)
Application
Context Broker
System BSystem A
87
88. 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
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
88
89. ⢠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
89
90. Context/Data Management Platform
Applications
OMA NGSI-9/10
Processing/Analysis
Algorithms
Gathered data is
injected for
processing/analysis
Distributed
Context
Sources Complex Event
Processing
(PROTON)
BigData
(COSMOS)
Processed data is
injected for
processing/analysi
s
Data generated either by CEP
or BigData is published
Gathered data injected
for CEP-like processing
Direct
bigdata
injection
Programming of
rules
90
FI-WARE Context/Data Management Platform
91. ⢠Used by /v2/op/update (batch operation)
⢠Conventional actionTypes
â APPEND: append (or update if the attribute already
exists)
â UPDATE: update
â DELETE: delete
⢠Special actionTypes
â APPEND_STRICT: strict append (returns error if some of
the attributes to add already exists)
â REPLACE: delete all the entity attributes, next append
the ones in the update request
91
Special update action types
Editor's Notes
Orion Context Broker is an implementation of a context information broker with persistent storage
It implements OMA NGSI9/10 specification
NGSI9 is about context information availability (i.e. sources of context information) management
NGSI10 is about context information itself
Alternatives to ngrok.io:
http://localtunnel.me
https://forwardhq.com