creating an all-purpose rest api for cloud services using osgi and sling - c ziegeler & d...
Post on 04-Jul-2015
158 Views
Preview:
DESCRIPTION
TRANSCRIPT
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Creating a REST API for Cloud services using OSGi and SlingCarsten Ziegeler and David Bosschaert
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
● David Bosschaert (davidb@apache.org)
– R&D Adobe Research Dublin
– Co-chair OSGi EEG
– Open-source and cloud enthusiast
● Carsten Ziegeler (cziegeler@apache.org)
– R&D Adobe Research Switzerland
– OSGi Board, CPEG and EEG member
– ASF member
Speakers
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Agenda
● A REST site with Apache Sling
● Scale it up! with OSGi and jclouds
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Te Next Great Application
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
ROA and REST
● htp://…/products.jsp?id=5643564
● htp://…/slingshot/slingshot1/public/travel/pet.(html|json)
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Resource Oriented Architecture
● Every piece of information is a resource
● User home, category, item, image, comment● Descriptive URI
● Stateless web architecture (REST)
● Request contains all relevant information● Targets the resource
● Leverage HTTP
● GET for rendering, POST/PUT/DELETE for operations
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
SlingShot Content Structure
/
slingshot1 slingshot2
public
travel
pethome
images comments ratings
pet.jpg
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Resource-frst Request Processing
● Request: /slingshot1/public/travel/pet/comments.10.json
● Resource: /slingshot1/public/travel/pet/comments
● Extension: json
● Selector: 10
● Method: GET
● Resource Type : slingshot/comments
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Resource-frst Request processing
1. Resolve the resource
2. Resolve processing script
3. Build execution chain
4. Execute
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Scripting Inside
● It’s your choice
● JSP, servlet, ESP, Scala, Sightly● javax.script● own script handlers
● Default servlets
● JSON, XML● POST/update/create/delete handling● Error handling
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
<sling:defineObjects/><div class="comment"><% final ValueMap attr = resource.getValueMap(); final String title = attr.get(PROPERTY_TITLE, resource.getName()); final String description = attr.get(PROPERTY_DESCRIPTION, ""); final String userId = attr.get(PROPERTY_USER, "");%> <h4><%= ResponseUtil.escapeXml(userId) %> : <%= ResponseUtil.escapeXml(title) %></h4> <p><%= ResponseUtil.escapeXml(description) %></p> <p><%= ResponseUtil.escapeXml( attr.get(SlingshotConstants.PROPERTY_CREATED, "")) %></p></div>
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Resource Providers
/
slingshot1
public
travel
pethome
images comments ratings
pet.jpg
MongoDB
FS
JCRApache Jackrabbit
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Scale UP!● Efectively use the cloud
● Scale up/down based on need
● start small = cheap
● No downtime
● when moving to larger machines
● No cloud-provider specifcs
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
28/10/14© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Sling in the cloud
Load Balancer(s)OSGi NodeOSGi Node
Sling
OSGi NodeOSGi Node
Sling
Director
traffic
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
28/10/14© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Director
OSGi NodeOSGi Node
Sling
OSGi NodeOSGi Node
Sling
Director
provisioninspectdiscover
OSGi NodeOSGi Node
Sling
OSGi NodeOSGi Node
Sling
jclouds create destroy
metricsmetrics
OSGi Cloud Ecosystems (RFC 183)FrameworkNodeStatus Service
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
28/10/14© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Busy times
Load Balancer(s)
OSGi NodeOSGi Node
Sling
OSGi NodeOSGi Node
Sling
Director
traffic
OSGi NodeOSGi Node
Sling
OSGi NodeOSGi Node
Sling
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
28/10/14© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Quiet times
Load Balancer(s)
OSGi NodeOSGi Node
Sling
Director
traffic
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
28/10/14© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Really Quiet times
Load Balancer(s)
OSGi NodeOSGi Node
Sling Sling
Sling Sling
Director
traffic
Dockerinstances
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Summary● Use Sling to build your REST service
● Write your app using anything that can interact with REST
● Native app
● Javascript
● …
● Use OSGi Cloud Ecosystems, Apache jclouds and Docker to scale
● Be cloud-vendor independent!
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Interested in OSGi and Cloud?
● Come to the OSGi Cloud WorkshopWednesday October 29 at 15:15 (Seminarräume 1-3)
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
Innovation at Adobe
22
Links
● Apache Sling – htp://sling.apache.org
● Apache jclouds – htp://jclouds.apache.org
● SlingShot Sample application – htp://svn.apache.org/repos/asf/sling/trunk/samples/slingshot
● OSGi Cloud Ecosystems RFC 183 – htps://github.com/osgi/design/tree/master/rfcs/rfc0183
© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.© 2014 Adobe Systems Incorporated. All Rights Reserved. Adobe Confdential.
top related