Designing Enterprise IT Systems with REST - QCon San Francisco 2008

31
San Francisco 2008 Designing Enterprise IT Systems with REST: A (Cloudy) Case Study Stuart Charlton Chief Software Architect, Elastra

description

Stuart Charlton's session in the REST track of QCon SF 2008, exploring hypermedia design

Transcript of Designing Enterprise IT Systems with REST - QCon San Francisco 2008

Page 1: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Designing Enterprise IT Systems with REST:

A (Cloudy) Case Study

Stuart CharltonChief Software Architect, Elastra

Page 2: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

ObjectivesWhat enterprise problem domains does RESTful architecture handle well?

Understanding Hypermedia as a primary systems abstraction

Suggested capabilities of RESTful Clients• Metadata & Versioning• Semantics & Querying• Security

2

Page 3: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

About Your PresenterStuart Charlton• Canadian,

now in San FranciscoChief Architect, Elastra• Responsible for technical

direction & long-termproduct strategy

In prior lives... • BEA Systems,

Rogers Communications, Financial Services,global training & consulting

Stu Says Stuffhttp://stucharlton.com/blog

3

Page 4: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

CaveatsREST is defined in Roy Fielding’s thesis• Go there for truth, I’m merely a theologian

Web architecture is an evolving field• This is most of what I’m talking about

I don’t expect everyone to agree with me• Some think actions via HTTP POST are a bad thing• I think they’re essential; “REST is not File Storage”

I actually like the Semantic Web• ...and thus cannot be trusted

4

Page 5: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

A Simple Reference Architecture

5

Data Services (e.g. DBMS, Logs, Event Streams, etc.)

Business Services (e.g. Transactions, BPM)

Presentation Services (e.g. GUI)

Page 6: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

Web Architecture

San Francisco 2008

Web architecture helps to burst silos

6

Data Services (e.g. DBMS, Logs, Event Streams, etc.)

Business Services (e.g. Transactions, BPM)

Presentation Services (e.g. GUI)

Page 7: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Classic “Good SOA” Interfaces

7

Page 8: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

The Hypermedia Alternative

8

Page 9: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Problem Domain

A Take on “Enterprise Cloud Computing”• Drastically reduced lead times to provision/change• Visible, declarative designs & infrastructure

9

Wire FundsWeb App

Msg Bus

WireProcess

AcctSvc

DB

Page 10: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Problem DomainIT Services Management & Provisioning

10

ElementManagement

ResourceManagement

Software & Hardware

Page 11: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Problem DomainArchitectural & Change Considerations

11

ElementManagement

ResourceManagement

Software & Hardware

Lifecycle(Birth, Growth, Failure, Recovery, Death)

Designs(Architectural Views)

Page 12: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Organizational & Geographic Distribution

12

Resource Pool A Resource Pool B

Wire FundsWeb App

Msg Bus

WireProcess

AcctSvc

DB

Design

TomcatV 5.5

MQ

WLS10.1

MySQL

ECMLECML ECMLECML

Packages

Configurations

How can youaffect change?

Page 13: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Hyperlinked Enterprise IT InfrastructureThe Decentralized, Declarative Data Center

13

ElementManagement

ResourceManagement

Software & Hardware

Web of MetadataCategories, Capabilities, Configurations & Dependencies

Lifecycle(Birth, Growth, Failure, Recovery, Death)

Designs(Architectural Views)

Page 14: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Hypermedia Application Flow

14

CollectionBookmarkGraph of

Informationand

Interfaces

DynamicInterfaces

New or Changed

Information

(optional)

Search, Feeds, etc.

Page 15: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Hypermedia is a mix of data and control

15

Global graph database that also describes interfaces

Data In(PUT,

DELETE)

Data Out(GET)

Dynamic Interface

ProcessSomething

(POST)

InterfaceOut

(GET)

Agent

Res

pons

e C

odes

Page 16: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

What’s a Dynamic Interface?

Interaction port that is bound at runtime• CORBA Dynamic Invocation Interface• java.lang.Reflect• Capability negotiation (e.g. TELNET)

Agent matches what they know to what’s availableThe Big Difference? Metadata over Methods• The semantics are in the context of the link

16

<control about=”http://myrobot.com/robot/controls/wave”> <title>Wave</title> <description>This will ask your robot to wave X many times</description> <action href=”http://myrobot.com/processor”> <input rel=”waveTimes” name=”waves” type=”xsd:positiveInteger”/> </action></control>

Page 17: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

A RESTFul Amazon EC2

17

Images ResourceBundles

Capabilites

SecurityGroups Credentials

ImageDescription

BundleDescription

Run/Terminate

Requirements

Collections

LinkedData

DynamicInterfaces

links

Page 18: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Observing Application State

18

Agent ServerResources

RepresentationHistory

CurrentState

primary & secondary

next states

Representations

GET

Page 19: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

<?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <title type="text">Amazon EC2 Bundles</title> <entry> <title>Amazon EC2 Standard Small Instance</title> <summary>1.7 GB Memory, 1 ECU Core, 160 Gigabytes of Storage</summary> <content type="application/edml+xml" src="http://www.mycloud.com/bundles/ec2/2008/08/Small"/> <updated>2008-07-31T12:29:29Z</updated> <published>2007-12-13T08:29:29-04:00</published> </entry> <entry> <title>Amazon EC2 Standard Large Instance</title> <summary>8 GB of Memory, 2 ECU Cores, 850 GB of Storage</summary> <content type="application/edml+xml" src="http://www.mycloud.com/bundles/ec2/2008/08/Large"/> <updated>2008-07-31T12:29:29Z</updated> <published>2007-12-13T08:29:29-04:00</published> </entry> </feed>

San Francisco 2008

A RESTFul Amazon EC2

19

Page 20: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Traversing a Link

20

Agent ServerResources

RepresentationHistory Cached

State

next states

CurrentState

GET

Page 21: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

GET http://www.mycloud.com/bundles/ec2/2008/08/SmallHost: www.mycloud.comDate: Mon, 17 Nov 2008 09:15:16 PSTAuthorization: <token here>Accept: application/edml+xml

HTTP/1.1 200 OKHost: www.mycloud.comDate: Mon, 17 Nov 2008 09:15:19 PSTContent-Type: application/edml+xml

<ResourceBundle xmlns="http://exml.com/2008/09/edml"> <name xml:lang="en">Amazon EC2 Standard Small Instance</rdfs:label> <provides> <capability href="http://www.mycloud.com/platforms/ec2#SmallStorage" /> <capability href="http://www.mycloud.com/platforms/ec2#SmallCPU" /> <capability href="http://www.mycloud.com/platforms/ec2#SmallMemory" /> </provides> </ResourceBundle>

San Francisco 2008

A RESTful Amazon EC2: Templates

21

Page 22: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

<Image xmlns="http://exml.com/2008/09/edml"> <name>Fedora Core 8 , x86_64, build 3</name> <provides> <capability>http://purl.org/edml/OperatingSystems/Linux</capability> <capability>http://purl.org/edml/OperatingSystems/64Bit</capability> </provides> <requires> <capability>http://purl.org/edml/ChipArchitectures/64Bit</capability </requires> <run action=""> <bundle /> <quantity /> <groups /> <keypair /> </run></Image>

San Francisco 2008

A RESTful Amazon EC2: Images

22

Page 23: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Changing Resource State

23

AgentServer

ResourcesCurrentState POST links

GET

KnownMediaTypes

Do I know the intent of this?Do I know how to construct this?

POST an appropriate media type

Page 24: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

POST /images/ec2/FC8x86_64b3Host: www.mycloud.comDate: Mon, 17 Nov 2008 09:15:16 PSTAuthorization: <token here>Content-Type: applicaton/edml+xml

<run xmlns="http://exml.com/edmlv2"> <bundle href="http://www.mycloud.com/bundles/ec2/2008/08/Small"/> <quantity>2</quantity> <groups>http://www.mycloud.com/groups/default</groups> <keypairs>http://www.mycloud.com/keypairs/stuartc-keypair</keypairs></run>

San Francisco 2008

Requesting an Instance

24

Page 25: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

HTTP/1.1 201 CreatedLocation: /reservations/a9311f3Host: www.mycloud.comDate: Mon, 17 Nov 2008 09:15:19 PSTContent-Type: application/edml+xml

<Reservation xmlns="http://exml.com/2008/09/edml"> <terminate action="http://www.mycloud.com/reservations/a9311f3"/> <Resource> <state>launching</state> <link rel="self" href="http://www.mycloud.com/reservations/a9311f3/1"/> <bundle href="http://www.mycloud.com/bundles/ec2/2008/08/Small"/> <image href="http://www.mycloud.com/bundles/ec2/FC8x86_64b3"/> <terminate action="http://www.mycloud.com/reservations/a9311f3/1"/> </Resource> <Resource> <state>launching</state> <link rel="self" href="http://www.mycloud.com/reservations/a9311f3/2"/> <bundle href="http://www.mycloud.com/bundles/ec2/2008/08/Small"/> <image href="http://www.mycloud.com/images/ec2/FC8x86_64b3"/> <terminate action="http://www.mycloud.com/reservations/a9311f3/2"/> </Resource> </Reservation>

San Francisco 2008

Receiving an Instance

25

Page 26: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

How can I describe my interfaces?

Tightly Coupled• XML Schema Definitions with minOccurs > 0

Looser Coupled• Dynamically generated XML Schema Definitions• Edit Link Relations (e.g. AtomPub Media Entries)• Forms (e.g. XForms, HTML)• Annotate each field with a Persistent URI

26

Page 27: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

What about Versioning and Provenance?

27

Agent Server

Shredded historical representations

Collections,Search,SPARQL Query

“Metabase”Intermediary

Annotation

Page 28: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Security: Federated Identity

Federated Identity is increasingly needed• Best bet, treat it as orthogonal for now

SAML, (very robust in Java world)WS-Federation, (for Microsoft integration)OpenID (mind the phishing)Point-to-Point (sadly)

OAuth has promise but is very young

28

Page 29: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Towards the Semantic WebIt’s not crazy, it’s just...• Layering logic on top of the Web (An Open-World RDBMS)• Enabling querying and mashing of web pages without

neurosurgerySPARQL is very a big win for RESTful implementers• Query databases or the web of hypermedia• Same syntax - nothing changes• Declarative integrity enforcement for PUT and POST

RDFa and GRDDL are easy to use• Just annotate your HTML or write your own XSLT

Semantic Web Client Library - Query the Web • http://www4.wiwiss.fu-berlin.de/bizer/ng4j/semwebclient/

29

Page 30: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

ConclusionsHypermedia bursts traditional IT silos• The same technology can handle Data, Service, and Presentation• At the expense of efficiency in some cases

Hypermedia gives you ...• A global database of linked data• Human interactions embedded with the data• Dynamic Interfaces embedded with the data

Dynamic interfaces are like CORBA DII or Reflection with a ProcessThis(...) methodNeed to look at the surrounding context

Semantic web technology is practical today for early adopters• Especially GRDDL, SPARQL and RDFa

30

Page 31: Designing Enterprise IT Systems with REST - QCon San Francisco 2008

San Francisco 2008

Thank You

Stuart CharltonChief Software Architect, Elastra