cloud computing 014 - uniroma1.it · cloud computing • cloud computing, like other technologies,...

129
Introduction to Cloud Computing Roberto Beraldi

Upload: others

Post on 22-Jul-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Introduction to Cloud Computing

Roberto Beraldi

Page 2: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

CC in a nutshell

• Cloud computing is a way to use Information

Technology infrastructures without the need to

install specific HW related to the infrastructures

being used.

• IT infrastructure can be as simple as a single raw

virtual machine, …

… more abstract as a sw platform used to develop

and running applications on several machines,

…or a sw application

Page 3: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Cloud computing in a nutshell

(by an analogy)

• Electricity is “virtual” entity – (many sources, we do not care from where we receive it,…)

• “Pay-as-you-go” – Elastic

Production Distribution Utilization

Page 4: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

CC: Virtual computing power

CPU

cycles

Storage

Memory

Provider Utilization

Virtual machine

control panel

User decides the size on the VM…

Page 5: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Cloud computing

• Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power in a fully virtualized manner, by aggregating resources and offering a single system view.

• Cloud computing has been coined as an umbrella term to describe a category of sophisticated on-demand computing services initially offered by commercial providers, such as Amazon, Google, and Microsoft.

Page 6: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

What CC can provide?

• Infrastructure

• Platform

• Software

• API

• STorage

• Desktop

• X

as a service (IaaS)

as a service (PaaS)

as a service (SaaS)

as a service (APIaaS)

as a service (STaaS)

as a service (DaaS)

as a service (XaaS)

Page 7: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Main characteristics of CC

• Pay-per-use

– no ongoing commitment, utility prices;

• Elastic capacity and the illusion of infinite resources;

• Resources that are abstracted or virtualized.

• Resources provided as a Service and with a self-service Interface

– provides users the ability to upload, build, deploy, schedule, manage, and report on their business services on demand.

Page 8: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Factors enabling cloud computingHardware

HW virtualization

Multi-core chipsIn

tern

et

Tech

no

log

ies

Distrib

ute

d

Co

mp

utin

g

Web 2.0

Web Services

Mashups

SoA

Utility computing

Grid Computing

..

System Management

Autonomic Computing

Data Center Automation

Cloud

computing

Page 9: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Cloud actors

Page 10: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

From mainframes to clouds

• Providers of CC can operate their

infrastructures at very high utilization rate

• Something similar to what happened with

Mainframes.

– They had to operate at very high utilization rates

simply because they were very expensive and

costs should be justified by efficient usage

Page 11: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Provisioning

Provisioning for peak load

Underprovisioning, case 1

Underprovisioning case 2

Page 12: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Types of Cloud Computing

(IaaS) Infrastructure as a Service

(SaaS)Software as a Service

XaaS (PaaS) Platform as a Service

Page 13: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

INFRASTRUCTURE AS A SERVICE

Page 14: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

IaaS

• A cloud infrastructure enables on-demand provisioning of servers running several choices of operating systems and a customized software stack.

• Cloud computing services are usually backed by large-scale data centers composed of thousands of computers.

• Such data centers are built to serve many users and host many disparate applications.

• Offers virtualized resources (computation, storage, and communication) on demand

Page 15: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Virtualization - isolation

• Through virtualization, workload isolation is achieved since all program instructions are fully confined inside a VM, which leads to improvements in security.

• Better reliability is also achieved because software failures inside one VM do not affect others.

• Moreover, better performance control is attained since execution of one VM should not affect the performance of another VM.

Page 16: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Virtualization - isolation

Page 17: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Virtualization – application mobility

• Workload migration, also referred to as application mobility, targets at facilitating hardware maintenance, load balancing, fault tolerance and disaster recovery.

• It is done by encapsulating a guest OS state within a VM and allowing it to be suspended, fully serialized, migrated to a different platform, and resumedimmediately or preserved to be restored at a later date.

• A VM’s state includes a full disk or partition image, configuration files, and an image of its RAM.

Page 18: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Virtualization – application mobility

Page 19: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Virtualization - consolidation

• Virtualization makes it possible to consolidate

individual workloads onto a single physical

platform, reducing the total cost of ownership.

Page 20: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Virtual machines

• Virtual machine is a logic machine implemented via

software (ML) running on a physical machine (MF)

• Two main types

• No native emulation ML≠MF

• Native emulation. ML=MF

Page 21: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Process virtual machine

• Runs a SW process

• Examples Java Virtual Machine

• Common Language Runtime (CLR)/.NET

Page 22: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Virtual machine and interoperabiity

• Java Virtual Machine (JVM)

– ISA: Macchina a stack (zero-register)

JVM

MF1 MF2 MFn

Java

• “write once run

everywhere”

Page 23: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

System virtual machine

• Same machine as the physical machine

“Efficient, isolated duplicate of a real

machine”*)

• Virtualization is realized by a Virtual Machine

Monitor (VMM) o hypervisor

• Process : SO = Supervisor : Hypervisor

Page 24: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

System virtual machine

• Full virtualization

– OS without modification (VMWare)

– OS legacy

• Paravirtualization

– OS must be modified

– Higher effciency

Page 25: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Resources

• Xen and the Art of Virtualization, Pratt et al. SOSP

2003.

• The Architecture of Virtual Machines, Smith, J.E.; R.

Nair, IEEE Computer, May 2005, Volume: 38 , Issue: 5

• A Comparison of Software and Hardware Techniques

for x86 Virtualization, K. Adams, O. Agesen. ASPLOS

2006.

Page 26: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Classical virtualization

• “A classical VMM executes guest operating system directly, but at a reduced privilegedlevel. The VMM intercepts traps from the de-privileged guest, and emulates the trapping instruction against a virtual machine state”[*]

[*]”A camparison of Software and Hardware Techniques for x86 Virtualization”, K.Adams, O.Agesen, ASPLOS 2006

Page 27: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Classical virtualization, esempio

1

3

4

5

Guest OS Istruzione non privilegiata

verde = User Mode

rosso = System Mode

Istruzione privilegiata

p.e. CLI, Clear Interrupts

2trap

VMM

time

2’

Livello User Livello Kernela. CPU executes a kernel

instruction of the Guest OS

while being in user mode

b. CPU generates a trap

c. Control passes to the VMM

that emulates the instruction

d. 2’ is different of 2, but is

produces the same effect (

(for example,

CLI�VCPU.IF=0)

Page 28: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Hw virtualizazion

Hardware virtualization allows running multiple operating systems and software

stacks on a single physical platform.

The virtual machine monitor (VMM), also called a hypervisor, mediates access to the

physical hardware presenting to each guest operating system a virtual machine

(VM), which is a set of virtual platform interfaces

Page 29: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Type-1 hypervisor (bare metal)

• Guest OS runs unchanged

• Used to build a “Hardware Server” (cloud computing)

• Hyper-V(Microsoft) , VMWare ESX

Page 30: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Type-2 hypervisor (hosted)

• Runs on top of a Hosting OS

• Guest OS unchanged (full virtualization)

• Often used on clients

Page 31: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example of VMM: Virtual Box

• It usually runs on Desktop computers

• VMM runs as an application hosted by an OS

• Software-based virtualization

• Lower performance, easy to install VM (demo)

Page 32: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

IaaS provider’s point of view

• A key challenge IaaS providers face when

building a cloud infrastructure is managing

physical and virtual resources, namely servers,

storage, and networks, in a holistic fashion.

• The orchestration of resources must be

performed in a way to rapidly and dynamically

provision resources to applications.

Page 33: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

IaaS provider’s point of view

• The software toolkit responsible for this orchestration is called a virtual infrastructure

manager (VIM).

• This type of software resembles a traditional operating system (“cloud operating system”)—but instead of dealing with a single computer, it aggregates resources from multiple computers, presenting a uniform view to user and applications.

Page 34: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: OpenNebula

• Interface to Public Clouds: it offers a driver to

manage the life cycle of virtualized resources

obtained from external cloud providers.

• In case of spikes in demand, extra load can be

offloaded to rented resources. To the

applications, the use of leased resources must

ideally be transparent

Page 35: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

IaaS: deployment model

Page 36: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example of IaaS

• Windows azure

• Different machine with different size and OS

• Different geographical region where the

machine is located

• Free trial (requires registration with VISA)

Page 37: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Platform as a Service

• A cloud platform offering an environment on which developers create and deploy applications

• Developers do have access to a SDK that allows to develop a new application and to deploy it in the cloud

• Impact on the programming model

• Google’s app engine, Windows Azure, and many more…

Page 38: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

PaaS – example: GAE

• Cloud service for running web applications on the

Google data center

• Do one thing well

– Simple configuration

– Transparent scalability

• “infinite” number of applications, req/sec storage

– Security

• All applications run inside a sandbox, do not have direct access to

file system, cannot open other connections

Page 39: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

GAE architecture

• Google App Engine speaks with web applications through the Web Server Gateway Interface (WSGI) standard protocol

• App Engine and SDK includes the webapp2 framework that implements WSGI

– Advanced frameworks can be used, e.g., Django

WEB AppHTTP Requests

WEB Server

WSGI Protocol

Page 40: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

GAE: supported language

• Java

– JVM, Java servlet, …

– SDK Eclipse extension

• Python

– Standard library (without ‘unsecure’ calls)

• Go

Page 41: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power
Page 42: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

LAB: Hello Word in GAE

• What we need:

– Google account

– GAE registration

• Plafond free (10 app)

– Register a new application

• The application ID will be used to deploy the

application

– SDK

– Python 2.7 (no support for 3.x)

Page 43: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Hello Word in GAE

helloworld.py

app.yaml

Code

ConfSimulator

“Google Cloud”Deploy

Web-based Admin console

Step 1

Step 3

Step 2

Step 4

Page 44: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Hello Word in GAE

• Define a handler for the HTTP requests as a class that extends webapp2.RequestHandler class (MainPage)– Attributes : response, request (instance of class Request, Response)

– Methods: get,post, etc.. (to override)

• Map HTTP get request to get method (also post, put, etc..)

• Write data to HTTP response through self.response

• app is a global name that must assigned to the application

helloworld.py

Code

Step 1

Page 45: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

app.yaml

Conf

“Google Cloud”Deploy

Web-based Admin console

Step 3

Step 4

• An application name helloword must be registered with the google engine– helloworld.appspot.com

appcfg.py update .

Page 46: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

GAE architecture (simplified view)

App Eng

Front End

App Eng

Front End

App Eng

Front End

App Server

Loa

d

Ba

lan

cer

App Server App Server

API layer

APP APP APP

Other

Google

Service

HTTP Requests

Page 47: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Python GAE architecture

Python

VM

Standard

Lib

App

Read-only

File system

Source: Google App Engine – Guido van Rossum

REQ/REP

DATASTOREMEMCACHE

BigTable

URLfetch

mail

images

ServicesSandbox

CGI

Page 48: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Python GAE architecture (scaling)

Python

VM

Standard

Lib

App

Read-only

File system

Source: Google App Engine – Guido van Rossum

REQ/REP

DATASTOREMEMCACHE

BigTable

URLfetch

mail

images

ServicesSandbox

CGI

Page 49: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

PaaS example2: Windows Azure

• It is a set of integrated cloud technologies each

providing a specific set of services to application

developers

• Windows Azure provides developer-accessible

services for creating applications

• Strongly integrated with Visual studio

– Development fabric simulator

– Development storage simulator

Page 50: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Windows azure

• Two execution models for applications – Web hosting: Web Site

– PaaS: Cloud Service

• IaaS: Virtual Machines

http://www.windowsazure.com/en-us/develop/net/fundamentals/intro-to-windows-azure/

Page 51: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

DeployementWeb Portal

1. Register (Live-id)

Conf(n.inst. =3)

Fabric

Controller

Service

.cspkg

Service

Service

Service

2. Create Hosted-Service

http://xxxx.cloudapp.net

3. Package upload

.csconf + .cspkg

Page 52: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

SOFTWARE AS A SERVICE

Page 53: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Types of Cloud Computing

(IaaS) Infrastructure as a Service

(SaaS)Software as a Service

XaaS (PaaS) Platform as a Service

Page 54: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Access to Cloud computing

• A service is delivered through two access points:

• Standard web browsing (HTTP) and

• Programmatic access (Rest,XML-RPC,SOAP, etc. over HTTP)

Programmatic Service Access

(many methods)

Web URL

(standard HTTP methods)

web browerHTTP

Application

HTTP

Rest,XML-RPC,etc

Service

PaaS

IaaS

SaaS

Page 55: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

What is a service?

SERVICE

INT

ER

FAC

E

--------

--------

--------

--------

Interface definition (e.g., WSDL)

Technology A

Technology B

Technology C

Page 56: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Web API (aka API as a Service)

• Delivering basic building blocks as ‘services’

for other programs

• Services can be offered via simpler protocols

– JSON, JSON-RPC, REST, JSONP,…

Page 57: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Web API (aka API as a Service)

Page 58: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Web-API

• Based of RPC/HTTP

• Two main data representations

– JSON

– XML

• Protocols

– XML-RPC

– JSON-RPC

– SOAP

– REST

Page 59: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Web API: RPC over Internet• RPC calls mapped onto HTTP (GET or POST)

• Synchronous call

• Asynchronous call– with callbacks

• External data representation– JSON (Java Simple Object Notation)

• http://www.json.org/json-it.html

– XML

• Protocols– REST, SOAP, JSONP, JSON-RPC, XML-RPC,…

Page 60: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

JSON

Page 61: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

JSON

• Two fundamental structures:

See JSON Lint

Page 62: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

XML in a nutshell

• XML (eXtensible Markup Language) is a language derived fromSGML (Standard Generalized Markup Language), from whichHTML also derives.

• The key notion in the markup language familty is a markup,something that describes some aspect of the data

• In HTML markups define the appearance of the document,whereas in XML they define the meaning of the data

Page 63: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

XML in a nutshell

• An XML document is a tree

• Data appear inside elements

• An element not only contains the data itself but alsoinformation describing the meaning of the data

Page 64: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example

Il Signore degli Anelli, di John Ronald Reuel Tolkien,

Bompiani.

Title

Author

Editor

Page 65: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example

<book>

<title>

Il Signore degli Anelli

</title>

<author>

John R. R. Tolkien

</author>

<editore>

Bompiani

</editor>

</book>

Title

Author

Editor

Book Elements

Tips : Browser allows to see the structure of the document

Page 66: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Elements and attribute

<title>

Il Signore degli Anelli

</title>

Data

Tag

<title pages=“345”>

Il Signore degli Anelli

</title>

Attribute (key/value pair)

Page 67: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Well formed document

Page 68: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Valid document

• Document that follows composition rules

about the its structure

• Two solutions

• Document Type Definition

– Easier, less ‘powerfull’

• XML Schema

– More complex, more powerfull

Page 69: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

WFD and validation

XML

DocumentSyntax check

Semantic

checkGrammar

Page 70: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

XML-RPC

Page 71: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Overview of XML-RPC

• Data Model

– Scalar

– Struct

– Array

• Messages

– Request message

– Response message

– Error message

Page 72: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Scalar types

Tag Type Example

<i4> or <int> four-byte signed integer -12

<boolean> 0 (false) or 1 (true) 1

<string> string hello world

<double> double-precision signed floating point

number

-12.214

<dateTime.iso8601> date/time 20101504T09:30:00

<base64> base64-encoded binary eW91IGNhbid0IHJlYWQgdGhpcyE=

Page 73: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Struct type

<struct>

<member>

<name>lowerBound</name>

<value><i4>18</i4></value>

</member>

<member>

<name>upperBound</name>

<value><i4>139</i4></value>

</member>

</struct>

Page 74: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Array type

<array>

<data>

<value><i4>12</i4></value>

<value><string>Egypt</string></value>

<value><boolean>0</boolean></value>

<value><i4>-31</i4></value>

</data>

</array>

Page 75: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Request message

• Root element: methodCall

• contains a MethodName element and a params

element

• MethodName contains the name of the procedure

being called

• Params is a list of values for the parameters

Page 76: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example

<?xml version="1.0"?>

<methodCall>

<methodName>XXX</methodName>

<params>

<param>

<value><i4>123</i4></value>

</param>

<param>

<value><double>12.3</double></value>

</param>

</params>

</methodCall>

Page 77: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example<?xml version="1.0"?>

<methodCall>

<methodName> XXX</methodName>

<params>

<param>

<value><i4>123</i4></value>

</param>

<param>

<value><double>12.3</double></value>

</param>

</params>

</methodCall>

methodCall

XXX

methodName

params

param valuei4

param valuedouble

123

12.3

Page 78: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example<?xml version="1.0"?>

<methodCall>

<methodName>Scuola XXX</methodName>

<params>

<param>

<value><i4>123</i4></value>

</param>

<param>

<value><double>12.3</double></value>

</param>

</params>

</methodCall>

methodCall

XXX

methodName

params

param valuei4

param valuedouble

123

12.3

methodName

params

paramparam

doublei4

methodCall

Page 79: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Complete request message

POST /xmlrpc HTTP 1.0

User-Agent: …

Host: …

Content-type: text/xml

Content-length: ..

<?xml version=“1.0”?>

<methodCall>

<methodName>Circle_Area</methodName>

<params><param><value><double>12.2</double></value><param><params>

</methodCall>

Page 80: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Reply message

<?xml version="1.0"?>

<methodResponse>

<params>

<param>

<value><i4>1</i4></value>

</param>

</params>

</methodResponse>

Page 81: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Fault message<?xml version="1.0"?>

<methodResponse>

<fault>

<value>

<struct>

<member>

<name>faultCode</name>

<value><int>4</int></value>

</member>

<member>

<name>faultString</name>

<value><string>Too many parameters.</string></value>

</member>

</struct>

</value>

</fault>

</methodResponse>

Page 82: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

JSON-RPC 2.0

• JSON-RPC is a stateless, transport agnostic,

light-weight remote procedure call (RPC)

protocol

• Much like XML-RPC

– No formal grammar

– Definition of request object and reply object

• New feature: batch requests, notification

Page 83: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Some example

--> {"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": 1}

<-- {"jsonrpc": "2.0", "result": 19, "id": 1}

-->{"jsonrpc": "2.0", "method": "subtract", "params": [23, 42], "id": 2}

<-- {"jsonrpc": "2.0", "result": -19, "id": 2}

-->{"jsonrpc": "2.0", "method": "subtract", "params": {"subtrahend": 23, "minuend": 42}, "id": 3}

<-- {"jsonrpc": "2.0", "result": 19, "id": 3}

--> {"jsonrpc": "2.0", "method": "subtract", "params": {"minuend": 42, "subtrahend": 23}, "id": 4}

<-- {"jsonrpc": "2.0", "result": 19, "id": 4}

Page 84: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

JSON-RPC call batch

--> [{"jsonrpc": "2.0", "method": "sum", "params": [1,2,4], "id": "1"},{"jsonrpc": "2.0", "method": "notify_hello", "params": [7]},{"jsonrpc": "2.0", "method": "subtract", "params": [42,23], "id": "2"},{"foo": "boo"},{"jsonrpc": "2.0", "method": "foo.get", "params": {"name": "myself"}, "id": "5"},{"jsonrpc": "2.0", "method": "get_data", "id": "9"} ]<-- [{"jsonrpc": "2.0", "result": 7, "id": "1"},{"jsonrpc": "2.0", "result": 19, "id": "2"},{"jsonrpc": "2.0", "error": {"code": -32600, "message": "Invalid Request."}, "id": null},{"jsonrpc": "2.0", "error": {"code": -32601, "message": "Method notfound."}, "id": "5"},{"jsonrpc": "2.0", "result": ["hello", 5], "id": "9"}]

Page 85: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

JSONP (JSON with Padding)

GET

….

<javasxcript scr=xxx&callback=f>

….

f(JSON data)

Used in JavaScript

Allows to overcome the cross-

domain problem

Uses a callback function

Page 86: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

REST

• Method calls are mapped to HTTP request

(Get, Post)

• Method name is a parameter of the call

• Reply is usually formatted as JSON or XML

Page 87: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

SOAP

• It’s by far the most verbose protocol

• Service is described in WSDL file

• Messages as XML documents formatted

according to a specific schema

Page 88: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Tool utili per il debugging

Page 89: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

RPC over Internet: example

http://api.wunderground.com/api/http://api.wunderground.com/api/http://api.wunderground.com/api/http://api.wunderground.com/api/KEYKEYKEYKEY////FEATUREFEATUREFEATUREFEATURE/[/[/[/[FEATUREFEATUREFEATUREFEATURE…]/q/…]/q/…]/q/…]/q/QUERYQUERYQUERYQUERY....FORMATFORMATFORMATFORMAT

Features

geolookupconditions forecast

types= JSON, XML

Page 90: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example

http://api.wunderground.com/api/[API_KEY]/conditions/q/rome.json

….

location ID

http://api.wunderground.com/api/[API_KEY]/conditions/q/rome.json?callback=f

JSONP

Page 91: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example of XML reply

http://api.wunderground.com/api/[APIKEY]/conditions/q/zmw:00000.1.16240.xml

Page 92: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Interoperability

Chrome Developer tool

Page 93: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Static call

• Using JS src you can “make a call” and display

results on the screen

Page 94: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Static call

Page 95: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Dynamic Call

Page 96: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Dynamic call

1. Dynamically create a HTML element and append in

the head section

2. Call the URL with callback function

Page 97: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Dynamic call

• Show the current temperature on the screen

Page 98: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Using jQuery

Page 99: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Additional example

Page 100: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Additional example

Page 101: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: Geocoding API

Page 102: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: Geocoding API (json)

Page 103: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: Geocoding API (xml)

Page 104: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: reverse Geocoding (json)

Page 105: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: Reverse geocoding (xml)

Page 106: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Google’s JavaScript API (vers. 3)

Page 107: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example

Page 108: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example:

Page 109: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Geolocation in HTML5

Page 110: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: Flickr ®

Page 111: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Flickr: request, reply message format

http://api.flickr.com/services/xmlrpc/

http://api.flickr.com/services/soap/

WEB-API

http://api.flickr.com/services/rest/

Page 112: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: rest call

Page 113: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example

• Reply is wrapped through jsonFlickrApi

callback name

• To avoid this, set nojsoncallback=1 option

json format

Page 114: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Asynchronous RPC: AJAX

Sicurezza:

Cross domain non è

consentito

Page 115: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: using AJAX

Page 116: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: using AJAX

Page 117: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: searching photos

Page 118: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: searching photos

Page 119: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: searching data

Key photo contains photo details

Page 120: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: searching photo

Every photo has a link

[mstzb] defines the size

Page 121: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: searching photos

Page 122: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Other example

http://api.wordreference.com/{api_version}/{API_key}/{dictionary}/{term}

http://api.wordreference.com/{api_version}/{API_key}/JSON/{dictionary}/{term}

Page 123: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example

Page 124: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example

Page 125: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Example: Twitter API

Page 126: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Exercise

• Write a simple JS program for the TTT game

• Hint:

– use a table for button formatting

– Use a single handler to make modification

Page 127: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Other web API

• http://openweathermap.org/api

• EditGrid

Page 128: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

• Dropbox is a free (up to 2GB), web-based cloud storage mechanism– file backup service

– data sharing

– Data sync among different clients

– Mobile applications

Android

iPhone

iPad

Blackberry

Windows

Linux

MAC

.mp3

.avi.jpg

REST / JSON

STorage as a Service

Page 129: Cloud Computing 014 - uniroma1.it · Cloud computing • Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power

Questions?