0% found this document useful (0 votes)
176 views84 pages

Fiware Ngsi Api

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
176 views84 pages

Fiware Ngsi Api

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 84

Introduction

Orion Context Broker

Context Management in FIWARE


Orion Context Broker
Creating and pulling data
Pushing data and notifications
Batch operations

●2
Being “Smart” requires first being “Aware”

Implementing a Smart Application requires gathering and managing context


information
Context information refers to the values of attributes characterizing entities
relevant to the application
Application

Context Information
Citizen
• Name-Surname Shop
Bus • Birthday • Location
• Location • Preferences • Business name
• No. passengers • Location • Franchise
• Driver • ToDo list • offerings
• Licence plate

●3
Being “Smart” requires first being “Aware”

Implementing a Smart Application requires gathering and managing context


information
Context information refers to the values of attributes characterizing entities
relevant to the application
Application

Context Information
Users
Boiler • Name-Surname
• Manufacturer • Birthday
Flowerpot
• Last revision • Preferences
• Humidity
• Product id • Location
• Watering plan
• temperature • ToDo list

●4
Different sources of context need to be handle

Context information may come from many sources:


Existing systems
Users, through mobile apps
Sensor networks (IoT Devices)
Source of info for a given entity.attribute may vary over time
What’s the current temperature Notify me the changes of
in place “X”? temperature in place “X”
Standard API
Place = “X”, temperature = 30º

It’s too hot!

A sensor in a pedestrian The Public Bus Transport


street A person from his smartphone Management system
A non-intrusive approach is required

Capable to integrate with existing or future systems dealing with management of


municipal services without impact in their architectures
Info about attributes of one entity may come from different systems, which work either
as Context Producers or Context Providers
Applications rely on a single model adapting to systems of each city

Application/Service
Standard API

attribute “location” attribute “driver”


System A System B
Context Producer Context Provider
●6
FIWARE NGSI: “The SNMP for IoT”

Capturing data from, or Acting upon, IoT devices becomes as easy as to


read/change the value of attributes linked to context entities using a
Context Broker
PUT <Oauth token>
GET <Oauth token> /v2/entities/lamp1/attrs/status/value
/v2/entities/lamp1/attrs/presenceSensor “light on”
NGSI API NGSI API

Context Broker

Issuing a get operation on the


“presenceSensor” attribute Setting up the value of attribute
enables the application to get “status” to “light on” triggers
info about presence of people execution of a function in the IoT
near the lamp device that switches the lamp on
●7
Connecting to the Internet of Things

Capturing data from, or Acting upon, IoT devices becomes as easy as to


read/change the value of attributes linked to context entities using a
Context Broker
PUT <Oauth token>
GET <Oauth token> /v2/entities/lamp1/attrs/status/value
/v2/entities/lamp1/attrs/humidity “watering”
NGSI API NGSI API

Context Broker

Issuing a get operation on the


“humidity” attribute enables Setting up the value of attribute
the application to find out “status” to “watering” triggers
whether the plant has to be execution of a function in the IoT
watered device that waters the plant

●8
Context Management in FIWARE

The FIWARE Context Broker GE implements the OMA NGSI-9/10 API: a simple
yet powerful standard API for managing Context information complying with
the requirements of a smart city
The FIWARE NGSI API is Restful: any web/backend programmer can manage it

Application/Service

NGSI API

Boiler
Context Broker
Users
• Manufacturer • Name-Surname
• Last revision • Birthday Flowerpot
• Product id • Preferences • Humidity
• temperature • Location • Watering plan
• ToDo list
●9
Orion Context Broker

Main functions:
Context management
HTTP and REST-based
JSON payload support
Context in NGSI is based in an entity-attribute model:

Entity Attributes
• EntityId “has” • Name
• EntityType • Type
1 n
• Value

10
Two “flavors” of NGSI API
NGSIv1
Original NGSI RESTful binding of OMA-NGSI
Implemented in 2013
Uses the /v1 prefix in resource URL
NGSIv2
A revamped, simplified binding of OMA-NGSI
Simple things must be easy
Complex things should be possible
Agile, implementation-driven approach
Make it as developer-friendly as possible (RESTful, JSON, …)

Enhanced functionality compared with NGSIv1 (eg. filtering)


Uses the /v2 prefix in resource URL
Introduction to NGSIv2: https://docs.google.com/presentation/d/1_fv9dB5joCsOCHlb4Ld6A-
QmeIYhDzHgFHUWreGmvKU/edit#slide=id.g53c31d7074fd7bc7_0

11
Orion Context Broker in a nutshell

Orion Context Broker Context


subscriptions
Consumers
query
Context
Producers 1026
update
notify

update

1026
notify
update

DB

●12
Orion Context Broker – check health

GET <cb_host>:1026/version

{
"orion" : {
"version" : "1.3.0",
"uptime" : "7 d, 21 h, 33 m, 39 s",
"git_hash" : "af44fd1fbdbbfd28d79ef4f929e871e515b5452e",
"compile_time" : "Tue Jun 15 11:52:53 CET 2016",
"compiled_by" : "fermin",
"compiled_in" : "centollo"
}
}
●13
Orion Context Broker Basic Operations

Entities
• GET /v2/entities
• Retrieve all entities
• POST /v2/entities
• Creates an entity
• GET /v2/entities/{entityID}
• Retrieves an entity
• [PUT|PATCH|POST] /v2/entities/{entityID}
• Updates an entity (different “flavors”)
• DELETE /v2/entities/{entityID}
• Deletes an entity

●14
Orion Context Broker Basic Operations

Attributes
• GET /v2/entities/{entityID}/attrs/{attrName}
• Retrieves an attribute’s data
• PUT /v2/entities/{entityID}/attrs/{attrName}
• Updates an attribute’s data
• DELETE /v2/entities/{entityID}/attrs/{attrName}
• Deletes an attribute
• GET /v2/entities/{entityID}/attrs/{attrName}/value
• Retrieves an attribute’s value
• PUT /v2/entities/{entityID}/attrs/{attrName}/value
• Updates an attribute’s value

●15
Context Broker operations: create & pull data
Context Producers publish data/context elements by invoking the update
operations on a Context Broker.

Context Consumers can retrieve data/context elements by invoking the query


operations on a Context Broker

update query

Context Producer Context Broker Context Consumer

●16
Quick Usage Example: Car Create

POST
<cb_host>:1026/v2/entities
Content-Type: application/json
...

{
"id": "Car1",
"type": "Car",
"speed": {
"type": "Float",
"value": 98 201 Created
}
}

●17
Quick Usage Example: Car Speed Update (1)

PUT
<cb_host>:1026/v2/entities/Car1/attrs/speed
Content-Type: application/json
...

{
"type": "Float",
"value": 110 In the case of id ambiguity, you can
} use "?type=Car" to specify entity type

204 No Content

●18
Quick Usage Example: Car Speed Query (1)

GET <cb_host>:1026/v2/entities/Car1/attrs/speed

200 OK
Content-Type: application/json
...

{
"type": "Float",
"value": 110,
You can get all the attributes of the entity using "metadata": {}
the entity URL: }
GET/v2/entities/Car1/attrs

●19
Quick Usage Example: Car Speed Update (2)

PUT
<cb_host>:1026/v2/entities/Car1/attrs/speed/value
Content-Type: text/plain
...

115

204 No Content

●20
Quick Usage Example: Car Speed Query (2)

GET
<cb_host>:1026/v2/entities/Car1/attrs/speed/value
Accept: text/plain

200 OK
Content-Type: text/plain
...

115.000000

●21
Quick Usage Example: Room Create (1)

POST <cb_host>:1026/v2/entities
Content-Type: application/json
...

{
"id": "Room1",
"type": "Room",
"temperature": {
"type": "Float",
"value": 24
},
"pressure": {
"type": "Integer", 201 Created
"value": 718 ...
}
}
●22
Quick Usage Example: Room Update (1)

PATCH <cb_host>:1026/v2/entities/Room1/attrs
Content-Type: application/json
...

{
"temperature“: {
"type": "Float",
"value": 25
},
"pressure": {
"type": "Integer",
"value": 720
}
} 204 No Content

●23
Quick Usage Example: Room Query (1)

GET
<cb_host>:1026/v2/entities/Room1/attrs

200 OK
Content-Type: application/json
...

{
"pressure": {
"type": "Integer",
"value": 720,
"metadata": {}
},
"temperature": {
"type": "Float",
"value": 25,
"metadata": {}
}
}

●24
Quick Usage Example: Room Query (2)

GET
<cb_host>:1026/v2/entities/Room1/attrs?options=keyValues

200 OK
Content-Type: application/json
...

{
"pressure": 720,
"temperature": 25
}

●25
Quick Usage Example: Room Create (2)

POST <cb_host>:1026/v2/entities
Content-Type: application/json
...

{
"id": "Room2",
"type": "Room",
"temperature": {
"type": "Float",
"value": 29
},
"pressure": {
"type": "Integer", 201 Created
"value": 730 ...
}
}
●26
Quick Usage Example: Filters (1)

GET
<cb_host>:1026/v2/entities?options=keyValues&q=temperature>27

200 OK
Content-Type: application/json
...

[
{
"id": "Room2",
"pressure": 730,
"temperature": 29,
"type": "Room"
}
]

●27
Quick Usage Example: Filters (2)

GET
<cb_host>:1026/v2/entities?options=keyValues&q=pressure==715..7
25
200 OK
Content-Type: application/json
...
The full description of the Simple
Query Language for filtering can [
be found in the NGSIv2 {
Specification document "id": "Room1",
"pressure": 720,
"temperature": 25,
"type": "Room"
}
]

●28
Context Broker operations: push data

Context Consumers can subscribe to receive context information that satisfy


certain conditions using the subscribe operation. Such subscriptions may
have an expiration time.

The Context Broker notifies updates on context information to subscribed


Context Consumers by invoking the notify operation they export

Application

subId = subscribeContext (consumer, expr, expiration)

notify (subId, data/context)

Context Consumer
Context Broker

●29
Quick Usage Example: Subscription
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" 201 Created
}, Location: /v2/subscriptions/
"attrs": [ "temperature" ]
}, 51c0ac9ed714fb3b37d7d5a8
"expires": "2026-04-05T14:00:00.00Z" ...
}

●30
Quick Usage Example: Notification

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": 19,
"metadata": {}
}
}
]
}

●31
List existing subscriptions

GET 200 OK
Content-Type: application/json
<cb_host>:1026/v2/subscriptions …
[{
"id": " 51c0ac9ed714fb3b37d7d5a8 ",
"expires": "2026-04-05T14:00:00.00Z",
"status": "active",
"subject": {
"entities": [{
"id": "Room1",
"type": "Room"
}],
The full description of the "condition": {
"attrs": ["temperature"]
subscription object (including all }
},
its fields) can be found in the "notification": {
NGSIv2 Specification "timesSent": 3,
"lastNotification": "2016-05-31T11:19:32.00Z",
"attrs": ["temperature"],
"attrsFormat": "normalized",
"http": {
"url": "http://localhost:1028/publish"
}
}
}]
●32
Orion Context Broker batch operations

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

33
Batch Operation Example: Create Several Rooms

POST <cb_host>:1026/v2/op/update …
Conten-Type: application/json {
... "type": "Room",
"id": "Room4",
{ "temperature": {
"actionType": "APPEND", "value": 31.8,
"entities": [ "type": "Float"
{ },
"type": "Room", "pressure": {
"id": "Room3", "value": 712,
"temperature": { "type": "Integer"
"value": 21.2, }
"type": "Float" }
}, ]
"pressure": { }
"value": 722,
"type": "Integer" 201 Created
}
}, ...

●34
Advanced Features
Orion Context Broker Metadata
Compound attribute/metadata values
Type browsing
Geo-location
Query filters
Custom notifications
Attribute/metadata filtering and special
attribute/metadata
Registrations & context providers

●35
Metadata
Users may attach metadata to attributes
Reserved metadata: ID, location, dateCreated, dateModified, previousValue, actionType
Examples:
… …
"temperature": { "temperature": {
"type": "Float", "type": "Float",
"value": 26.5, "value": 26.5,
"metadata": { "metadata": {
{ {
"accuracy": { “average": {
"type": "Float", "type": "Float",
"value": 0.9 "value": 22.4
} }
} }
} }
… ●36

Complete NGSI Model

Entity Attributes Metadata


“has” • Name “has” • Name
• EntityId
• Type • Type
• EntityType 1 n 1 n
• Value • Value

●37
Compound Attribute/Metadata Values

Attributes and metadata can have a structured value. Vectors


and key-value maps are supported.
It maps directly to JSON's objects and arrays.

●38
Compound Attribute/Metadata Values

Example: we have a car {


"type": "Car",
whose four wheels' "id": "Car1",
pressure we want to "tirePressure": {
represent as a "type": "kPa",
"value": {
compound attribute for "frontRight": "120",
a car entity. We would "frontLeft": "110",
create the car entity like "backRight": "115",
"backLeft": "130"
this: }
}
}
●39
Type Browsing
• GET /v2/types
• Retrieve a list of all entity types currently in Orion, including their corresponding attributes and entities count
• GET /v2/types/{typeID}
• Retrieve attributes and entities count associated to an entity type

PRO TIP
GET /v2/contextTypes?options=values
Retrieves just a list of all entity types without any extra info

●40
Geo-location
POST <cb_host>:1026/v2/entities
{
Entities can have an attribute that specifies its "type": "City",
location "id": "Madrid",
"position": {
Several attribute types can be used "type": "geo:point",
geo:point (for points)
"value": "40.418889, -3.691944"
geo:line (for lines)
geo:box (for boxes) }
geo:polygon (for polygons) }
geo:json (for arbitrary geometries, in GeoJson
standard)

Example: create an entity called Madrid


…and create a couple more towns:
Leganés
Alcobendas

●41
Geo-location – Circle

●42
Geo-location – Max distance

GET <cb_host>:1026/v2/entities?
idPattern=.*&
type=City&
georel=near;maxDistance:13500&
geometry=point&
coords=40.418889,-3691944

●43
Geo-location – Min distance

GET <cb_host>:1026/v2/entities?
idPattern=.*&
type=City&
georel=near;minDistance:13500&
geometry=point&
coords=40.418889,-3691944

●44
More geo-relationships
Apart from near, the following georel can be used
georel=coveredBy
georel=intersects
georel=equals
georel=disjoint
See NGSIv2 Specification for a detailed description

●45
Query filters
For the GET /v2/entities operation

By entity type GET <cb_host>:1026/v2/entities?type=Room

By entity id list GET <cb_host>:1026/v2/entities?id=Room1,Room2

By entity id pattern (regex) GET


<cb_host>:1026/v2/entities?idPattern=^Room[2-5]
By entity type pattern (regex)

By geographical location GET


Described in detail in previous slides <cb_host>:1026/v2/entities?typePattern=T[ABC]

Filters can be used simultaneously (i.e. like AND condition)

●46
Query filters
attribute name
By attribute value (q)
GET <cb_host>:1026/v2/entities?q=temperature>25
attribute sub-key (for compound attribute values only)
GET
<cb_host>:1026/v2/entities?q=tirePressure.frontRight
attribute name
By metadata
>130 value (mq) metadata name
metadata sub-key (for compound
GET
metadata values only)
<cb_host>:1026/v2/entities?mq=temperature.avg>25
GET <cb_host>:1026/v2/entities?mq=tirePressure.accuracy.frontRight
>90
See full details about q and mq query language in NGSIv2 specification

●47
POST <cb_host>:1026/v2/subscriptions

{
Query filters "subject": {
"entities": [
{
"id": “Car5",
"type": “Car"
Filters can be also used in {
},

subscriptions "idPattern": “^Room[2-5]",


"type": "Room"
id {
},

type "id": “D37",


"typePattern": "Type[ABC]"
id pattern },
],
type pattern "condition": {
"attrs": [ "temperature" ],
attribute values "expression": {
metadata value "q": "temperature>40",
"mq": "humidity.avg==80..90",
geographical location "georel": "near;maxDistance:100000",
"geometry": "point",
"coords": "40.418889,-3.691944"
}
}
},

●48
Custom notifications
Apart from the standard formats defined in the previous slides
NGSIv2 allows to re-define all the notification aspects
httpInfo is used instead of http, with the following subfields
URL query parameters
HTTP method
HTTP headers
Payload (not necessarily JSON!)
A simple macro substitution language based on ${..} syntax can be used to “fill
the gaps” with entity data (id, type or attribute values)
Exception: this cannot be used in HTTP method field
49
Custom notifications
PUT /v2/entities/DC_S1-D41/attrs/temp/value?type=Room

23.4


"httpCustom": {
update "url": "http://foo.com/entity/${id}",
"headers": {
"Content-Type": "text/plain"
},
"method": "PUT",
"qs": {
"type": "${type}"
notification },
"payload": "The temperature is ${temp} degrees"
}
PUT http://foo.com/entity/DC_S1-D41?type=Room Content- …
Type: text/plain
Content-Length: 31 Custom notification configuration
The temperature is 23.4 degrees

50
Registration & Context Providers
POST <cb_host>:1026/v1/registry/registerContext

{
"contextRegistrations": [
{
"entities": [
{
"type": "Car",
"isPattern": "false",
"id": "Car1"
},
200 OK
"attributes": [ ...
{ {
"name": "speed", "duration" : "P1M",
"type": "float", "registrationId" : "52a744b011f5816465943d58"
"isDomain": "false" }
}
],
"providingApplication": "http://contextprovider.com/Cars"
}
],
Context management availability functionality not yet specified in
"duration": "P1M"
}
NGSIv2. Thus, a NGSIv1 operation is used to create the registration.

●51
Registration & Context Providers

GET
<cb_host>:1026/v2/entities/Car1/attrs

200 OK
data
Content-Type: application/json
...
query
{ ContextBroker ContextProvider
"type": "Float", db
"value": 110,
"metadata": {}
}
●52
INTEGRATION WITH OTHER
SYSTEMS

●53
FI-WARE Context/Data Management Platform

Applications
Processing/Analysi
OMA NGSI- s Algorithms
9/10

Gathered data is
injected for
processing/analysis
Data generated either by
CEP or BigData is published

Gathered data
injected for CEP-like BigData
processing (COSMOS)
Distributed Direct Big
Context Complex Event Data
Sources Processed data injection
Processing (PROTON) is injected for
Programming processing and
analysis
of rules Context/Data Management Platform
●54
How to store the context information

Context Broker don’t persist historic data


Cygnus: adapter between Context Broker and Storage
There are 4 storage typologies

Cygnus
BigData
Cosmos
The 4 Storage Systems

MySQL is related database


mongoDB is not related database (NoSQL)
Cosmos is Hadoop ecosystem-based to manage huge amounts of previously stored data
 HDFS as its distributed file system

 Hadoop core as its MapReduce engine

 HiveQL and Pig for querying the data

 Oozie as remote MapReduce jobs and Hive launcher

CKAN (Comprehensive Knowledge Archive Network) is (Open) Data Platform


 create private/public datasets (JSON, CSV, TXT, PDF, …)

 REST/JSON APIs to access data and metadata


Install Cygnus on Context Broker VM

Deploy Context Broker


Install Cygnus (on Context Broker VM):
 $ sudo –i

 # yum install cygnus

Cygnus configuration files (next sections)


Status/Start/Restart/Stop command
 # service cygnus status C
y
g Cygnus
 # service cygnus start
n configuration files
u
 # service cygnus restart s
Storage
 # service cygnus stop
Cygnus configuration files

 All files are available (as template) in /usr/cygnus/conf/ folder (in detail see README.md file):
 log4j.properties cp /usr/cygnus/conf/log4j.properties.template /usr/cygnus/conf/log4j.properties

 flume-env.sh cp /usr/cygnus/conf/flume-env.sh.template /usr/cygnus/conf/flume-env.sh

 krb5.conf cp /usr/cygnus/conf/krb5.conf.template /usr/cygnus/conf/krb5.conf

 matching_table.conf cp /usr/cygnus/conf/matching_table.conf.template /usr/cygnus/conf/matching_table.conf

Files per instance:


 agent.conf

 cygnus_instance.conf

Replace “<id>” tag with your instance name:


 agent_<id>.conf

 cygnus_instance_<id>.conf
1. Context Broker and MySQL

You need an instance of MySQL Database


Tips (to install database on Context Broker instance)
 # yum install mysql mysql-server mysql-libs mysql-server

 # service mysqld start

 # mysqladmin -u root password NEWPASSWORD


C
y
Edit instance files and rename them with <id> = mysql g
n
u
s
 cygnus_instance_mysql.conf

 agent_mysql.conf
1. Context Broker and MySQL

Edit cygnus_instance_mysql.conf
1. Context Broker and MySQL

Edit agent_mysql.conf
1. Context Broker and MySQL

Edit agent_mysql.conf
Example of publish/subscribe
updateContext : queryContext : subscribeContext:
{ { {
"contextElements": [ "entities": [ "entities": [
{ { {
"type": "Car", "type": "Car", "type": "Car",
"isPattern": "false", "isPattern": "false", "isPattern": "false",
"id": "Car1", "id": "Car1" "id": "Car1"
"attributes": [ } }
{ ] ],
"name": "speed", } "attributes": [
"type": "float", "speed"
"value": "98" ],
} "reference": "http://localhost:5050/notify",
] "duration": "P1M",
} "notifyConditions": [
], {
"updateAction": "APPEND" "type": "ONCHANGE",
} "condValues": [
"speed"
]
Headers: }
Content-Type: application/json ],
"throttling": "PT1S"
Accept: application/json
}
Fiware-Service: vehicles
Fiware-ServicePath: /4wheels
1. Context Broker and MySQL - Example: check the context data
$ mysql -u root –p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
...
mysql> show databases;
+-----------------------+
| Database |
+-----------------------+
| information_schema |
| mysql |
| test |
| vehicles |
+-----------------------+
4 rows in set (0.01 sec)
mysql> use vehicles;
...
Database changed
mysql> show tables;
+--------------------+
| Tables_in_vehicles |
+--------------------+
| 4wheels_car1_car |
+--------------------+
1 row in set (0.00 sec)
mysql> select * from 4wheels_car1_car;
...
2. Context Broker and mongoDB

You need an instance of mongoDB Database


Tips (Context Broker instance has already got it)
Edit instance files and rename them with <id> = mongo
 cygnus_instance_mongo.conf
C
 agent_mongo.conf y
g
n
u
s
2. Context Broker and mongoDB

Edit cygnus_instance_mongo.conf
2. Context Broker and mongoDB

Edit agent_mongo.conf
2. Context Broker and mongoDB

Edit agent_mongo.conf
2. Context Broker and mongoDB - Example: check the context data
$ mongo
MongoDB shell version: 2.6.9
connecting to: test
...
> show databases
admin (empty)
local 0.031GB
orion 0.031GB
orion-vehicles 0.031GB
sth_vehicles 0.031GB
test (empty)
> use sth_vehicles
switched to db sth_vehicles
> show collections
sth_/4wheels_car1_car
system.indexes
> db['sth_/4wheels_car1_car'].find()
...
3. Context Broker and Cosmos

You need an instance of Big Data Analysis Cosmos GE


Tips (FIWARE Lab provide you this feature at this link cosmos.lab.fiware.org)
Edit instance files and rename them with <id> = cosmos
 cygnus_instance_cosmos.conf

 agent_cosmos.conf

C
y
g BigData
n Cosmos
u
s
3. Context Broker and Cosmos

Edit cygnus_instance_cosmos.conf
3. Context Broker and Cosmos

Edit agent_cosmos.conf
3. Context Broker and Cosmos

Edit agent_cosmos.conf
3. Context Broker and Cosmos - How to get the auth-token

Cosmos WebHDFS access is protected with OAuth2


Request:
curl -X POST "https://cosmos.lab.fiware.org:13000/cosmos-auth/v1/token" -H "Content-Type: application/x-www-
form-urlencoded" -d "grant_type=password&[email protected]&password=mypassword" –k

Response:
{"access_token": "P8vBzFdJB2ZBNHwfxUHFrfc1buTx7n", "token_type": "Bearer", "expires_in": 3600,
"refresh_token": "He8aJdQiEkpbnQB4KFAS1DFra9RhNq"}

Example to get file status:


curl -X GET
"http://cosmos.lab.fiware.org:14000/webhdfs/v1/user/pasquale.vitale?op=liststatus&user.name=pasquale.vitale" -H
"X-Auth-Token: P8vBzFdJB2ZBNHwfxUHFrfc1buTx7n“

{"FileStatuses":{"FileStatus":[...]}}
3. Context Broker and Cosmos - Example: check the context data

Cosmos GUI - http://cosmos.lab.fi-ware.org/cosmos-gui


Connection and check data in Cosmos:
$ ssh [email protected]
[email protected]'s password:

$ hadoop fs -lsr /user/pasquale.vitale/


drwxr----- - pasquale.vitale pasquale.vitale 0 2015-07-21 17:11 /user/pasquale.vitale/vehicles
drwxr----- - pasquale.vitale pasquale.vitale 0 2015-07-21 17:11 /user/pasquale.vitale/vehicles/4wheels
drwxr----- - pasquale.vitale pasquale.vitale 0 2015-09-24 15:54 /user/pasquale.vitale/vehicles/4wheels/car1_car
-rw-r----- 3 pasquale.vitale pasquale.vitale 820 2015-09-24 15:54 /user/pasquale.vitale/vehicles/4wheels/car1_car/car1_car

$ hadoop fs -cat /user/pasquale.vitale/vehicles/4wheels/car1_car/car1_car.txt


{"recvTime":"2015-07-21T15:11:11.344Z","speed":"25", "speed_md":[]}
{"recvTime":"2015-07-21T15:41:30.233Z","speed":"125", "speed_md":[]}
{"recvTime":"2015-07-21T15:45:52.305Z","speed":"99", "speed_md":[]}
4. Context Broker and CKAN

You need an instance of CKAN


Tips (FIWARE Lab provide you this feature at this link data.lab.fiware.org)
Edit instance files and rename them with <id> = ckan
 cygnus_instance_ckan.conf

 agent_ckan.conf

C
y
g
n
u
s
4. Context Broker and CKAN

Edit cygnus_instance_ckan.conf
4. Context Broker and CKAN

Edit agent_ckan.conf
4. Context Broker and CKAN

Edit agent_ckan.conf
4. Context Broker and CKAN - Example: check the context data
Would you like to play with this?

Have a look to the FIWARE Reference Tutorial application


git clone https://github.com/Fiware/tutorials.TourGuide-App.git
cd tutorials.TourGuide-App/
docker-compose up orion
curl localhost:1026/version
Self-explanatory README.md at root directory
Open a Postman session and rock and roll
Postman collection: https://github.com/Fiware/tutorials.TourGuide-
App/blob/develop/contrib/CampusParty2016.postman_collection

●81
NGSI Plugin for Freeboard
Create a real time dashboard for your entities, representing gauges,
spark lines and maps. No coding required!
• https://github.com/telefonicaid/fiware-dataviz
In addition, Freeboard freemium version integrates Orion off-the-shelf
Would you like to know more?
The easy way
This presentation: google for “fermingalan slideshare” and search the one named “Managing
Context Information at large scale”
Orion User Manual: google for “Orion FIWARE manual” and use the first hit
Orion Catalogue page: google for “Orion FIWARE catalogue” and use the first hit

References
NGSIv2 Specification
http://fiware.github.io/specifications/ngsiv2/stable
http://fiware.github.io/specifications/ngsiv2/latest
NGSIv2 for NGSIv1 developers
http://bit.ly/ngsiv2-vs-ngsiv1
This presentation
http://www.slideshare.net/fermingalan/fiware-managing-context-information-at-large-scale
Orion Catalogue:
http://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context-broker
Orion support trhough StackOverflow
Ask your questions using the “fiware-orion” tag
Look for existing questions at http://stackoverflow.com/questions/tagged/fiware-orion

●83
TEST IT AT HOME

●84

You might also like