SlideShare a Scribd company logo
Pasquale Vitale
Engineering Ingegneria Informatica
FIWARE Contex Broker
Introduction
Managing Context Information at large scale
FIWARE Context Broker GE (implementation: Orion)
Creating and pulling data
Pushing data and notifications
Convenience operations
Managing Context Information at large scale
Context Information is represented through values assigned to attributes
The Context Broker is able to:
handle context information at large scale
enable your application to query on context information
subscribe to changes in context information that will be received through notifications
enable your application or other applications to modify the context information
Context Management in FIWARE
Context Information: the value of attributes that characterize those entities relevant to your application
NGSI API
Bus
• Location
• No. passengers
• Driver
• License plate
Citizen
• Name-Surname
• Birthday
• Preferences
• Location
• To Do list
Shop
• Location
• Business name
• Franchise
• Offerings
Applications/Services
Context Broker
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?
… but programmers should just care
about entities and their attributes
Context Information independent from the source
Context information may come from many sources using different interfaces and protocols …
Context Management in FIWARE
Get notified when an update on context information takes place
Bus = “X”, last_stop = “A”,
arrived= “Yes”
push
Notify me when bus “X” arrives at
the bus stop “A”
API
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”
API
FIWARE Context Broker GE: Orion
Main functions:
Context availability management - OMA NGSI-9 specs
Context management - OMA NGSI-10 specs
HTTP and REST-based
XML payload support
JSON payload support
FIWARE Context Broker GE: Orion
Functions Operations
NGSI-9
• Register,
• Search,
• Subscribe for context sources
• registerContext
• discoverContextAvailability
• subscribeContextAvailability
• updateContextAvailabilitySubscription
• unsubscribeContextAvailability
NGSI-10
• Query,
• Update,
• Subscribe to context elements
• updateContext
• queryContext
• subscribeContext
• updateContextSubscription
• unsubscribeContextSubscription
FIWARE Context Broker GE: Orion
Context in NGSI is based in an entity-attribute model:
Attributes
• Name
• Type
• Value
Entity
• EntityId
• EntityType 1 n
“has”
FIWARE Context Broker GE: Orion
Orion Architecture
11
Orion Context Broker
Context
Producers
Context
Consumers
subscriptions
update
query
notify
notify
update
update
DB
1026
1026
Context Broker operations: create and 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
Context Consumer
queryContext
Context Producer
updateContext
Context Broker
speed
Entity creation example: car create
updateContext operation with APPEND action type
POST localhost:1026/v1/updateContext
... 
{
"contextElements": [
{
"type": "Car",
"isPattern": "false",
"id": "Car1",
"attributes": [
{
"name": "speed",
"type": "float",
"value": "98"
}
]
}
],
"updateAction": "APPEND"
}
200 OK
... 
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "speed",
"type": "float",
"value": ""
}
],
"id": "Car1",
"isPattern": "false",
"type": "Car"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Update context elements example: car updateContext
updateContext operation with UPDATE action type
POST localhost:1026/v1/updateContext
... 
{
"contextElements": [
{
"type": "Car",
"isPattern": "false",
"id": "Car1",
"attributes": [
{
"name": "speed",
"type": "float",
"value": "110"
}
]
}
],
"updateAction": "UPDATE"
}
200 OK
... 
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "speed",
"type": "float",
"value": ""
}
],
"id": "Car1",
"isPattern": "false",
"type": "Car"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Query context operation example: car queryContext
queryContext operation by Id
POST <cb_host>:1026/v1/queryContext
... 
{
"entities": [
{
"type": "Car",
"isPattern": "false",
"id": "Car1"
}
]
} 
200 OK
... 
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "speed",
"type": "float",
"value": "110"
}
],
"id": "Car1",
"isPattern": "false",
"type": "Car"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Entity creation example: room create
POST localhost:1026/v1/updateContext
... 
{
"contextElements": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1",
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "24"
},
{
"name": "pressure",
"type": "integer",
"value": "718"
}
]
}
],
"updateAction": "APPEND"
}
200 OK
... 
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"type": "float",
"value": ""
},
{
"name": "pressure",
"type": "integer",
"value": ""
}
],
"id": "Room1",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Two attributes: temperature and pressure
Update context elements example: room updateContext
POST localhost:1026/v1/updateContext
... 
{
"contextElements": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1",
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "25"
},
{
"name": "pressure",
"type": "integer",
"value": "720"
}
]
}
],
"updateAction": "UPDATE"
}
200 OK
... 
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"type": "float",
"value": ""
},
{
"name": "pressure",
"type": "integer",
"value": ""
}
],
"id": "Room1",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Update: temperature and pressure
Query context operation example: room queryContext
queryContext operation by Id
POST <cb_host>:1026/v1/queryContext
... 
{
"entities": [
{
"type": “Room",
"isPattern": "false",
"id": “Room1"
}
]
} 
200 OK
... 
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "25"
},
{
"name": "pressure",
"type": "integer",
"value": "720"
}
],
"id": "Room1",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Query context operation example: room queryContext
queryContext operation by Id and attribute
POST <cb_host>:1026/v1/queryContext
... 
{
"entities": [
{
"type": “Room",
"isPattern": "false",
"id": "Room1"
}
] ,
"attributes": [
"temperature"
]
} 
200 OK
... 
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "25"
}
],
"id": "Room1",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Entity creation example: room create
POST localhost:1026/v1/updateContext
... 
{
"contextElements": [
{
"type": "Room",
"isPattern": "false",
"id": "Room2",
"attributes": [
{
"name": "temperature",
"type": "float",
"value": “33"
},
{
"name": "pressure",
"type": "integer",
"value": “722"
}
]
}
],
"updateAction": "APPEND"
}
200 OK
... 
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"type": "float",
"value": ""
},
{
"name": "pressure",
"type": "integer",
"value": ""
}
],
"id": "Room2",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
Append another room: Room2
Query context operation example: room queryContext
queryContext operation by regex Room.*
POST <cb_host>:1026/v1/queryContext
... 
{
"entities": [
{
"type": “Room",
"isPattern": “true",
"id": "Room.*"
}
] ,
"attributes": [
"temperature"
]
} 
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "25"
}
],
"id": "Room1",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
},
{
"contextElement": {
"attributes": [
{
"name": "temperature",
"type": "float",
"value": “33"
}
],
"id": "Room2",
"isPattern": "false",
"type": "Room"
},
"statusCode": {
"code": "200",
"reasonPhrase": "OK"
}
}
]
}
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)
Context Consumer
notifyContext (subscription_id, data/context)
Context Broker
Application
Context subscriptions example: ONTIMEINTERVAL
POST <cb_host>:1026/v1/subscribeContext
…
{
"entities": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1"
}
],
"attributes": [
"temperature"
],
"reference": "http://<host>:<port>/publish",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONTIMEINTERVAL",
"condValues": [
“PT10S"
]
}
]
}
200 OK
... 
{
"subscribeResponse": {
"duration": "P1M",
"subscriptionId": "54dcb87fa85d63b107245ff1"
}
}
25
19
Context subscriptions example: ONCHANGE
POST <cb_host>:1026/v1/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
19
Notification
POST http://<host>:<port>/publish
…
{
"subscriptionId" : "51c0ac9ed714fb3b37d7d5a8",
"originator" : "localhost",
"contextResponses" : [
{
"contextElement" : {
"attributes" : [
{
"name" : "temperature",
"type" : "float",
"value" : "19"
}
],
"type" : "Room",
"isPattern" : "false",
"id" : "Room1"
},
"statusCode" : {
"code" : "200",
"reasonPhrase" : "OK"
}
}
]
}
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
Convenience Operations
Entities
GET /v1/contextEntities/{entityID} Query Context Retrieves an entity
POST /v1/contextEntities/{entityID} Entity Creation Creates an entity
PUT /v1/contextEntities/{entityID} Update Context Updates an entity
DELETE /v1/contextEntities/{entityID} Delete Context Deletes an entity
GET all entities
GET /v1/contextEntities
Convenience Operations
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
Convenience Operations
Subscriptions
POST /v1/contextSubscriptions Creates a subscription
PUT / v1/contextSubscriptions/{subID} Updates a subscription
DELETE / v1/contextSubscriptions/{subID} Deletes a subscription
Convenience Operations
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
Advanced features
Pagination
Compound attribute values
Metadata
Geo-location
Registrations & context providers
Entity service paths
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")
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 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
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
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"
}
Metadata
Users may attach metadata to attributes
Reserved metadatas: ID, Location, creDate and modDate
Examples:
…
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "26.5",
"metadatas": [
{
"name": "accuracy",
"type": "float",
"value": "0.9"
}
]
}
]
…
…
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "26.5",
"metadatas": [
{
"name": "average",
"type": "float",
"value": "22.4"
}
]
}
]
…
Context Element attributes
• Name
• Type
• Value
Context Element
• EntityId
• EntityType
n
“has”
1
Metadata
• Name
• Type
• Valuen
“has”
1
Geo-location
Entities can have an attribute that specifies its location
- Using a "location" metadata
Example:
create an entity called Madrid (of type "City")
with attribute "position" defined as location
POST <cb_host>:1026/v1/updateContext
{
"contextElements": [
{
"type": "City",
"isPattern": "false",
"id": "Madrid",
"attributes": [
{
"name": "position",
"type": "coords",
"value": "40.418889, ‐3.691944",
"metadatas": [
{
"name": "location",
"type": "string",
"value": "WGS84"
}
]
}
]
}
],
"updateAction": "APPEND"
}
Coordinates for Madrid are:
• latitude 40.418889
• longitude 3.691944
Geo-located queries
Entities location can be used in queryContex using:
- FIWARE::Location as scopeType
- and an area specification as scopeValue
The area specification are:
- area internal to a circle, given its centre and radius
- area external to a circle, given its centre and radius
- area internal to a polygon, given its vertices
- area external to a polygon, given its vertices
{
"entities": [
{
"type": "Point",
"isPattern": "true",
"id": ".*"
}
],
"restriction": {
"scopes": [
{
"type" : "FIWARE::Location",
"value" : {
"polygon": {
"vertices": [
{
"latitude": "0",
"longitude": "0"
},
{
"latitude": "0",
"longitude": "6"
},
{
"latitude": "6",
"longitude": "6"
},
{
"latitude": "6",
"longitude": "0"
}
]
}
}
}
]
}
}
Geo-location - circle
Distances between:
- Madrid / Alcobendas 13.65 km
- Madrid / Leganes 12.38 km
Consider a radius of 13.5 km
POST <cb_host>:1026/v1/queryContext
…
{
"entities": [
{
"type": "City",
"isPattern": "true",
"id": ".*"
}
],
"restriction": {
"scopes": [
{
"type" : "FIWARE::Location",
"value" : {
"circle": {
"centerLatitude": "40.418889",
"centerLongitude": "‐3.691944",
"radius": "13500"
}
}
}
]
}
}
The query is Madrid and Leganes
Geo-location - inverse circle
Distances between:
- Madrid / Alcobendas 13.65 km
- Madrid / Leganes 12.38 km
Consider a radius of 13.5 km
POST <cb_host>:1026/v1/queryContext
{
"entities": [
{
"type": "City",
"isPattern": "true",
"id": ".*"
}
],
"restriction": {
"scopes": [
{
"type" : "FIWARE::Location",
"value" : {
"circle": {
"centerLatitude": "40.418889",
"centerLongitude": "‐3.691944",
"radius": "13500",
"inverted": "true"
}
}
}
]
}
}
The query is Alcobendas
Registration & Context Providers
Context Broker doesn't cache the result of the query internally
Application
Context Broker Context Provider
1. registerContext(provider= )
2. queryContext(id) 3. queryContext(id)
4. data5. data
Context Consumer
db
Registration & Context Providers
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"
}
The application registers the Context Provider for the Car1 speed using providingApplication attribute
Application
registerContext
http://contextprovider.com/Cars
{
"contextResponses": [
{
"contextElement": {
"attributes": [
{
"name": "speed",
"type": "float",
"value": "100"
}
],
"id": "Car1",
"isPattern": "false",
"type": "Car"
},
"statusCode": {
"code": "200",
"details": "Redirected to context provider http://contextprovider.com/Cars",
"reasonPhrase": "OK"
}
}
]
}
Registration & Context Providers
It includes details in the response
POST <cb_host>:1026/v1/queryContext
... 
{
"entities": [
{
"type": "Car",
"isPattern": "false",
"id": "Car1"
}
]
}
queryContext(id)
data
Multitenancy
Context Broker implements a simple multitenant/multiservice model based and logical database separation
Make easer service/tenant based authorization policies provided by other FI-WARE components or third
party software
Orion uses the "Fiware-Service" HTTP header in the request to identify the service/tenant
Example:
Fiware-Service: Tenant1
Context
Broker
Context
Broker
Tenant1
Tenant2
…
entities1/attributes1/subscripitions1
entities2/attributes2/subscripitions2
Entity Service Paths
Orion Context Broker supports hierarchical scopes
Entities can be assigned to a scope at creation time with updateContext
queryContext can be also scoped to locate entities in the corresponding scopes
For example, consider the following scopes in the figure:
- Madrid, as first level scope
- Gardens and Districts, as second-level scope (children of Madrid)
- ParqueNorte, ParqueOeste and ParqueSur (children of Gardens)
and Fuencarral and Latina (children of Districts)
- Parterre1 and Parterre2 (children of ParqueNorte)
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
ParqueNorte
Parterre2Parterre1
Entity Service Paths
Properties:
1. A query on a service path will look only into the specified node
2. Use ParentNode/# to include all child nodes
3. Queries without Fiware-ServicePath resolve to /#
4. Entities will fall in the "/" node by default
5. 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
1. You can have the same element IDs in different scopes (be careful with this!)
2. You can't change scope once the element is created
3. One entity can belong to only one scope
A B
A or B
ParqueNorte
Parterre1
light1
light1
Thanks!Thanks!

More Related Content

PDF
FIWARE Internet of Things
PDF
FINODEX introduces FIWARE
PDF
FIWARE Technology
PPTX
Introduction to FIWARE Cloud & Context Broker
PPTX
Orion Context Broker webminar 2014 01-22
PPTX
Introduction to FIWARE Open Ecosystem
PPTX
Developing your first application using FI-WARE
PPTX
FIWARE Developers Week_Managing context information at large scale_conference
FIWARE Internet of Things
FINODEX introduces FIWARE
FIWARE Technology
Introduction to FIWARE Cloud & Context Broker
Orion Context Broker webminar 2014 01-22
Introduction to FIWARE Open Ecosystem
Developing your first application using FI-WARE
FIWARE Developers Week_Managing context information at large scale_conference

What's hot (19)

PPTX
FIWARE NGSI: Managing Context Information at Large Scale
PPTX
IoT on the Edge
PDF
FIWARE Overview of Generic Enablers
PPTX
201410 1 fiware-overview
PPT
PPTX
Fiware IoT_IDAS_intro_ul20_v2
PPTX
FIWARE Primer - Learn FIWARE in 60 Minutes
PPTX
IoT-Broker Developers Week
PPTX
Supporting an Advanced User Experience Using FIWARE
PDF
Microsoft Azure and IoT – how to use
PPTX
Azure IoT Hub
PDF
PPTX
Creating end-to-end IoT applications with Eclipse Kura & Solair IoT Platform
PPTX
apidays LIVE India - Asynchronous and Broadcasting APIs using Kafka by Rohit ...
PPTX
apidays LIVE Jakarta - Building an Event-Driven Architecture by Harin Honesty...
PDF
Advanced MQTT and Kura - EclipseCON 2014
PDF
Smart edge ioT devices enable utility company to create new business segments...
PPTX
apidays LIVE Jakarta - REST the events: REST APIs for Event-Driven Architectu...
PDF
[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform
FIWARE NGSI: Managing Context Information at Large Scale
IoT on the Edge
FIWARE Overview of Generic Enablers
201410 1 fiware-overview
Fiware IoT_IDAS_intro_ul20_v2
FIWARE Primer - Learn FIWARE in 60 Minutes
IoT-Broker Developers Week
Supporting an Advanced User Experience Using FIWARE
Microsoft Azure and IoT – how to use
Azure IoT Hub
Creating end-to-end IoT applications with Eclipse Kura & Solair IoT Platform
apidays LIVE India - Asynchronous and Broadcasting APIs using Kafka by Rohit ...
apidays LIVE Jakarta - Building an Event-Driven Architecture by Harin Honesty...
Advanced MQTT and Kura - EclipseCON 2014
Smart edge ioT devices enable utility company to create new business segments...
apidays LIVE Jakarta - REST the events: REST APIs for Event-Driven Architectu...
[WSO2Con EU 2017] Building Smart, Connected Products with WSO2 IoT Platform
Ad

Viewers also liked (12)

PDF
FIWARE Generic Enablers introduction
PDF
FIWARE Complex Event Processing
PDF
FIWARE ID Management
PDF
FIWARE Lab
PDF
FINODEX summary. Year 1
PDF
Dealing with Data Diversity in a Smart City Data Hub
PDF
Open Data Conference - Rufus Pollock - Open Knowledge Foundation & CKAN
PPTX
FIWARE From Open Data to Open APIs
PDF
NGSIを利用するプラットフォームFIWAREとは何か?(in Japanese)
PDF
FI-WARE Basic Guide
PDF
How to Make Awesome SlideShares: Tips & Tricks
PDF
Getting Started With SlideShare
FIWARE Generic Enablers introduction
FIWARE Complex Event Processing
FIWARE ID Management
FIWARE Lab
FINODEX summary. Year 1
Dealing with Data Diversity in a Smart City Data Hub
Open Data Conference - Rufus Pollock - Open Knowledge Foundation & CKAN
FIWARE From Open Data to Open APIs
NGSIを利用するプラットフォームFIWAREとは何か?(in Japanese)
FI-WARE Basic Guide
How to Make Awesome SlideShares: Tips & Tricks
Getting Started With SlideShare
Ad

Similar to FIWARE Context Broker (20)

PPTX
Orion Context Broker 1.15.0
PPTX
orioncontextbroker-20180615
PPTX
FIWARE: Managing Context Information at large scale
PPTX
Orion Context Broker 20180928
PPTX
Orion Context Broker 2020-03-25
PPTX
Orion Context Broker 20190214
PPTX
Orion Context Broker 20181218
PPTX
Orion Context Broker 20191021
PPTX
Orion Context Broker 2020-10-28
PPTX
Orion Context Broker introduction 20250509
PPTX
Orion Context Broker 20210602
PPTX
Orion Context Broker 20210412
PPTX
Orion Context Broker 2020-10-29
PPTX
Orion Context Broker 20220526
PPTX
Orion Context Broker introduction 20240911
PPTX
Orion Context Broker 20220301
PPTX
Orion Context Broker 20211209
PPTX
Orion Context Broker 20210907
PPTX
Orion Context Broker 20211022
PPTX
Orion Context Broker 20220127
Orion Context Broker 1.15.0
orioncontextbroker-20180615
FIWARE: Managing Context Information at large scale
Orion Context Broker 20180928
Orion Context Broker 2020-03-25
Orion Context Broker 20190214
Orion Context Broker 20181218
Orion Context Broker 20191021
Orion Context Broker 2020-10-28
Orion Context Broker introduction 20250509
Orion Context Broker 20210602
Orion Context Broker 20210412
Orion Context Broker 2020-10-29
Orion Context Broker 20220526
Orion Context Broker introduction 20240911
Orion Context Broker 20220301
Orion Context Broker 20211209
Orion Context Broker 20210907
Orion Context Broker 20211022
Orion Context Broker 20220127

Recently uploaded (20)

PDF
Softaken Excel to vCard Converter Software.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Introduction to Artificial Intelligence
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
PDF
Digital Strategies for Manufacturing Companies
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
Transform Your Business with a Software ERP System
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
medical staffing services at VALiNTRY
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
System and Network Administration Chapter 2
PDF
AI in Product Development-omnex systems
PPTX
Online Work Permit System for Fast Permit Processing
Softaken Excel to vCard Converter Software.pdf
Design an Analysis of Algorithms II-SECS-1021-03
Introduction to Artificial Intelligence
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
Internet Downloader Manager (IDM) Crack 6.42 Build 42 Updates Latest 2025
Digital Strategies for Manufacturing Companies
ManageIQ - Sprint 268 Review - Slide Deck
Transform Your Business with a Software ERP System
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
medical staffing services at VALiNTRY
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Adobe Illustrator 28.6 Crack My Vision of Vector Design
2025 Textile ERP Trends: SAP, Odoo & Oracle
CHAPTER 2 - PM Management and IT Context
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Upgrade and Innovation Strategies for SAP ERP Customers
System and Network Administration Chapter 2
AI in Product Development-omnex systems
Online Work Permit System for Fast Permit Processing

FIWARE Context Broker

  • 1. Pasquale Vitale Engineering Ingegneria Informatica FIWARE Contex Broker
  • 2. Introduction Managing Context Information at large scale FIWARE Context Broker GE (implementation: Orion) Creating and pulling data Pushing data and notifications Convenience operations
  • 3. Managing Context Information at large scale Context Information is represented through values assigned to attributes The Context Broker is able to: handle context information at large scale enable your application to query on context information subscribe to changes in context information that will be received through notifications enable your application or other applications to modify the context information
  • 4. Context Management in FIWARE Context Information: the value of attributes that characterize those entities relevant to your application NGSI API Bus • Location • No. passengers • Driver • License plate Citizen • Name-Surname • Birthday • Preferences • Location • To Do list Shop • Location • Business name • Franchise • Offerings Applications/Services Context Broker
  • 5. 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? … but programmers should just care about entities and their attributes Context Information independent from the source Context information may come from many sources using different interfaces and protocols …
  • 6. Context Management in FIWARE Get notified when an update on context information takes place Bus = “X”, last_stop = “A”, arrived= “Yes” push Notify me when bus “X” arrives at the bus stop “A” API
  • 7. 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” API
  • 8. FIWARE Context Broker GE: Orion Main functions: Context availability management - OMA NGSI-9 specs Context management - OMA NGSI-10 specs HTTP and REST-based XML payload support JSON payload support
  • 9. FIWARE Context Broker GE: Orion Functions Operations NGSI-9 • Register, • Search, • Subscribe for context sources • registerContext • discoverContextAvailability • subscribeContextAvailability • updateContextAvailabilitySubscription • unsubscribeContextAvailability NGSI-10 • Query, • Update, • Subscribe to context elements • updateContext • queryContext • subscribeContext • updateContextSubscription • unsubscribeContextSubscription
  • 10. FIWARE Context Broker GE: Orion Context in NGSI is based in an entity-attribute model: Attributes • Name • Type • Value Entity • EntityId • EntityType 1 n “has”
  • 11. FIWARE Context Broker GE: Orion Orion Architecture 11 Orion Context Broker Context Producers Context Consumers subscriptions update query notify notify update update DB 1026 1026
  • 12. Context Broker operations: create and 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 Context Consumer queryContext Context Producer updateContext Context Broker speed
  • 13. Entity creation example: car create updateContext operation with APPEND action type POST localhost:1026/v1/updateContext ...  { "contextElements": [ { "type": "Car", "isPattern": "false", "id": "Car1", "attributes": [ { "name": "speed", "type": "float", "value": "98" } ] } ], "updateAction": "APPEND" } 200 OK ...  { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "speed", "type": "float", "value": "" } ], "id": "Car1", "isPattern": "false", "type": "Car" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ] }
  • 14. Update context elements example: car updateContext updateContext operation with UPDATE action type POST localhost:1026/v1/updateContext ...  { "contextElements": [ { "type": "Car", "isPattern": "false", "id": "Car1", "attributes": [ { "name": "speed", "type": "float", "value": "110" } ] } ], "updateAction": "UPDATE" } 200 OK ...  { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "speed", "type": "float", "value": "" } ], "id": "Car1", "isPattern": "false", "type": "Car" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ] }
  • 15. Query context operation example: car queryContext queryContext operation by Id POST <cb_host>:1026/v1/queryContext ...  { "entities": [ { "type": "Car", "isPattern": "false", "id": "Car1" } ] }  200 OK ...  { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "speed", "type": "float", "value": "110" } ], "id": "Car1", "isPattern": "false", "type": "Car" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ] }
  • 16. Entity creation example: room create POST localhost:1026/v1/updateContext ...  { "contextElements": [ { "type": "Room", "isPattern": "false", "id": "Room1", "attributes": [ { "name": "temperature", "type": "float", "value": "24" }, { "name": "pressure", "type": "integer", "value": "718" } ] } ], "updateAction": "APPEND" } 200 OK ...  { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "float", "value": "" }, { "name": "pressure", "type": "integer", "value": "" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ] } Two attributes: temperature and pressure
  • 17. Update context elements example: room updateContext POST localhost:1026/v1/updateContext ...  { "contextElements": [ { "type": "Room", "isPattern": "false", "id": "Room1", "attributes": [ { "name": "temperature", "type": "float", "value": "25" }, { "name": "pressure", "type": "integer", "value": "720" } ] } ], "updateAction": "UPDATE" } 200 OK ...  { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "float", "value": "" }, { "name": "pressure", "type": "integer", "value": "" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ] } Update: temperature and pressure
  • 18. Query context operation example: room queryContext queryContext operation by Id POST <cb_host>:1026/v1/queryContext ...  { "entities": [ { "type": “Room", "isPattern": "false", "id": “Room1" } ] }  200 OK ...  { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "float", "value": "25" }, { "name": "pressure", "type": "integer", "value": "720" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ] }
  • 19. Query context operation example: room queryContext queryContext operation by Id and attribute POST <cb_host>:1026/v1/queryContext ...  { "entities": [ { "type": “Room", "isPattern": "false", "id": "Room1" } ] , "attributes": [ "temperature" ] }  200 OK ...  { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "float", "value": "25" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ] }
  • 20. Entity creation example: room create POST localhost:1026/v1/updateContext ...  { "contextElements": [ { "type": "Room", "isPattern": "false", "id": "Room2", "attributes": [ { "name": "temperature", "type": "float", "value": “33" }, { "name": "pressure", "type": "integer", "value": “722" } ] } ], "updateAction": "APPEND" } 200 OK ...  { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "float", "value": "" }, { "name": "pressure", "type": "integer", "value": "" } ], "id": "Room2", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ] } Append another room: Room2
  • 21. Query context operation example: room queryContext queryContext operation by regex Room.* POST <cb_host>:1026/v1/queryContext ...  { "entities": [ { "type": “Room", "isPattern": “true", "id": "Room.*" } ] , "attributes": [ "temperature" ] }  { "contextResponses": [ { "contextElement": { "attributes": [ { "name": "temperature", "type": "float", "value": "25" } ], "id": "Room1", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } }, { "contextElement": { "attributes": [ { "name": "temperature", "type": "float", "value": “33" } ], "id": "Room2", "isPattern": "false", "type": "Room" }, "statusCode": { "code": "200", "reasonPhrase": "OK" } } ] }
  • 22. 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) Context Consumer notifyContext (subscription_id, data/context) Context Broker Application
  • 23. Context subscriptions example: ONTIMEINTERVAL POST <cb_host>:1026/v1/subscribeContext … { "entities": [ { "type": "Room", "isPattern": "false", "id": "Room1" } ], "attributes": [ "temperature" ], "reference": "http://<host>:<port>/publish", "duration": "P1M", "notifyConditions": [ { "type": "ONTIMEINTERVAL", "condValues": [ “PT10S" ] } ] } 200 OK ...  { "subscribeResponse": { "duration": "P1M", "subscriptionId": "54dcb87fa85d63b107245ff1" } } 25 19
  • 24. Context subscriptions example: ONCHANGE POST <cb_host>:1026/v1/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 19
  • 26. 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
  • 27. Convenience Operations Entities GET /v1/contextEntities/{entityID} Query Context Retrieves an entity POST /v1/contextEntities/{entityID} Entity Creation Creates an entity PUT /v1/contextEntities/{entityID} Update Context Updates an entity DELETE /v1/contextEntities/{entityID} Delete Context Deletes an entity GET all entities GET /v1/contextEntities
  • 28. Convenience Operations 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
  • 29. Convenience Operations Subscriptions POST /v1/contextSubscriptions Creates a subscription PUT / v1/contextSubscriptions/{subID} Updates a subscription DELETE / v1/contextSubscriptions/{subID} Deletes a subscription
  • 30. Convenience Operations 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
  • 31. Advanced features Pagination Compound attribute values Metadata Geo-location Registrations & context providers Entity service paths
  • 32. 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")
  • 33. 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 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
  • 34. 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 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" }
  • 35. Metadata Users may attach metadata to attributes Reserved metadatas: ID, Location, creDate and modDate Examples: … "attributes": [ { "name": "temperature", "type": "float", "value": "26.5", "metadatas": [ { "name": "accuracy", "type": "float", "value": "0.9" } ] } ] … … "attributes": [ { "name": "temperature", "type": "float", "value": "26.5", "metadatas": [ { "name": "average", "type": "float", "value": "22.4" } ] } ] … Context Element attributes • Name • Type • Value Context Element • EntityId • EntityType n “has” 1 Metadata • Name • Type • Valuen “has” 1
  • 36. Geo-location Entities can have an attribute that specifies its location - Using a "location" metadata Example: create an entity called Madrid (of type "City") with attribute "position" defined as location POST <cb_host>:1026/v1/updateContext { "contextElements": [ { "type": "City", "isPattern": "false", "id": "Madrid", "attributes": [ { "name": "position", "type": "coords", "value": "40.418889, ‐3.691944", "metadatas": [ { "name": "location", "type": "string", "value": "WGS84" } ] } ] } ], "updateAction": "APPEND" } Coordinates for Madrid are: • latitude 40.418889 • longitude 3.691944
  • 37. Geo-located queries Entities location can be used in queryContex using: - FIWARE::Location as scopeType - and an area specification as scopeValue The area specification are: - area internal to a circle, given its centre and radius - area external to a circle, given its centre and radius - area internal to a polygon, given its vertices - area external to a polygon, given its vertices { "entities": [ { "type": "Point", "isPattern": "true", "id": ".*" } ], "restriction": { "scopes": [ { "type" : "FIWARE::Location", "value" : { "polygon": { "vertices": [ { "latitude": "0", "longitude": "0" }, { "latitude": "0", "longitude": "6" }, { "latitude": "6", "longitude": "6" }, { "latitude": "6", "longitude": "0" } ] } } } ] } }
  • 38. Geo-location - circle Distances between: - Madrid / Alcobendas 13.65 km - Madrid / Leganes 12.38 km Consider a radius of 13.5 km POST <cb_host>:1026/v1/queryContext … { "entities": [ { "type": "City", "isPattern": "true", "id": ".*" } ], "restriction": { "scopes": [ { "type" : "FIWARE::Location", "value" : { "circle": { "centerLatitude": "40.418889", "centerLongitude": "‐3.691944", "radius": "13500" } } } ] } } The query is Madrid and Leganes
  • 39. Geo-location - inverse circle Distances between: - Madrid / Alcobendas 13.65 km - Madrid / Leganes 12.38 km Consider a radius of 13.5 km POST <cb_host>:1026/v1/queryContext { "entities": [ { "type": "City", "isPattern": "true", "id": ".*" } ], "restriction": { "scopes": [ { "type" : "FIWARE::Location", "value" : { "circle": { "centerLatitude": "40.418889", "centerLongitude": "‐3.691944", "radius": "13500", "inverted": "true" } } } ] } } The query is Alcobendas
  • 40. Registration & Context Providers Context Broker doesn't cache the result of the query internally Application Context Broker Context Provider 1. registerContext(provider= ) 2. queryContext(id) 3. queryContext(id) 4. data5. data Context Consumer db
  • 41. Registration & Context Providers 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" } The application registers the Context Provider for the Car1 speed using providingApplication attribute Application registerContext http://contextprovider.com/Cars
  • 43. Multitenancy Context Broker implements a simple multitenant/multiservice model based and logical database separation Make easer service/tenant based authorization policies provided by other FI-WARE components or third party software Orion uses the "Fiware-Service" HTTP header in the request to identify the service/tenant Example: Fiware-Service: Tenant1 Context Broker Context Broker Tenant1 Tenant2 … entities1/attributes1/subscripitions1 entities2/attributes2/subscripitions2
  • 44. Entity Service Paths Orion Context Broker supports hierarchical scopes Entities can be assigned to a scope at creation time with updateContext queryContext can be also scoped to locate entities in the corresponding scopes For example, consider the following scopes in the figure: - Madrid, as first level scope - Gardens and Districts, as second-level scope (children of Madrid) - ParqueNorte, ParqueOeste and ParqueSur (children of Gardens) and Fuencarral and Latina (children of Districts) - Parterre1 and Parterre2 (children of ParqueNorte)
  • 45. 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 ParqueNorte Parterre2Parterre1
  • 46. Entity Service Paths Properties: 1. A query on a service path will look only into the specified node 2. Use ParentNode/# to include all child nodes 3. Queries without Fiware-ServicePath resolve to /# 4. Entities will fall in the "/" node by default 5. 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 1. You can have the same element IDs in different scopes (be careful with this!) 2. You can't change scope once the element is created 3. One entity can belong to only one scope A B A or B ParqueNorte Parterre1 light1 light1