SlideShare uma empresa Scribd logo
1 de 38
Baixar para ler offline
connecting java (and clojure) to the cloud

                  adrian@opscode.com
                  @jclouds
                  http://blog.jclouds.org

Monday, July 12, 2010                                                1
Agenda
                  •     Motivation
                  •     jclouds
                  •     BlobStores
                  •     Provisioning




Monday, July 12, 2010                           2
Motivation
                  • Cloud Storage
                  • Vendors
                  • Differences


Monday, July 12, 2010                     3
what is key value storage?

                        global name space
                        key, value with metadata
                        http accessible
                        sites on demand
                        unlimited scaling

Monday, July 12, 2010                              4
key value storage concepts


         GLOBAL NAME SPACE
                             KEY/ VALUE




Monday, July 12, 2010                     5
THE VENDORS




Monday, July 12, 2010                 6
They aren’t the same




Monday, July 12, 2010                          7
• FILE SIZE

               • RESUMABILITY




Monday, July 12, 2010           8
CONTENT DELIVERY NETWORK

                                     REPLICATION

                                             SLA




Monday, July 12, 2010                              9
Consistency Model




Monday, July 12, 2010                       10
AUTHORIZATION

Monday, July 12, 2010                   11
api complexity
Monday, July 12, 2010                    12
CODE AND SIGN THE HTTP REQUEST


                                                                        PUT /adriansmovies/sushi.avi HTTP/1.1
       PUT /sushi.avi HTTP/1.1                                          Host: <account>.blob.core.windows.net
       Host: adriansmovies.s3.amazonaws.com                             Content-Length: 734859264
       Content-Length: 734859264                                        Date: Wed, 01 Mar 2006 12:00:00 GMT
       Date: Wed, 01 Mar 2006 12:00:00 GMT                              Authorization: SharedKey <app>:signature
       Authorization: signature                                         x-ms-meta-Chef: Kawasaki
       x-amz-meta-Chef: Kawasaki




                                                            POST /namespace/adriansmovies/sushi.avi HTTP/1.1
                         PUT /<api version>/<account>/
                                                            Content-Length: 734859264
                         adriansmovies/sushi.avi HTTP/1.1
                                                            Date: Wed, 01 Mar 2006 12:00:00 GMT
                         Host: storage.clouddrive.com
                                                            x-emc-uid: <uid>
                         Transfer-Encoding: chunked
                                                            x-emc-signature: signature
                         X-Auth-Token: session-token
                                                            x-emc-meta: Chef=Kawasaki
                         X-Object-Meta-Chef: Kawasaki




Monday, July 12, 2010                                                                                              13
CODE AND SIGN THE HTTP REQUEST


GET /ws/IMFS/GetStorageNodeExtended.ashx?&fileOverwrite=true&ipRestricted=true&destFolderPath= adriansmovies&sizeBytes=
734859264&firstByteExpiration=6000&lastByteExpiration=259200&sessionToken=session-token HTTP/1.1

POST /Upload.ashx?uploadToken=from_above&destFolderPath=adriansmovies HTTP/1.1
Host: from_above
Content-Length: 734859382
Content-Type=multipart/form-data; boundary=--jclouds--
Authorization=Basic GpjbG9=
----jclouds--
Content-Disposition: form-data; name="sushi.avi"; filename="sushi.avi"
Content-Type: application/octetstring
...

PUT /ws/Metadata/SetMetadata.ashx?&path=Folders/adriansmovies/sushi.avi&sessionToken=session-token&metadata=Chef:Kawasaki HTTP/1.1




Monday, July 12, 2010                                                                                                                14
CODE AND SIGN THE HTTP REQUEST



                        POST /<api version>/containers/id_of_ adriansmovies/contents HTTP/1.1
                        Content-Length: 734859382
                        Content-Type=multipart/form-data; boundary=--jclouds--
                        Authorization=Basic GpjbG9=
                        ----jclouds--
                        Content-Disposition: form-data; name="sushi.avi"; filename="sushi.avi"
                        Content-Type: application/octetstring
                        ...

                        PUT /<api version>/files/from_above/metadata/Chef HTTP/1.1
                        Content-Length: 8
                        Content-Type: text/plain
                        Authorization: Basic GpjbG9=
                        Kawasaki




Monday, July 12, 2010                                                                           15
do you want to


        • Deal with Errors
        • Deal with Concurrency
        • Deal with Cloud Complexity

Monday, July 12, 2010                    16
jclouds

    open source
    feels like java (and clojure)
    portability between clouds
    deal with web complexity
    unit testability
    thread-safe and scalable

Monday, July 12, 2010                17
Tools we provide
                    • Abstractions
                     • BlobStore ( atmos, azure, rackspace, s3 )
                     • Compute ( vcloud, ec2, gogrid, ibmdev,
                        rackspace, rimu )
                    • Clojure bindings
                    • Third-party library integration
Monday, July 12, 2010                                              18
Alternatives to jclouds
                    • Roll-your-own
                    • Jersey, RESTEasy
                    • EC2-based cloud apis
                    • typica, jets3t
                    • Dasein Cloud API
                    • Service provided SDKs
Monday, July 12, 2010                         19
BlobStore
                  • Java Code
                  • Clojure Code



Monday, July 12, 2010                    20
java
                    // init
                    context = new BlobStoreContextFactory().createContext(
                                    "s3",
                                    accesskeyid,
                                    secretaccesskey);
                    blobStore = context.getBlobStore();

                    // create container
                    blobStore.createContainerInLocation(null, "mycontainer");

                    // add blob
                    blob = blobStore.newBlob("test");
                    blob.setPayload("testdata");
                    blobStore.putBlob(containerName, blob);




Monday, July 12, 2010                                                           21
commons vfs

                vfs > open blobstore://user:key@cloudfiles/mycontainer
                Opened blobstore://cloudfiles/mycontainer/
                Current folder is blobstore://cloudfiles/mycontainer/
                vfs > ls
                Contents of blobstore://cloudfiles/mycontainer/
                README.txt
                0 Folder(s), 1 File(s)
                vfs > close




Monday, July 12, 2010                                                    22
clojure

                (ns demo
                  (:use org.jclouds.blobstore)
                  (:use clojure.contrib.pprint)
                )


                 (def blobstore (blobstore-context service account secret ))

                 (pprint (containers blobstore))

                 (pprint (blobs blobstore "mycontainer" ))




Monday, July 12, 2010                                                          23
Provisioning
                  • The Good, the Bad, and the Ugly
                  • Java Code
                  • Clojure Code


Monday, July 12, 2010                                 24
The Good



                        provisioning (and re-provisioning) is cheap
                        APIs = automation
                        tools exist




Monday, July 12, 2010                                                 25
The Bad



                        forgetting to turn things off
                        licensing
                        erratic service quality




Monday, July 12, 2010                                   26
The Ugly


                        cloud apis are sometimes unreliable
                        apis are very different across clouds
                        features are very different across clouds
                        accidental complexity




Monday, July 12, 2010                                               27
Things to consider when provisioning


                        Can you create an image?
                        Can you push credentials or files?
                        Do you need to VPN in?
                        How is storage provisioned?
                        How close are your dependencies?



Monday, July 12, 2010                                       28
Java Code




Monday, July 12, 2010               29
jclouds                            github jclouds/jclouds


 service = new ComputeServiceContextFactory().createContext(
             “rimuhosting”, user, password ).getComputeService();

 template = service.templateBuilder().any().biggest().build();

 template.getOptions().installPrivateKey(privateRSA)
                      .authorizePublicKey(publicRSA)
                      .runScript(installGemsAndRunChef);

 nodes = service.runNodesWithTag(“webserver”, 5, template);




Monday, July 12, 2010                                               30
dasein                        sourceforge dasein-cloud


 CloudProvider provider = providerClass.newInstance();

 ProviderContext context = new ProviderContext();

 context.setAccountNumber(accountNumber);
 context.setAccessPublic(apiKeyBytes);
 context.setAccessPrivate(privateKeyBytes);

 provider.connect(context);

 ServerServices services = provider.getServerServices();

 server = services.launch(imageId,             size,
                          dataCenterId,        serverName,
                          keypairOrPassword,   vlan,
                          analytics,           firewalls);


Monday, July 12, 2010                                        31
whirr                               github tomwhite/whirr


 ServiceSpec serviceSpec = new ServiceSpec();

 serviceSpec.setProvider("gogrid");
 serviceSpec.setAccount(account);
 serviceSpec.setKey(key);
 serviceSpec.setSecretKeyFile(secretKeyFile);
 serviceSpec.setClusterName(clusterName);

 service = new HadoopService(serviceSpec);

 ClusterSpec clusterSpec = new ClusterSpec(
    new InstanceTemplate(1, HadoopService.MASTER_ROLE),
    new InstanceTemplate(1, HadoopService.WORKER_ROLE));

 cluster = service.launchCluster(clusterSpec);
 proxy = new HadoopProxy(serviceSpec, cluster);
 proxy.start();

Monday, July 12, 2010                                      32
jclouds-chef                      github jclouds/jclouds

context = ChefContextFactory.createContext(server, identity, key);

rsaPrivateKey = context.getApi().createClient(clientName);

cookbooks = context.getApi().listCookbooks();

ChefAsyncClient nonBlockingClient = context.getAsyncApi();

nonBlockingClient.uploadCookbook(“apache2”,
                                new File(“/cookbooks/apache2.tgz”));




Monday, July 12, 2010                                                  33
(code clojure)




Monday, July 12, 2010                    34
jclouds                            github jclouds/jclouds


 (def service
   (compute-service “ec2” account key :ssh :log4j))

 (with-compute-service [service]
   (def template
     (build-template :run-script bootstrap))
   (def node
     (run-node "couchdb" template))
   (create-volume :node node :size 250))




Monday, July 12, 2010                                    35
crane                                 github clj-sys/crane



 (def hadoop-config (conf "/path/to/conf.clj"))

 (def compute (ec2 (creds "/path/to/creds.clj")))

 (launch-hadoop-cluster compute hadoop-config)




Monday, July 12, 2010                                         36
pallet                        github hugoduncan/pallet


 (defnode webserver []
     :bootstrap [(public-dns-if-no-nameserver)
                 (automated-admin-user)]
     :configure [(chef)])

 (with-compute-service [service]
   (converge {webserver 3})
   (cook webserver "/cookbooks/apache-chef-demo"))




Monday, July 12, 2010                                 37
Questions?



                  adrian@opscode.org
                  @jclouds
                  http://blog.jclouds.org

Monday, July 12, 2010                       38

Mais conteúdo relacionado

Mais procurados

[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design
Christopher Schmitt
 
jQuery Conference 2012 keynote
jQuery Conference 2012 keynotejQuery Conference 2012 keynote
jQuery Conference 2012 keynote
dmethvin
 
Develop With Pleasure Deploy With Fun Glass Fish And Net Beans For A Better...
Develop With Pleasure  Deploy With Fun  Glass Fish And Net Beans For A Better...Develop With Pleasure  Deploy With Fun  Glass Fish And Net Beans For A Better...
Develop With Pleasure Deploy With Fun Glass Fish And Net Beans For A Better...
railsconf
 
Choosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkitChoosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkit
Hristo Chakarov
 

Mais procurados (20)

[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design[jqconatx] Adaptive Images for Responsive Web Design
[jqconatx] Adaptive Images for Responsive Web Design
 
Vue JS Intro
Vue JS IntroVue JS Intro
Vue JS Intro
 
jQuery Conference 2012 keynote
jQuery Conference 2012 keynotejQuery Conference 2012 keynote
jQuery Conference 2012 keynote
 
jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010jQuery Keynote - Fall 2010
jQuery Keynote - Fall 2010
 
Develop With Pleasure Deploy With Fun Glass Fish And Net Beans For A Better...
Develop With Pleasure  Deploy With Fun  Glass Fish And Net Beans For A Better...Develop With Pleasure  Deploy With Fun  Glass Fish And Net Beans For A Better...
Develop With Pleasure Deploy With Fun Glass Fish And Net Beans For A Better...
 
Accessibility - A feature you can build
Accessibility - A feature you can buildAccessibility - A feature you can build
Accessibility - A feature you can build
 
SEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer ExperienceSEE 2009: Improving Mobile Web Developer Experience
SEE 2009: Improving Mobile Web Developer Experience
 
Building single page applications
Building single page applicationsBuilding single page applications
Building single page applications
 
JavaScript MV* Framework - Making the Right Choice
JavaScript MV* Framework - Making the Right ChoiceJavaScript MV* Framework - Making the Right Choice
JavaScript MV* Framework - Making the Right Choice
 
Real World Web components
Real World Web componentsReal World Web components
Real World Web components
 
The Future Of Web Frameworks
The Future Of Web FrameworksThe Future Of Web Frameworks
The Future Of Web Frameworks
 
Javascript fatigue, 자바스크립트 피로
Javascript fatigue, 자바스크립트 피로Javascript fatigue, 자바스크립트 피로
Javascript fatigue, 자바스크립트 피로
 
S314011 - Developing Composite Applications for the Cloud with Apache Tuscany
S314011 - Developing Composite Applications for the Cloud with Apache TuscanyS314011 - Developing Composite Applications for the Cloud with Apache Tuscany
S314011 - Developing Composite Applications for the Cloud with Apache Tuscany
 
Choosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkitChoosing the best JavaScript framework/library/toolkit
Choosing the best JavaScript framework/library/toolkit
 
jQuery in the [Aol.] Enterprise
jQuery in the [Aol.] EnterprisejQuery in the [Aol.] Enterprise
jQuery in the [Aol.] Enterprise
 
Vue.js Getting Started
Vue.js Getting StartedVue.js Getting Started
Vue.js Getting Started
 
lecture5
lecture5lecture5
lecture5
 
Java Web Application Security - Utah JUG 2011
Java Web Application Security - Utah JUG 2011Java Web Application Security - Utah JUG 2011
Java Web Application Security - Utah JUG 2011
 
High Performance JavaScript (YUIConf 2010)
High Performance JavaScript (YUIConf 2010)High Performance JavaScript (YUIConf 2010)
High Performance JavaScript (YUIConf 2010)
 
Vue.js
Vue.jsVue.js
Vue.js
 

Destaque

Pictures from "Learn about RenderScript" meetup at SF Android User Group
Pictures from "Learn about RenderScript" meetup at SF Android User GroupPictures from "Learn about RenderScript" meetup at SF Android User Group
Pictures from "Learn about RenderScript" meetup at SF Android User Group
Marakana Inc.
 
The Latest on Semantic Web
The Latest on Semantic WebThe Latest on Semantic Web
The Latest on Semantic Web
Marakana Inc.
 
2010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-62010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-6
Marakana Inc.
 
Latest on Semantic Web
Latest on Semantic WebLatest on Semantic Web
Latest on Semantic Web
Shamod Lacoul
 

Destaque (9)

Learn about Eclipse e4 from Lars Vogel at SF-JUG
Learn about Eclipse e4 from Lars Vogel at SF-JUGLearn about Eclipse e4 from Lars Vogel at SF-JUG
Learn about Eclipse e4 from Lars Vogel at SF-JUG
 
Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6Efficient Rails Test-Driven Development - Week 6
Efficient Rails Test-Driven Development - Week 6
 
Efficient Rails Test Driven Development (class 3) by Wolfram Arnold
Efficient Rails Test Driven Development (class 3) by Wolfram ArnoldEfficient Rails Test Driven Development (class 3) by Wolfram Arnold
Efficient Rails Test Driven Development (class 3) by Wolfram Arnold
 
Learn about JRuby Internals from one of the JRuby Lead Developers, Thomas Enebo
Learn about JRuby Internals from one of the JRuby Lead Developers, Thomas EneboLearn about JRuby Internals from one of the JRuby Lead Developers, Thomas Enebo
Learn about JRuby Internals from one of the JRuby Lead Developers, Thomas Enebo
 
Pictures from "Learn about RenderScript" meetup at SF Android User Group
Pictures from "Learn about RenderScript" meetup at SF Android User GroupPictures from "Learn about RenderScript" meetup at SF Android User Group
Pictures from "Learn about RenderScript" meetup at SF Android User Group
 
The Latest on Semantic Web
The Latest on Semantic WebThe Latest on Semantic Web
The Latest on Semantic Web
 
2010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-62010 07-18.wa.rails tdd-6
2010 07-18.wa.rails tdd-6
 
The State of Nextwave Greentech Investing
The State of Nextwave Greentech InvestingThe State of Nextwave Greentech Investing
The State of Nextwave Greentech Investing
 
Latest on Semantic Web
Latest on Semantic WebLatest on Semantic Web
Latest on Semantic Web
 

Semelhante a JClouds at San Francisco Java User Group

JClouds at San Francisco Java User Group
JClouds at San Francisco Java User GroupJClouds at San Francisco Java User Group
JClouds at San Francisco Java User Group
Marakana Inc.
 
Open End To End Js Stack
Open End To End Js StackOpen End To End Js Stack
Open End To End Js Stack
Skills Matter
 
jclouds High Level Overview by Adrian Cole
jclouds High Level Overview by Adrian Colejclouds High Level Overview by Adrian Cole
jclouds High Level Overview by Adrian Cole
Everett Toews
 
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Patrick Chanezon
 

Semelhante a JClouds at San Francisco Java User Group (20)

Joshfire Factory: Building Apps for Billion of Devices
Joshfire Factory: Building Apps for Billion of DevicesJoshfire Factory: Building Apps for Billion of Devices
Joshfire Factory: Building Apps for Billion of Devices
 
Big Data & Cloud | Cloud Storage Simplified | Adrian Cole
Big Data & Cloud | Cloud Storage Simplified | Adrian ColeBig Data & Cloud | Cloud Storage Simplified | Adrian Cole
Big Data & Cloud | Cloud Storage Simplified | Adrian Cole
 
JClouds at San Francisco Java User Group
JClouds at San Francisco Java User GroupJClouds at San Francisco Java User Group
JClouds at San Francisco Java User Group
 
Open End To End Js Stack
Open End To End Js StackOpen End To End Js Stack
Open End To End Js Stack
 
jclouds High Level Overview by Adrian Cole
jclouds High Level Overview by Adrian Colejclouds High Level Overview by Adrian Cole
jclouds High Level Overview by Adrian Cole
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 
Charles
CharlesCharles
Charles
 
Sjug aug 2010_cloud
Sjug aug 2010_cloudSjug aug 2010_cloud
Sjug aug 2010_cloud
 
Open Innovation means Open Source
Open Innovation means Open SourceOpen Innovation means Open Source
Open Innovation means Open Source
 
jclouds overview
jclouds overviewjclouds overview
jclouds overview
 
Camlistore reprise at Google NYC
Camlistore reprise at Google NYCCamlistore reprise at Google NYC
Camlistore reprise at Google NYC
 
Surrogate dependencies (in node js) v1.0
Surrogate dependencies  (in node js)  v1.0Surrogate dependencies  (in node js)  v1.0
Surrogate dependencies (in node js) v1.0
 
Distributed Identities with OpenID
Distributed Identities with OpenIDDistributed Identities with OpenID
Distributed Identities with OpenID
 
Bar Camp Auckland - Mongo DB Presentation BCA4
Bar Camp Auckland - Mongo DB Presentation BCA4Bar Camp Auckland - Mongo DB Presentation BCA4
Bar Camp Auckland - Mongo DB Presentation BCA4
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
Kotlin server side frameworks
Kotlin server side frameworksKotlin server side frameworks
Kotlin server side frameworks
 
Mobile App Performance: Getting the Most from APIs (MBL203) | AWS re:Invent ...
Mobile App Performance:  Getting the Most from APIs (MBL203) | AWS re:Invent ...Mobile App Performance:  Getting the Most from APIs (MBL203) | AWS re:Invent ...
Mobile App Performance: Getting the Most from APIs (MBL203) | AWS re:Invent ...
 
DDS on the Web: Quick Recipes for Real-Time Web Applications
DDS on the Web: Quick Recipes for Real-Time Web ApplicationsDDS on the Web: Quick Recipes for Real-Time Web Applications
DDS on the Web: Quick Recipes for Real-Time Web Applications
 
Cloud foundry and openstackcloud
Cloud foundry and openstackcloudCloud foundry and openstackcloud
Cloud foundry and openstackcloud
 
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
Cloud Foundry, the Open Platform as a Service - Oscon - July 2012
 

Mais de Marakana Inc.

Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven Development
Marakana Inc.
 
Why Java Needs Hierarchical Data
Why Java Needs Hierarchical DataWhy Java Needs Hierarchical Data
Why Java Needs Hierarchical Data
Marakana Inc.
 
Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)
Marakana Inc.
 
A hands on overview of the semantic web
A hands on overview of the semantic webA hands on overview of the semantic web
A hands on overview of the semantic web
Marakana Inc.
 

Mais de Marakana Inc. (20)

Android Services Black Magic by Aleksandar Gargenta
Android Services Black Magic by Aleksandar GargentaAndroid Services Black Magic by Aleksandar Gargenta
Android Services Black Magic by Aleksandar Gargenta
 
JRuby at Square
JRuby at SquareJRuby at Square
JRuby at Square
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven Development
 
Martin Odersky: What's next for Scala
Martin Odersky: What's next for ScalaMartin Odersky: What's next for Scala
Martin Odersky: What's next for Scala
 
Why Java Needs Hierarchical Data
Why Java Needs Hierarchical DataWhy Java Needs Hierarchical Data
Why Java Needs Hierarchical Data
 
Deep Dive Into Android Security
Deep Dive Into Android SecurityDeep Dive Into Android Security
Deep Dive Into Android Security
 
Securing Android
Securing AndroidSecuring Android
Securing Android
 
Android UI Tips, Tricks and Techniques
Android UI Tips, Tricks and TechniquesAndroid UI Tips, Tricks and Techniques
Android UI Tips, Tricks and Techniques
 
Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)Graphicsand animations devoxx2010 (1)
Graphicsand animations devoxx2010 (1)
 
jQuery State of the Union - Yehuda Katz
jQuery State of the Union - Yehuda KatzjQuery State of the Union - Yehuda Katz
jQuery State of the Union - Yehuda Katz
 
Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...
Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...
Pics from: "James Gosling on Apple, Apache, Google, Oracle and the Future of ...
 
Efficient Rails Test Driven Development (class 4) by Wolfram Arnold
Efficient Rails Test Driven Development (class 4) by Wolfram ArnoldEfficient Rails Test Driven Development (class 4) by Wolfram Arnold
Efficient Rails Test Driven Development (class 4) by Wolfram Arnold
 
Replacing Java Incrementally
Replacing Java IncrementallyReplacing Java Incrementally
Replacing Java Incrementally
 
Learn to Build like you Code with Apache Buildr
Learn to Build like you Code with Apache BuildrLearn to Build like you Code with Apache Buildr
Learn to Build like you Code with Apache Buildr
 
Learn How to Unit Test Your Android Application (with Robolectric)
Learn How to Unit Test Your Android Application (with Robolectric)Learn How to Unit Test Your Android Application (with Robolectric)
Learn How to Unit Test Your Android Application (with Robolectric)
 
Learn Learn how to build your mobile back-end with MongoDB
Learn Learn how to build your mobile back-end with MongoDBLearn Learn how to build your mobile back-end with MongoDB
Learn Learn how to build your mobile back-end with MongoDB
 
A hands on overview of the semantic web
A hands on overview of the semantic webA hands on overview of the semantic web
A hands on overview of the semantic web
 
Jena framework
Jena frameworkJena framework
Jena framework
 
Super simple application security with Apache Shiro
Super simple application security with Apache ShiroSuper simple application security with Apache Shiro
Super simple application security with Apache Shiro
 
Overview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUGOverview of Java EE 6 by Roberto Chinnici at SFJUG
Overview of Java EE 6 by Roberto Chinnici at SFJUG
 

JClouds at San Francisco Java User Group

  • 1. connecting java (and clojure) to the cloud adrian@opscode.com @jclouds http://blog.jclouds.org Monday, July 12, 2010 1
  • 2. Agenda • Motivation • jclouds • BlobStores • Provisioning Monday, July 12, 2010 2
  • 3. Motivation • Cloud Storage • Vendors • Differences Monday, July 12, 2010 3
  • 4. what is key value storage? global name space key, value with metadata http accessible sites on demand unlimited scaling Monday, July 12, 2010 4
  • 5. key value storage concepts GLOBAL NAME SPACE KEY/ VALUE Monday, July 12, 2010 5
  • 7. They aren’t the same Monday, July 12, 2010 7
  • 8. • FILE SIZE • RESUMABILITY Monday, July 12, 2010 8
  • 9. CONTENT DELIVERY NETWORK REPLICATION SLA Monday, July 12, 2010 9
  • 13. CODE AND SIGN THE HTTP REQUEST PUT /adriansmovies/sushi.avi HTTP/1.1 PUT /sushi.avi HTTP/1.1 Host: <account>.blob.core.windows.net Host: adriansmovies.s3.amazonaws.com Content-Length: 734859264 Content-Length: 734859264 Date: Wed, 01 Mar 2006 12:00:00 GMT Date: Wed, 01 Mar 2006 12:00:00 GMT Authorization: SharedKey <app>:signature Authorization: signature x-ms-meta-Chef: Kawasaki x-amz-meta-Chef: Kawasaki POST /namespace/adriansmovies/sushi.avi HTTP/1.1 PUT /<api version>/<account>/ Content-Length: 734859264 adriansmovies/sushi.avi HTTP/1.1 Date: Wed, 01 Mar 2006 12:00:00 GMT Host: storage.clouddrive.com x-emc-uid: <uid> Transfer-Encoding: chunked x-emc-signature: signature X-Auth-Token: session-token x-emc-meta: Chef=Kawasaki X-Object-Meta-Chef: Kawasaki Monday, July 12, 2010 13
  • 14. CODE AND SIGN THE HTTP REQUEST GET /ws/IMFS/GetStorageNodeExtended.ashx?&fileOverwrite=true&ipRestricted=true&destFolderPath= adriansmovies&sizeBytes= 734859264&firstByteExpiration=6000&lastByteExpiration=259200&sessionToken=session-token HTTP/1.1 POST /Upload.ashx?uploadToken=from_above&destFolderPath=adriansmovies HTTP/1.1 Host: from_above Content-Length: 734859382 Content-Type=multipart/form-data; boundary=--jclouds-- Authorization=Basic GpjbG9= ----jclouds-- Content-Disposition: form-data; name="sushi.avi"; filename="sushi.avi" Content-Type: application/octetstring ... PUT /ws/Metadata/SetMetadata.ashx?&path=Folders/adriansmovies/sushi.avi&sessionToken=session-token&metadata=Chef:Kawasaki HTTP/1.1 Monday, July 12, 2010 14
  • 15. CODE AND SIGN THE HTTP REQUEST POST /<api version>/containers/id_of_ adriansmovies/contents HTTP/1.1 Content-Length: 734859382 Content-Type=multipart/form-data; boundary=--jclouds-- Authorization=Basic GpjbG9= ----jclouds-- Content-Disposition: form-data; name="sushi.avi"; filename="sushi.avi" Content-Type: application/octetstring ... PUT /<api version>/files/from_above/metadata/Chef HTTP/1.1 Content-Length: 8 Content-Type: text/plain Authorization: Basic GpjbG9= Kawasaki Monday, July 12, 2010 15
  • 16. do you want to • Deal with Errors • Deal with Concurrency • Deal with Cloud Complexity Monday, July 12, 2010 16
  • 17. jclouds open source feels like java (and clojure) portability between clouds deal with web complexity unit testability thread-safe and scalable Monday, July 12, 2010 17
  • 18. Tools we provide • Abstractions • BlobStore ( atmos, azure, rackspace, s3 ) • Compute ( vcloud, ec2, gogrid, ibmdev, rackspace, rimu ) • Clojure bindings • Third-party library integration Monday, July 12, 2010 18
  • 19. Alternatives to jclouds • Roll-your-own • Jersey, RESTEasy • EC2-based cloud apis • typica, jets3t • Dasein Cloud API • Service provided SDKs Monday, July 12, 2010 19
  • 20. BlobStore • Java Code • Clojure Code Monday, July 12, 2010 20
  • 21. java // init context = new BlobStoreContextFactory().createContext( "s3", accesskeyid, secretaccesskey); blobStore = context.getBlobStore(); // create container blobStore.createContainerInLocation(null, "mycontainer"); // add blob blob = blobStore.newBlob("test"); blob.setPayload("testdata"); blobStore.putBlob(containerName, blob); Monday, July 12, 2010 21
  • 22. commons vfs vfs > open blobstore://user:key@cloudfiles/mycontainer Opened blobstore://cloudfiles/mycontainer/ Current folder is blobstore://cloudfiles/mycontainer/ vfs > ls Contents of blobstore://cloudfiles/mycontainer/ README.txt 0 Folder(s), 1 File(s) vfs > close Monday, July 12, 2010 22
  • 23. clojure (ns demo   (:use org.jclouds.blobstore)   (:use clojure.contrib.pprint) )  (def blobstore (blobstore-context service account secret ))  (pprint (containers blobstore))  (pprint (blobs blobstore "mycontainer" )) Monday, July 12, 2010 23
  • 24. Provisioning • The Good, the Bad, and the Ugly • Java Code • Clojure Code Monday, July 12, 2010 24
  • 25. The Good provisioning (and re-provisioning) is cheap APIs = automation tools exist Monday, July 12, 2010 25
  • 26. The Bad forgetting to turn things off licensing erratic service quality Monday, July 12, 2010 26
  • 27. The Ugly cloud apis are sometimes unreliable apis are very different across clouds features are very different across clouds accidental complexity Monday, July 12, 2010 27
  • 28. Things to consider when provisioning Can you create an image? Can you push credentials or files? Do you need to VPN in? How is storage provisioned? How close are your dependencies? Monday, July 12, 2010 28
  • 29. Java Code Monday, July 12, 2010 29
  • 30. jclouds github jclouds/jclouds service = new ComputeServiceContextFactory().createContext( “rimuhosting”, user, password ).getComputeService(); template = service.templateBuilder().any().biggest().build(); template.getOptions().installPrivateKey(privateRSA) .authorizePublicKey(publicRSA) .runScript(installGemsAndRunChef); nodes = service.runNodesWithTag(“webserver”, 5, template); Monday, July 12, 2010 30
  • 31. dasein sourceforge dasein-cloud CloudProvider provider = providerClass.newInstance(); ProviderContext context = new ProviderContext(); context.setAccountNumber(accountNumber); context.setAccessPublic(apiKeyBytes); context.setAccessPrivate(privateKeyBytes); provider.connect(context); ServerServices services = provider.getServerServices(); server = services.launch(imageId, size, dataCenterId, serverName, keypairOrPassword, vlan, analytics, firewalls); Monday, July 12, 2010 31
  • 32. whirr github tomwhite/whirr ServiceSpec serviceSpec = new ServiceSpec(); serviceSpec.setProvider("gogrid"); serviceSpec.setAccount(account); serviceSpec.setKey(key); serviceSpec.setSecretKeyFile(secretKeyFile); serviceSpec.setClusterName(clusterName); service = new HadoopService(serviceSpec); ClusterSpec clusterSpec = new ClusterSpec( new InstanceTemplate(1, HadoopService.MASTER_ROLE), new InstanceTemplate(1, HadoopService.WORKER_ROLE)); cluster = service.launchCluster(clusterSpec); proxy = new HadoopProxy(serviceSpec, cluster); proxy.start(); Monday, July 12, 2010 32
  • 33. jclouds-chef github jclouds/jclouds context = ChefContextFactory.createContext(server, identity, key); rsaPrivateKey = context.getApi().createClient(clientName); cookbooks = context.getApi().listCookbooks(); ChefAsyncClient nonBlockingClient = context.getAsyncApi(); nonBlockingClient.uploadCookbook(“apache2”, new File(“/cookbooks/apache2.tgz”)); Monday, July 12, 2010 33
  • 35. jclouds github jclouds/jclouds (def service (compute-service “ec2” account key :ssh :log4j)) (with-compute-service [service] (def template (build-template :run-script bootstrap)) (def node (run-node "couchdb" template)) (create-volume :node node :size 250)) Monday, July 12, 2010 35
  • 36. crane github clj-sys/crane (def hadoop-config (conf "/path/to/conf.clj")) (def compute (ec2 (creds "/path/to/creds.clj"))) (launch-hadoop-cluster compute hadoop-config) Monday, July 12, 2010 36
  • 37. pallet github hugoduncan/pallet (defnode webserver []     :bootstrap [(public-dns-if-no-nameserver)               (automated-admin-user)]   :configure [(chef)]) (with-compute-service [service]   (converge {webserver 3})   (cook webserver "/cookbooks/apache-chef-demo")) Monday, July 12, 2010 37
  • 38. Questions? adrian@opscode.org @jclouds http://blog.jclouds.org Monday, July 12, 2010 38