Introduction to Managing Context Information at Large Scale by Fermín Galán and Leandro Gullén (@leandrogullen @fermingalan) for Developers Week
www.fiware.org
FIWARE Developers Week_ Introduction to Managing Context Information at Large Scale_presentation
1. Managing Context Information
at large scale
(Introduction)
Contact twitter
@fermingalan
@LeandroJGuillen
Contact email
fermin.galanmarquez@telefonica.com
(Reference Orion Context Broker version: 0.16.0)
2. Introduction
• Context Management in FIWARE
• Orion Context Broker
• Creating and pulling data
• Pushing data and notifications
• Convenience operations
Orion Context Broker
2
3. 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
4. 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 …
Context
Information
Context
Information
4
A sensor in a
pedestrian street
The Public Bus
Transport Management
system
It’s too hot!
A person from his smartphone
Context
Information
What’s the current temperature?
5. Context Management in FIWARE
Get notified when an update on context information takes place
Bus = “X”, last_stop = “A”,
arrived= “Yes”
5
push
Notify me when bus “X”
arrives at the bus stop “A”
API
6. Context Management in FIWARE
Acting on devices can be as easy as changing the value of attributes
linked to its corresponding entity
Street Lamp lamp1.status “on”
Street lamp = “lamp1”, status= “on”
6
API
7. Orion Context Broker
• Main functions:
– Context availability management
– Context management
• 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
“has”
1 n
8. Orion Context Broker in a nutshell
Orion Context Broker
8
Context
Producers
Context
Consumers
subscriptions
update
query
notify
notify
update
update
DB
1026
1026
9. Orion Context Broker – check health
GET <cb_host>:1026/version
{
"orion" : {
"version" : "0.16.0",
"uptime" : "7 d, 21 h, 33 m, 39 s",
"git_hash" : "238c3642ad67899da7c1ff08aba4b5c846b4901a",
"compile_time" : "Mon Nov 3 11:27:18 CET 2014",
"compiled_by" : "fermin",
"compiled_in" : "centollo"
}
}
9
11. 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
queryContext
Context Consumer
Context Producer
updateContext
Context Broker
24. 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
subscription_id = subscribeContext (consumer, expr, duration)
24
Context Consumer
notifyContext (subscription_id, data/context)
Context Broker
Application
28. 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
29. 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
30. 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
31. Convenience Operations – Example 3
Subscriptions
• POST /v1/contextSubscriptions
• Creates a subscription
• PUT /v1/contextSubscriptions/{subID}
• Updates a subscription
• DELETE /v1/contextSubscriptions/{subID}
• Cancel a subscription
32. 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=true
Retrieves a list of all entity types without attribute info
33. Managing Context Information
at large scale
(Advanced Topics)
Contact wwitter
@fermingalan
@LeandroJGuillen
Contact email
fermin.galanmarquez@telefonica.com
(Reference Orion Context Broker version: 0.16.0)
35. Pagination
• 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")
35
36. Pagination
• Example, querying the first 100 entries:
POST <orion_host>:1026/v1/queryContext?limit=100&details=on
• The first 100 elements are returned, along with the following errorCode in
the response:
"errorCode": {
"code": "200",
"details": "Count: 322",
"reasonPhrase": "OK"
}
• Now we now there are 322 entities, we can keep querying the broker for
them:
– POST <orion_host>:1026/v1/queryContext?offset=100&limit=100
– POST <orion_host>:1026/v1/queryContext?offset=200&limit=100
– POST <orion_host>:1026/v1/queryContext?offset=300&limit=100
36
37. 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
38. 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
47. 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
48. Entity Service Paths
• A service path is a hierarchical scope assigned to an entity
at creation time (with updateContext).
48
49. Entity Service Paths
• 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 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
Parterre1 Parterre2
49
50. 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
A B
A or B
ParqueNorte
Parterre1
light1
light1
50
51. Bonus Track: Orion Context Explorer
• Publicly available browser-based front-end for Orion
Context Broker
– Open source development by VM9
• Authentication integrated with FIWARE Lab account
• Have a look!
– http://orionexplorer.com/
51
54. 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
System A System B
54
queryContext (e1,
attr1, attr2)
queryContext (e1,
attr1)
Context Provider
updateContext (e1,
attr2)
Context Consumer
Application
Context Broker
55. 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
OMA NGSI API (northbound interface)
FIWARE Context Broker
55
IoT
Agent-1
IoT
Agent-2
IoT
Agent-n
IoT Agent
Manager
create/monitor
FIWARE Backend IoT
Device Management
(southbound interfaces)
ETSI M2M MQTT IETF CoAP
56. Context Management in FIWARE
• Federation of infrastructures (private/public regions)
• Automated GE deployment Cloud
• Complete Context Management Platform
• Integration of Data and Media Content Data
•Easy plug&play of devices using multiple protocols
•Automated Measurements/Action Context updates IoT
• Visualization of data (operation dashboards)
•Publication of data sets/services Apps
•Easy support of UIs with advanced web-based 3D and AR
capabilities
•Visual representation of context information.
56
Web UI
•Advanced networking capabilities (SDN) and Middleware
• Interface to robots I2ND
•Security Monitoring
•Built-in Identity/Access/Privacy Management Security
57. FI-WARE Context/Data Management Platform
Applications
Context/Data Management Platform
57
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
Editor's Notes
1. En la primera slide poned una lista de puntos de lo que se puede hacer con ese GE/set de GEs. Me refiero en plan titulares, sin muchas explicaciones.
2. Mostrad un ejemplo representativo de uno o varios de los puntos anteriores.
Recordad: si lo hacéis como demo, poned slides con capturas y explicaciones también (así sirve también por si la demo os falla en ese momento ;-) ).
3. Mostrad un enlace donde pondremos esta semana las slides de la Campus que tienen los detalles de todos los puntos mencionados en 1.
(Poned la lista de ficheros pero dejad el enlace en blanco que ya lo pondremos a última hora).
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
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
1. En la primera slide poned una lista de puntos de lo que se puede hacer con ese GE/set de GEs. Me refiero en plan titulares, sin muchas explicaciones.
2. Mostrad un ejemplo representativo de uno o varios de los puntos anteriores.
Recordad: si lo hacéis como demo, poned slides con capturas y explicaciones también (así sirve también por si la demo os falla en ese momento ;-) ).
3. Mostrad un enlace donde pondremos esta semana las slides de la Campus que tienen los detalles de todos los puntos mencionados en 1.
(Poned la lista de ficheros pero dejad el enlace en blanco que ya lo pondremos a última hora).
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature
Do the following sequence (showing the XML)
registerContext Room1-temperature
updateContext Room1-temperture = 30ºC
queryContext Room1-temperature
updateContext Room1-temperture = 31ºC
queryContext Room1-temperature