SlideShare a Scribd company logo
Session 3 - Core Context Management
Fernando López, Cloud & Platform Senior Expert
fernando.lopez@fiware.org
@flopezaguilar
FIWARE Foundation, e.V.
1
Did you
understand
anything?
I haven't understand
anything yet. And
You?
Me neither…
Ok, lets follow with
our poker faces…
2
Captain, may I ask
now some
questions?
Sure…
I mean, a question
after this one…
Spock!!!
Learning Goals
▪ General overview of Orion Context Broker architecture
▪ Introduction to NGSI, NGSIv2
▪ Creating and pulling data
▪ Pushing data and notifications
▪ Batch operations
3
4
Orion Context Broker
General concepts
▪ Context data represents the state of a physical or conceptual object which exists in the
real world.
▪ The Orion Context Broker maintains a representation of the state of the entities:
• Entered programmatically
• Retrieved from sensors
• Augmented by other sources such as webservices, other context brokers etc.
▪ The Context Broker only holds the current state - it has no memory
5
General concepts
▪ NGSI v2 is a vendor-neutral standardized interface for interactions within FIWARE
• Simple REST API for CRUD
• Subscriptions can be used raise events to send data to other microservices
• Registrations can be used to retrieve context from other sources
• Also supports Query Filtering + Pagination + Geoqueries
• Use the Open API Specification to generate a library
6
Orion Context Broker
7
▪ Main functions:
▪ Context management
▪ Context availability management (advanced topic)
▪ HTTP and REST-based
▪ JSON payload support
▪ Context in NGSI is based in an entity-attribute-metadata model:
Orion Context Broker in a nutshell
8
Context
Producers
Context
Consumers
subscriptions
update
query
notify
notify
update
update
Mongo
DB
1026
1026
Orion Context Broker – check health
9
GET <cb_host>:1026/version
{
"orion" : {
"version" : "2.3.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"
}
}
10
Introduction to NGSI, NGSIv2
Two “flavours” of NGSI API
11
▪ 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
▪ Enhanced functionality compared with NGSIv1 (eg. filtering)
▪ Stable, ready for production, version already available
▪ Current NGSIv2 version is Release Candidate 2018.07 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
Basic Concepts
12
▪ Entity
▪ Any kind of thing of interest. It has many attributes
o id : Entity identifier
o type : Entity type
▪ Attributes
▪ Represent an observable property of an entity
o name
o type
o value
o additional “extra sub-properties” (metadata in NGSI terminology)
Entity Examples in NGSIv2
13
{
“id”: “Traffic-Incidence-9876”,
“type”: “gsmadata:TrafficIncidence”,
“category”: “Vehicle Fault”,
“severity”: “Yellow”,
“vehicleType”: “Truck”,
“startDate”: "2015-07-17T09:31:11.112Z”
“roadName”: “N-122”,
“description”: “A truck is stopped on road”
}
{
“id”: “r786543”,
“type”: “Room”,
“name”: “Chrisantemum”,
“temperature”: 22,
“seatNumber”: 10,
“location”: {
“type”: “Point”,
“coordinates”: [31.2222200, 121.4580600]
}
}
JSON payload features
14
▪ Flexible to accommodate different data flavours
▪ Terse (only the essential is provided)
▪ Simple and ready for front-end data consumers
▪ It can represent any dataset
▪ As a collection of entities with the same type
API Overview
15
▪ Simple operations (RESTful)
▪ Useful for app developers (Northbound interfaces)
▪ One “transaction” per request
▪ Bulk operations (RPC Style → HTTP POST)
▪ Allow to perform many simple operations at the same time
▪ Mostly useful for more complex backend processes
o South / Eastbound interfaces
o Original OMA-NGSI with simplified payload binding
Simple Operations
16
▪ Query Operations
▪ Northbound interfaces
▪ Update Operations
▪ For creating new data available on the system
▪ Subscribe operations
▪ For subscription to change in data
▪ Register operations
▪ For associating external providers to data items
Simple Operations
17
▪ Query data collections
▪ GET /entities?q=<SimpleQuery>&options=<opts>
▪ Query specific data instances
▪ GET /entities/<id>
▪ Insert new data instances
▪ POST /entities
▪ Update data instances
▪ PATCH /entities/<id>
Simple Operations: Query Operations I
18
▪ What are the Mercedes Vehicles currently at a radius of 10 kms with center Gangnam-Gu (Seoul)?
GET
/v2/entities?type=Vehicle&geometry=point&coords=37.496667,127.0275&georel=near;maxDistance=10000
▪ What are the vehicles currently at a radius of 10 kms with center Gangnam-Gu?
GET
/v2/entities?type=Vehicle&coords=37.496667,127.0275&geometry=point;
&georel=near;maxDistance=10000&q=manufacturer:’Mercedes Benz’
Simple Operations: Query Operations II
19
▪ Tell me rooms on which temperature is less than 23 degrees and have at least 10 seats
GET /v2/entities?type=VehicleFault&q=startDate>=2019-11-11T00:00:00
▪ Tell me vehicle faults which happened today
GET /v2/entities?type=Room&q=temperature<23;seatNumber>=10
Simple Operations: Query payload examples
20
[
{
“id”: “123-456-789”,
“type”: “Vehicle”,
“model”: “C200”,
“brand”: “Mercedes Benz”,
“buildYear”: “2010”
},
{
“id”: “000-987-654”,
“type”: “Vehicle”,
“model”: “Astra”,
“brand”: “Opel”,
“buildYear”: “2003”
}
]
[
{
“id”: “123890-22222”,
“type”: “VehicleFault”,
“location”: {
“type”: “point”,
“coordinates”: [40.41, -3.70]
}
“startDate”: 2015-07-17T11:12:42.540Z”
}
]
Simple Operations: Query Operations III
21
GET /v2/entities/r786543/attrs/temperature/value
▪ Tell me the temperature at the Chrisantemum room
▪ Only Value is returned → The most abbreviated response
GET /v2/entities?type=CarBrand&attrs=name&options=values
▪ Tell me the known car brands
23.5
[“Ford”, “Mercedes Benz”, “Hyundai”]
22
Creating and Pulling data
Context Broker operations: create & pull data
23
▪ 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
Quick Usage Example: Car Create
24
201 Created
POST <cb_host>:1026/v2/entities
Content-Type: application/json
...
{
"id": "Car1",
"type": "Car",
"speed": {
"type": "Float",
"value": 98
}
}
Quick Usage Example: Car Speed Update I
25
PUT <cb_host>:1026/v2/entities/Car1/attrs/speed
Content-Type: application/json
...
{
"type": "Float",
"value": 110
}
204 No Content
…
In the case of id ambiguity, you can use
"?type=Car" to specify entity type
Quick Usage Example: Car Speed Query I
26
200 OK
Content-Type: application/json
...
{
"type": "Float",
"value": 110,
"metadata": {}
}
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
Quick Usage Example: Car Speed Update II
27
PUT <cb_host>:1026/v2/entities/Car1/attrs/speed/value
Content-Type: text/plain
...
115
204 No Content
…
Quick Usage Example: Car Speed Query II
28
200 OK
Content-Type: text/plain
...
115.000000
GET <cb_host>:1026/v2/entities/Car1/attrs/speed/value
Accept: text/plain
Quick Usage Example: Room Create I
29
201 Created
...
POST <cb_host>:1026/v2/entities
Content-Type: application/json
...
{
"id": "Room1",
"type": "Room",
"temperature": {
"type": "Float",
"value": 24
},
"pressure": {
"type": "Integer",
"value": 718
}
}
Quick Usage Example: Room Update I
30
204 No Content
…
PATCH <cb_host>:1026/v2/entities/Room1/attrs
Content-Type: application/json
...
{
"temperature“: {
"type": "Float",
"value": 27,9
},
"pressure": {
"type": "Integer",
"value": 720
}
}
Quick Usage Example: Room Query I
31
200 OK
Content-Type: application/json
...
{
"pressure": {
"type": "Integer",
"value": 720,
"metadata": {}
},
"temperature": {
"type": "Float",
"value": 27.9,
"metadata": {}
}
}
GET <cb_host>:1026/v2/entities/Room1/attrs
Quick Usage Example: Room Query II
32
200 OK
Content-Type: application/json
...
{
"pressure": 720,
"temperature": 27.9
}
GET <cb_host>:1026/v2/entities/Room1/attrs?options=keyValues
Quick Usage Example: Room Create II
33
201 Created
...
POST <cb_host>:1026/v2/entities
Content-Type: application/json
...
{
"id": "Room2",
"type": "Room",
"temperature": {
"type": "Float",
"value": 29
},
"pressure": {
"type": "Integer",
"value": 730
}
}
Quick Usage Example: Filters I
34
200 OK
Content-Type: application/json
...
[
{
"id": "Room2",
"pressure": 730,
"temperature": 29,
"type": "Room"
}
]
GET <cb_host>:1026/v2/entities?options=keyValues&q=temperature>28
Quick Usage Example: Filters II
35
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
36
Push data
Context
Consumer
update
Context
Broker
subId = subscribeContext (consumer, expr, expiration)
notify (subId, data/context)
Context Broker operations: push data
37
▪ 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.
Context
Producer
Application
Quick Usage Example: Subscription
38
POST <cb_host>:1026/v2/subscriptions
Content-Type: application/json
…
{
"subject": {
"entities": [
{
"id": "Room1",
"type": "Room"
}
],
"condition": {
"attrs": [ "temperature" ]
}
},
"notification": {
"http": {
"url": "http://<host>:<port>/publish"
},
"attrs": [ "temperature" ]
},
"expires": "2026-04-05T14:00:00.00Z"
}
201 Created
Location: /v2/subscriptions/51c0ac9ed714fb3b37d7d5a8
...
Quick Usage Example: Notification
39
POST /publish HTTP/1.1
Content-type: application/json; charset=utf-8
Ngsiv2-AttrsFormat: normalized
…
{
"subscriptionId": "574d720dbef222abb860534a",
"data": [
{
"id": "Room1",
"type": "Room",
"temperature": {
"type": "Float",
"value": 17.8,
"metadata": {}
}
}
]
}
27.9
17.8
List existing subscriptions
40
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
41
Batch operations
Orion Context Broker: batch operations
42
▪ 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
Special update action types
43
▪ 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
Batch Operation Example: Create Several Rooms
44
201 Created
...
POST <cb_host>:1026/v2/op/update
Conten-Type: application/json
...
{
"actionType": "APPEND",
"entities": [
{
"type": "Room",
"id": "Room3",
"temperature": {
"value": 21.2,
"type": "Float"
},
"pressure": {
"value": 722,
"type": "Integer"
}
},
…
…
{
"type": "Room",
"id": "Room4",
"temperature": {
"value": 31.8,
"type": "Float"
},
"pressure": {
"value": 712,
"type": "Integer"
}
}
]
}
Orion advanced functionality… next seminar!
45
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
Summary: Terms
46
● JSON, JavaScript Object Notation is an open-standard file format that uses human-readable text to
transmit data objects consisting of attribute–value pairs and array data types.
● NGSIv2, version 2 of the Open Mobile Alliance (OMA) Next Generation Service Interfaces (NGSI).
● Publish,
● Subscribe,
● Notify,
● Pulling mechanism,
● Pushing mechanism,
References
47
● FIWARE Catalogue
o https://www.fiware.org/developers/catalogue
● NGSIv2 Specification
o http://fiware.github.io/specifications/ngsiv2/stable
o http://fiware.github.io/specifications/ngsiv2/latest
● Orion support though StackOverflow
o Ask your questions using the “fiware-orion” tag
o Look for existing questions at http://stackoverflow.com/questions/tagged/fiware-orion
Question & Answer
48
fiware-tech-help@lists.fiware.org
Core Context Management
5
0

More Related Content

What's hot (20)

PDF
FIWARE Wednesday Webinars - Cities as Enablers of the Data Economy: Smart Dat...
FIWARE
 
PDF
FIWARE Wednesday Webinars - Integrating FIWARE with Blockchain/DLTs
FIWARE
 
PDF
FIWARE Wednesday Webinars - The Use of DDS Middleware in Robotics (Part 1)
FIWARE
 
PDF
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE
 
PDF
DKAN Drupal Distribution Presentation at Drupal Gov Days 2013
Andrew Hoppin
 
PDF
Real time analytics on deep learning @ strata data 2019
Zhenxiao Luo
 
PDF
FIWARE Wednesday Webinars - Architecting Your Smart Solution Using FIWARE
FIWARE
 
PPTX
Closing Keynote
Neo4j
 
PDF
CZJUG Intro - BI Platform as a Service - a case for Java in the Cloud
Jaroslav Gergic
 
PDF
FIWARE Tech Summit - Publishing Context Info As Open Data
FIWARE
 
PDF
IoT Interoperability: a Hub-based Approach
Michael Blackstock
 
PDF
2013 Enterprise Track, Building GIS, Decision Support, and Location Intellige...
GIS in the Rockies
 
PDF
FIWARE Global Summit - Using ML/AI Techniques with FIWARE and Connected IoT D...
FIWARE
 
PDF
FIWARE Training: IoT and Legacy
FIWARE
 
PDF
Ultralight data movement for IoT with SDC Edge. Guglielmo Iozzia - Optum
Data Driven Innovation
 
PPTX
Azure Digital Twins 2.0
Marco Parenzan
 
PDF
DataGraft: Data-as-a-Service for Open Data
dapaasproject
 
PPTX
20181012 fiware at_construction_conference
stefano de panfilis
 
PDF
Interoperability rules for an European API ecosystem: do we still need SOAP?
Roberto Polli
 
PPTX
App Mashup GE: WireCloud - Startup Weekend
Miguel Jiménez
 
FIWARE Wednesday Webinars - Cities as Enablers of the Data Economy: Smart Dat...
FIWARE
 
FIWARE Wednesday Webinars - Integrating FIWARE with Blockchain/DLTs
FIWARE
 
FIWARE Wednesday Webinars - The Use of DDS Middleware in Robotics (Part 1)
FIWARE
 
FIWARE Global Summit - A Multi-database Plugin for the Orion FIWARE Context B...
FIWARE
 
DKAN Drupal Distribution Presentation at Drupal Gov Days 2013
Andrew Hoppin
 
Real time analytics on deep learning @ strata data 2019
Zhenxiao Luo
 
FIWARE Wednesday Webinars - Architecting Your Smart Solution Using FIWARE
FIWARE
 
Closing Keynote
Neo4j
 
CZJUG Intro - BI Platform as a Service - a case for Java in the Cloud
Jaroslav Gergic
 
FIWARE Tech Summit - Publishing Context Info As Open Data
FIWARE
 
IoT Interoperability: a Hub-based Approach
Michael Blackstock
 
2013 Enterprise Track, Building GIS, Decision Support, and Location Intellige...
GIS in the Rockies
 
FIWARE Global Summit - Using ML/AI Techniques with FIWARE and Connected IoT D...
FIWARE
 
FIWARE Training: IoT and Legacy
FIWARE
 
Ultralight data movement for IoT with SDC Edge. Guglielmo Iozzia - Optum
Data Driven Innovation
 
Azure Digital Twins 2.0
Marco Parenzan
 
DataGraft: Data-as-a-Service for Open Data
dapaasproject
 
20181012 fiware at_construction_conference
stefano de panfilis
 
Interoperability rules for an European API ecosystem: do we still need SOAP?
Roberto Polli
 
App Mashup GE: WireCloud - Startup Weekend
Miguel Jiménez
 

Similar to Core Context Management (20)

PDF
FIWARE Tech Summit - FIWARE NGSIv2 Introduction
FIWARE
 
PPTX
Context Information Management in IoT enabled smart systems - the basics
Fernando Lopez Aguilar
 
PPTX
FIWARE: Managing Context Information at Large Scale (NGSIv1)
Fermin Galan
 
PPTX
FIWARE NGSI: Managing Context Information at Large Scale
FIWARE
 
PPTX
Orion Context Broker
TIDChile
 
PPTX
Context-aware application development with FIWARE #CPBR8
Fermin Galan
 
PPTX
Orion Context Broker 1.15.0
Fermin Galan
 
PPTX
orioncontextbroker-20180615
Fermin Galan
 
PPTX
Orion Context Broker 20210602
Fermin Galan
 
PPTX
Orion Context Broker 20210412
Fermin Galan
 
PPTX
FIWARE: Managing Context Information at large scale
Fermin Galan
 
PPTX
Orion Context Broker 20210907
Fermin Galan
 
PPTX
Orion Context Broker 20220526
Fermin Galan
 
PPTX
Orion Context Broker 20211209
Fermin Galan
 
PPTX
Orion Context Broker 20220127
Fermin Galan
 
PPTX
Orion Context Broker 20211022
Fermin Galan
 
PPTX
Orion Context Broker 20220301
Fermin Galan
 
PPTX
TMForum Open:Hack - FIWARE Training Session
Aitor Magán García
 
PPTX
Orion Context Broker introduction 20250509
Fermin Galan
 
PPTX
Orion Context Broker 20181218
Fermin Galan
 
FIWARE Tech Summit - FIWARE NGSIv2 Introduction
FIWARE
 
Context Information Management in IoT enabled smart systems - the basics
Fernando Lopez Aguilar
 
FIWARE: Managing Context Information at Large Scale (NGSIv1)
Fermin Galan
 
FIWARE NGSI: Managing Context Information at Large Scale
FIWARE
 
Orion Context Broker
TIDChile
 
Context-aware application development with FIWARE #CPBR8
Fermin Galan
 
Orion Context Broker 1.15.0
Fermin Galan
 
orioncontextbroker-20180615
Fermin Galan
 
Orion Context Broker 20210602
Fermin Galan
 
Orion Context Broker 20210412
Fermin Galan
 
FIWARE: Managing Context Information at large scale
Fermin Galan
 
Orion Context Broker 20210907
Fermin Galan
 
Orion Context Broker 20220526
Fermin Galan
 
Orion Context Broker 20211209
Fermin Galan
 
Orion Context Broker 20220127
Fermin Galan
 
Orion Context Broker 20211022
Fermin Galan
 
Orion Context Broker 20220301
Fermin Galan
 
TMForum Open:Hack - FIWARE Training Session
Aitor Magán García
 
Orion Context Broker introduction 20250509
Fermin Galan
 
Orion Context Broker 20181218
Fermin Galan
 
Ad

More from Fernando Lopez Aguilar (20)

PDF
Introduction to FIWARE technology
Fernando Lopez Aguilar
 
PDF
DW2020 Data Models - FIWARE Platform
Fernando Lopez Aguilar
 
PPTX
How to deploy a smart city platform?
Fernando Lopez Aguilar
 
PDF
Data Modeling with NGSI, NGSI-LD
Fernando Lopez Aguilar
 
PDF
FIWARE and Robotics
Fernando Lopez Aguilar
 
PDF
Big Data and Machine Learning with FIWARE
Fernando Lopez Aguilar
 
PDF
Creating a Context-Aware solution, Complex Event Processing with FIWARE Perseo
Fernando Lopez Aguilar
 
PDF
Data persistency (draco, cygnus, sth comet, quantum leap)
Fernando Lopez Aguilar
 
PDF
How to debug IoT Agents
Fernando Lopez Aguilar
 
PDF
What is an IoT Agent
Fernando Lopez Aguilar
 
PDF
Overview of the FIWARE Ecosystem
Fernando Lopez Aguilar
 
PPTX
Cloud and Big Data in the agriculture sector
Fernando Lopez Aguilar
 
PDF
Berlin OpenStack Summit'18
Fernando Lopez Aguilar
 
PPTX
FIWARE IoT Introduction 1
Fernando Lopez Aguilar
 
PPTX
Introduction to FIWARE IoT
Fernando Lopez Aguilar
 
PPTX
Setting up your virtual infrastructure using FIWARE Lab Cloud
Fernando Lopez Aguilar
 
PDF
Connecting to the internet of things (IoT)
Fernando Lopez Aguilar
 
PPTX
Fiware, the future internet
Fernando Lopez Aguilar
 
PPTX
Fiware, the future internet
Fernando Lopez Aguilar
 
PPTX
How to deploy spark instance using ansible 2.0 in fiware lab v2
Fernando Lopez Aguilar
 
Introduction to FIWARE technology
Fernando Lopez Aguilar
 
DW2020 Data Models - FIWARE Platform
Fernando Lopez Aguilar
 
How to deploy a smart city platform?
Fernando Lopez Aguilar
 
Data Modeling with NGSI, NGSI-LD
Fernando Lopez Aguilar
 
FIWARE and Robotics
Fernando Lopez Aguilar
 
Big Data and Machine Learning with FIWARE
Fernando Lopez Aguilar
 
Creating a Context-Aware solution, Complex Event Processing with FIWARE Perseo
Fernando Lopez Aguilar
 
Data persistency (draco, cygnus, sth comet, quantum leap)
Fernando Lopez Aguilar
 
How to debug IoT Agents
Fernando Lopez Aguilar
 
What is an IoT Agent
Fernando Lopez Aguilar
 
Overview of the FIWARE Ecosystem
Fernando Lopez Aguilar
 
Cloud and Big Data in the agriculture sector
Fernando Lopez Aguilar
 
Berlin OpenStack Summit'18
Fernando Lopez Aguilar
 
FIWARE IoT Introduction 1
Fernando Lopez Aguilar
 
Introduction to FIWARE IoT
Fernando Lopez Aguilar
 
Setting up your virtual infrastructure using FIWARE Lab Cloud
Fernando Lopez Aguilar
 
Connecting to the internet of things (IoT)
Fernando Lopez Aguilar
 
Fiware, the future internet
Fernando Lopez Aguilar
 
Fiware, the future internet
Fernando Lopez Aguilar
 
How to deploy spark instance using ansible 2.0 in fiware lab v2
Fernando Lopez Aguilar
 
Ad

Recently uploaded (20)

PPTX
Pengenalan perangkat Jaringan komputer pada teknik jaringan komputer dan tele...
Prayudha3
 
PDF
How Much GB RAM Do You Need for Coding? 5 Powerful Reasons 8GB Is More Than E...
freeshopbudget
 
PPT
Introduction to dns domain name syst.ppt
MUHAMMADKAVISHSHABAN
 
PDF
Data Protection & Resilience in Focus.pdf
AmyPoblete3
 
PPT
1965 INDO PAK WAR which Pak will never forget.ppt
sanjaychief112
 
PDF
Cybersecurity Awareness Presentation ppt.
banodhaharshita
 
PDF
GEO Strategy 2025: Complete Presentation Deck for AI-Powered Customer Acquisi...
Zam Man
 
PPTX
Perkembangan Perangkat jaringan komputer dan telekomunikasi 3.pptx
Prayudha3
 
PPTX
dns domain name system history work.pptx
MUHAMMADKAVISHSHABAN
 
PDF
LOGENVIDAD DANNYFGRETRRTTRRRTRRRRRRRRR.pdf
juan456ytpro
 
PDF
Latest Scam Shocking the USA in 2025.pdf
onlinescamreport4
 
PPTX
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
PDF
The AI Trust Gap: Consumer Attitudes to AI-Generated Content
Exploding Topics
 
DOCX
An_Operating_System by chidi kingsley wo
kingsleywokocha4
 
PDF
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
PPTX
The Latest Scam Shocking the USA in 2025.pptx
onlinescamreport4
 
PPTX
How tech helps people in the modern era.
upadhyayaryan154
 
PPTX
原版北不列颠哥伦比亚大学毕业证文凭UNBC成绩单2025年新版在线制作学位证书
e7nw4o4
 
PPTX
办理方法西班牙假毕业证蒙德拉贡大学成绩单MULetter文凭样本
xxxihn4u
 
PPTX
AI at Your Side: Boost Impact Without Losing the Human Touch (SXSW 2026 Meet ...
maytaldahan
 
Pengenalan perangkat Jaringan komputer pada teknik jaringan komputer dan tele...
Prayudha3
 
How Much GB RAM Do You Need for Coding? 5 Powerful Reasons 8GB Is More Than E...
freeshopbudget
 
Introduction to dns domain name syst.ppt
MUHAMMADKAVISHSHABAN
 
Data Protection & Resilience in Focus.pdf
AmyPoblete3
 
1965 INDO PAK WAR which Pak will never forget.ppt
sanjaychief112
 
Cybersecurity Awareness Presentation ppt.
banodhaharshita
 
GEO Strategy 2025: Complete Presentation Deck for AI-Powered Customer Acquisi...
Zam Man
 
Perkembangan Perangkat jaringan komputer dan telekomunikasi 3.pptx
Prayudha3
 
dns domain name system history work.pptx
MUHAMMADKAVISHSHABAN
 
LOGENVIDAD DANNYFGRETRRTTRRRTRRRRRRRRR.pdf
juan456ytpro
 
Latest Scam Shocking the USA in 2025.pdf
onlinescamreport4
 
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
The AI Trust Gap: Consumer Attitudes to AI-Generated Content
Exploding Topics
 
An_Operating_System by chidi kingsley wo
kingsleywokocha4
 
The Internet of Things (IoT) refers to a vast network of interconnected devic...
chethana8182
 
The Latest Scam Shocking the USA in 2025.pptx
onlinescamreport4
 
How tech helps people in the modern era.
upadhyayaryan154
 
原版北不列颠哥伦比亚大学毕业证文凭UNBC成绩单2025年新版在线制作学位证书
e7nw4o4
 
办理方法西班牙假毕业证蒙德拉贡大学成绩单MULetter文凭样本
xxxihn4u
 
AI at Your Side: Boost Impact Without Losing the Human Touch (SXSW 2026 Meet ...
maytaldahan
 

Core Context Management

  • 1. Session 3 - Core Context Management Fernando López, Cloud & Platform Senior Expert [email protected] @flopezaguilar FIWARE Foundation, e.V.
  • 2. 1 Did you understand anything? I haven't understand anything yet. And You? Me neither… Ok, lets follow with our poker faces…
  • 3. 2 Captain, may I ask now some questions? Sure… I mean, a question after this one… Spock!!!
  • 4. Learning Goals ▪ General overview of Orion Context Broker architecture ▪ Introduction to NGSI, NGSIv2 ▪ Creating and pulling data ▪ Pushing data and notifications ▪ Batch operations 3
  • 6. General concepts ▪ Context data represents the state of a physical or conceptual object which exists in the real world. ▪ The Orion Context Broker maintains a representation of the state of the entities: • Entered programmatically • Retrieved from sensors • Augmented by other sources such as webservices, other context brokers etc. ▪ The Context Broker only holds the current state - it has no memory 5
  • 7. General concepts ▪ NGSI v2 is a vendor-neutral standardized interface for interactions within FIWARE • Simple REST API for CRUD • Subscriptions can be used raise events to send data to other microservices • Registrations can be used to retrieve context from other sources • Also supports Query Filtering + Pagination + Geoqueries • Use the Open API Specification to generate a library 6
  • 8. Orion Context Broker 7 ▪ Main functions: ▪ Context management ▪ Context availability management (advanced topic) ▪ HTTP and REST-based ▪ JSON payload support ▪ Context in NGSI is based in an entity-attribute-metadata model:
  • 9. Orion Context Broker in a nutshell 8 Context Producers Context Consumers subscriptions update query notify notify update update Mongo DB 1026 1026
  • 10. Orion Context Broker – check health 9 GET <cb_host>:1026/version { "orion" : { "version" : "2.3.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" } }
  • 12. Two “flavours” of NGSI API 11 ▪ 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 ▪ Enhanced functionality compared with NGSIv1 (eg. filtering) ▪ Stable, ready for production, version already available ▪ Current NGSIv2 version is Release Candidate 2018.07 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
  • 13. Basic Concepts 12 ▪ Entity ▪ Any kind of thing of interest. It has many attributes o id : Entity identifier o type : Entity type ▪ Attributes ▪ Represent an observable property of an entity o name o type o value o additional “extra sub-properties” (metadata in NGSI terminology)
  • 14. Entity Examples in NGSIv2 13 { “id”: “Traffic-Incidence-9876”, “type”: “gsmadata:TrafficIncidence”, “category”: “Vehicle Fault”, “severity”: “Yellow”, “vehicleType”: “Truck”, “startDate”: "2015-07-17T09:31:11.112Z” “roadName”: “N-122”, “description”: “A truck is stopped on road” } { “id”: “r786543”, “type”: “Room”, “name”: “Chrisantemum”, “temperature”: 22, “seatNumber”: 10, “location”: { “type”: “Point”, “coordinates”: [31.2222200, 121.4580600] } }
  • 15. JSON payload features 14 ▪ Flexible to accommodate different data flavours ▪ Terse (only the essential is provided) ▪ Simple and ready for front-end data consumers ▪ It can represent any dataset ▪ As a collection of entities with the same type
  • 16. API Overview 15 ▪ Simple operations (RESTful) ▪ Useful for app developers (Northbound interfaces) ▪ One “transaction” per request ▪ Bulk operations (RPC Style → HTTP POST) ▪ Allow to perform many simple operations at the same time ▪ Mostly useful for more complex backend processes o South / Eastbound interfaces o Original OMA-NGSI with simplified payload binding
  • 17. Simple Operations 16 ▪ Query Operations ▪ Northbound interfaces ▪ Update Operations ▪ For creating new data available on the system ▪ Subscribe operations ▪ For subscription to change in data ▪ Register operations ▪ For associating external providers to data items
  • 18. Simple Operations 17 ▪ Query data collections ▪ GET /entities?q=<SimpleQuery>&options=<opts> ▪ Query specific data instances ▪ GET /entities/<id> ▪ Insert new data instances ▪ POST /entities ▪ Update data instances ▪ PATCH /entities/<id>
  • 19. Simple Operations: Query Operations I 18 ▪ What are the Mercedes Vehicles currently at a radius of 10 kms with center Gangnam-Gu (Seoul)? GET /v2/entities?type=Vehicle&geometry=point&coords=37.496667,127.0275&georel=near;maxDistance=10000 ▪ What are the vehicles currently at a radius of 10 kms with center Gangnam-Gu? GET /v2/entities?type=Vehicle&coords=37.496667,127.0275&geometry=point; &georel=near;maxDistance=10000&q=manufacturer:’Mercedes Benz’
  • 20. Simple Operations: Query Operations II 19 ▪ Tell me rooms on which temperature is less than 23 degrees and have at least 10 seats GET /v2/entities?type=VehicleFault&q=startDate>=2019-11-11T00:00:00 ▪ Tell me vehicle faults which happened today GET /v2/entities?type=Room&q=temperature<23;seatNumber>=10
  • 21. Simple Operations: Query payload examples 20 [ { “id”: “123-456-789”, “type”: “Vehicle”, “model”: “C200”, “brand”: “Mercedes Benz”, “buildYear”: “2010” }, { “id”: “000-987-654”, “type”: “Vehicle”, “model”: “Astra”, “brand”: “Opel”, “buildYear”: “2003” } ] [ { “id”: “123890-22222”, “type”: “VehicleFault”, “location”: { “type”: “point”, “coordinates”: [40.41, -3.70] } “startDate”: 2015-07-17T11:12:42.540Z” } ]
  • 22. Simple Operations: Query Operations III 21 GET /v2/entities/r786543/attrs/temperature/value ▪ Tell me the temperature at the Chrisantemum room ▪ Only Value is returned → The most abbreviated response GET /v2/entities?type=CarBrand&attrs=name&options=values ▪ Tell me the known car brands 23.5 [“Ford”, “Mercedes Benz”, “Hyundai”]
  • 24. Context Broker operations: create & pull data 23 ▪ 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
  • 25. Quick Usage Example: Car Create 24 201 Created POST <cb_host>:1026/v2/entities Content-Type: application/json ... { "id": "Car1", "type": "Car", "speed": { "type": "Float", "value": 98 } }
  • 26. Quick Usage Example: Car Speed Update I 25 PUT <cb_host>:1026/v2/entities/Car1/attrs/speed Content-Type: application/json ... { "type": "Float", "value": 110 } 204 No Content … In the case of id ambiguity, you can use "?type=Car" to specify entity type
  • 27. Quick Usage Example: Car Speed Query I 26 200 OK Content-Type: application/json ... { "type": "Float", "value": 110, "metadata": {} } 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
  • 28. Quick Usage Example: Car Speed Update II 27 PUT <cb_host>:1026/v2/entities/Car1/attrs/speed/value Content-Type: text/plain ... 115 204 No Content …
  • 29. Quick Usage Example: Car Speed Query II 28 200 OK Content-Type: text/plain ... 115.000000 GET <cb_host>:1026/v2/entities/Car1/attrs/speed/value Accept: text/plain
  • 30. Quick Usage Example: Room Create I 29 201 Created ... POST <cb_host>:1026/v2/entities Content-Type: application/json ... { "id": "Room1", "type": "Room", "temperature": { "type": "Float", "value": 24 }, "pressure": { "type": "Integer", "value": 718 } }
  • 31. Quick Usage Example: Room Update I 30 204 No Content … PATCH <cb_host>:1026/v2/entities/Room1/attrs Content-Type: application/json ... { "temperature“: { "type": "Float", "value": 27,9 }, "pressure": { "type": "Integer", "value": 720 } }
  • 32. Quick Usage Example: Room Query I 31 200 OK Content-Type: application/json ... { "pressure": { "type": "Integer", "value": 720, "metadata": {} }, "temperature": { "type": "Float", "value": 27.9, "metadata": {} } } GET <cb_host>:1026/v2/entities/Room1/attrs
  • 33. Quick Usage Example: Room Query II 32 200 OK Content-Type: application/json ... { "pressure": 720, "temperature": 27.9 } GET <cb_host>:1026/v2/entities/Room1/attrs?options=keyValues
  • 34. Quick Usage Example: Room Create II 33 201 Created ... POST <cb_host>:1026/v2/entities Content-Type: application/json ... { "id": "Room2", "type": "Room", "temperature": { "type": "Float", "value": 29 }, "pressure": { "type": "Integer", "value": 730 } }
  • 35. Quick Usage Example: Filters I 34 200 OK Content-Type: application/json ... [ { "id": "Room2", "pressure": 730, "temperature": 29, "type": "Room" } ] GET <cb_host>:1026/v2/entities?options=keyValues&q=temperature>28
  • 36. Quick Usage Example: Filters II 35 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
  • 38. Context Consumer update Context Broker subId = subscribeContext (consumer, expr, expiration) notify (subId, data/context) Context Broker operations: push data 37 ▪ 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. Context Producer Application
  • 39. Quick Usage Example: Subscription 38 POST <cb_host>:1026/v2/subscriptions Content-Type: application/json … { "subject": { "entities": [ { "id": "Room1", "type": "Room" } ], "condition": { "attrs": [ "temperature" ] } }, "notification": { "http": { "url": "http://<host>:<port>/publish" }, "attrs": [ "temperature" ] }, "expires": "2026-04-05T14:00:00.00Z" } 201 Created Location: /v2/subscriptions/51c0ac9ed714fb3b37d7d5a8 ...
  • 40. Quick Usage Example: Notification 39 POST /publish HTTP/1.1 Content-type: application/json; charset=utf-8 Ngsiv2-AttrsFormat: normalized … { "subscriptionId": "574d720dbef222abb860534a", "data": [ { "id": "Room1", "type": "Room", "temperature": { "type": "Float", "value": 17.8, "metadata": {} } } ] } 27.9 17.8
  • 41. List existing subscriptions 40 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
  • 43. Orion Context Broker: batch operations 42 ▪ 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
  • 44. Special update action types 43 ▪ 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
  • 45. Batch Operation Example: Create Several Rooms 44 201 Created ... POST <cb_host>:1026/v2/op/update Conten-Type: application/json ... { "actionType": "APPEND", "entities": [ { "type": "Room", "id": "Room3", "temperature": { "value": 21.2, "type": "Float" }, "pressure": { "value": 722, "type": "Integer" } }, … … { "type": "Room", "id": "Room4", "temperature": { "value": 31.8, "type": "Float" }, "pressure": { "value": 712, "type": "Integer" } } ] }
  • 46. Orion advanced functionality… next seminar! 45 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
  • 47. Summary: Terms 46 ● JSON, JavaScript Object Notation is an open-standard file format that uses human-readable text to transmit data objects consisting of attribute–value pairs and array data types. ● NGSIv2, version 2 of the Open Mobile Alliance (OMA) Next Generation Service Interfaces (NGSI). ● Publish, ● Subscribe, ● Notify, ● Pulling mechanism, ● Pushing mechanism,
  • 48. References 47 ● FIWARE Catalogue o https://www.fiware.org/developers/catalogue ● NGSIv2 Specification o http://fiware.github.io/specifications/ngsiv2/stable o http://fiware.github.io/specifications/ngsiv2/latest ● Orion support though StackOverflow o Ask your questions using the “fiware-orion” tag o Look for existing questions at http://stackoverflow.com/questions/tagged/fiware-orion
  • 51. 5 0