Cloud Foundry for Spring Developers

Gunnar Hillert
Gunnar HillertSoftware Developer at Hillert, Inc.
Cloud Foundry for Spring Developers

Gunnar Hillert, Member of Technical Staff, Spring Integration




                                                                © 2011 SpringSource, A division of VMware. All rights reserved
Agenda

§  Overview
§  Deployment
§  Debugging
§  Profiling
§  Agnostic War Files
§  Modular Cloud Apps




                         2
What is Cloud Foundry?




                         3
4
Three Layers of Cloud Computing




§  SaaS
  •  Software as a Service


§  PaaS
  •  Platform as a Service


§  IaaS
  •  Infrastructure as a Service




                                   5
Choice of clouds




                                        .js



       Data
       Services
                                                        Private	
  	
  
                                                        Clouds	
  	
  
                                                                                 …	
  
                  Msg
                  Services
                                                Public	
  
                                                Clouds	
  
                                                                          .COM
                              Other     Micro	
  
                             Services
                                        Clouds	
  



                                                                                         6
Broad Support for Languages/Application Frameworks

§  JVM
  •  Spring, Grails, Roo, Lift, plain Java
§  Ruby
  •  Rails, Sinatra
§  Node.js
§  Community contributions
  •  Erlang, Python, PHP




                                                     7
JVM Frameworks

§  Unit of deployment: Java WAR files
  •  Can run any standard War file
  •  Servlet 2.5
  •  Don’t assume particular container
§  Spring, Grails, Lift framework
  •  Auto-reconfiguration goodies




                                         8
Services

§  Relational database
  •  Postgres
  •  MySQL
§  Key-value store
  •  Redis
§  Document store
  •  MongoDB
§  Messaging
  •  RabbitMQ




                          9
Open Source

§  Source code available under Apache License v2.0
 •  https://github.com/cloudfoundry/
•  VCAP
 •  https://github.com/cloudfoundry/vcap
•  Project Website
 •  http://cloudfoundry.org/




                                                      10
Logical View




               11
Architecture

     Architecture




           25
 Thursday, October 27, 11   12
Deployment Options




                     13
Deployment Options

§  VMC
  •  Ruby based command line tool
§  SpringSource Tool Suite (STS)
§  Grails
§  Spring Roo Cloud Foundry Addon
§  Cloud Foundry Maven Plugin
§  vcap-java-client
  •  Used by STS and Cloud Foundry Maven Plugin




                                                  14
DEMO
Deployment Options




                     15
Debugging




            16
Debugging

§  Start Cloud Foundry applications in debug mode
§  Set Break Points for Micro Cloud Foundry
§  STS 2.8.1 supports it
§  Coming with Micro Cloud Foundry 1.1.1 (Currently RC)




                                                           17
Caldecott

§  TCP over HTTP tunnel
§  Local client
§  Remote server




                           18
Caldecott - Multiple Services and Sessions

§  One vcc server instance
 •  Manages multiple tunnels
§  One vcc client instance per service
 •  Multiple local apps may share a
   client if they connect to the same
   remote server:port
 •  Each listens on different local port




                                             19
DEMO
Debugging




            20
Profiling




            21
Profiling – Spring Insight

§  Providing real-time application runtime performance and behavior
 information for Java Spring applications
§  Beta available for CloudFoundry.com
§  Signup at: insight.cloudfoundry.com
§  Write your own plugins
 •  https://github.com/SpringSource/spring-insight-plugins




                                                                       22
DEMO
Spring Insight for Cloud Foundry




                                   23
Agnostic War Files




                     24
Agnostic War Files – Toolbox

§  Auto Reconfiguration
§  Cloud Namespace
§  Spring 3.1 Profiles




                               25
Agnostic War Files – Auto Reconfiguration

§  Move existing Applications easily to Cloud Foundry
§  Makes 2 modifications at deploy time:
 •  Adds additional Jar
 •  Updates web.xml
§  BeanFactoryPostProcessor examines the application context before
 creating beans
§  Swaps existing beans of matching types




                                                                   26
Agnostic War Files – Auto Reconfiguration




        Service Type                 Replaced Bean Type

           MySQL       javax.sql.DataSource

          Postgres     javax.sql.DataSource

           Redis       org.sf.data.redis.connection.RedisConnectionFactory

          MongoDB      org.sf.data.document.mongodb.MongoDbFactory

          RabbitMQ     org.sf.amqp.rabbit.connection.ConnectionFactory




                                                                             27
Agnostic War Files – Auto Reconfiguration

§  Limitations
  •  one service of a given service type
  •  one bean of the matching type
  •  If application does not follow limits, auto-reconfiguration mechanism will not take
   place




                                                                                      28
Agnostic War Files – Cloud Namespace

§  Explicit configuration of Cloud Foundry Services
§  Finer grained control of configuration parameters
§  Necessary when configuring multiple services of same type




                                                                29
Agnostic War Files – Cloud Namespace

§  Setup – Maven
<dependency>
  <groupId>org.cloudfoundry</groupId>
  <artifactId>cloudfoundry-runtime</artifactId>
  <version>0.8.1</version>
</dependency>


§  Setup – Spring Application Context

<?xml version="1.0" encoding="UTF-8"?>
<beans …
 xmlns:cloud="http://schema.cloudfoundry.org/spring"
 xsi:schemaLocation=“http://schema.cloudfoundry.org/spring
     http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.8.xsd">


                                                                           30
Available Namespace Elements

§  Define and use a DataSource

 <cloud:data-source id="dataSource" />

 <bean id="jdbcTemplate”
       class="org.springframework.jdbc.core.JdbcTemplate">
  <property name="dataSource" ref="dataSource" />
 </bean>


§  Optional Subelements
 •  <cloud:connection>
 •  <cloud:pool>




                                                             31
Available Namespace Elements

§  MongoDB Support
 •  <cloud:mongo-db-factory>

§  Redis Support
 •  <cloud:redis-connection-factory>

§  RabbitMQ
 •  <cloud:rabbit-connection-factory>



§  Autocreate Services
 •  <cloud:service-scan>




                                        32
Agnostic War Files – Spring Profiles

§  Spring 3.1 adds new support for environments
§  Deploy to Cloud Foundry and Stand-alone Containers

<bean id="mongoTemplate"
      class="org.springframework.data.mongodb.core.MongoTemplate">
  <constructor-arg ref="mongoDbFactory" />
</bean>

<beans profile="default">
  <mongo:db-factory id="mongoDbFactory" dbname="pwdtest"
                    host="127.0.0.1" port="27017"
                    username="test_user" password=”s3cr3t" />
</beans>

<beans profile="cloud">
  <cloud:mongo-db-factory id="mongoDbFactory" />
</beans>
                                                                     33
Modular Cloud Apps




                     34
Monolithic Enterprise Application




                                    35
Benefits of App-level Modularity

§  Efficient Elasticity
§  Fault Isolation
§  Dynamic Configuration
§  “always-on”/Rolling Upgrades




                                   36
Modularized Enterprise Application




                                     37
DEMO
Spring Integration




                     38
Resources




            39
Resources

§  Cloud Foundry on Ubuntu
  http://blog.dustinkirkland.com/2011/08/howto-install-cloudfoundry-server-
  paas.html


§  VMC
  http://support.cloudfoundry.com/entries/20012337-getting-started-guide-
  command-line-vmc-users

  http://cloudfoundry.zendesk.com/entries/20012462-getting-started-guide-sts-users

  http://blog.dustinkirkland.com/2011/07/getting-started-with-cloudfoundry.html

  http://blog.cloudfoundry.com/post/9037486110/vmc-everywhere




                                                                                  40
Resources

§  Cloud Foundry Maven Plugin
  http://blog.springsource.com/2011/09/22/rapid-cloud-foundry-deployments-with-
  maven/

  https://github.com/cloudfoundry/vcap-java-client/tree/master/cloudfoundry-maven-
  plugin (Sources + Reference Documentation)


§  Caldecott
  http://blog.cloudfoundry.com/post/12928974099/now-you-can-tunnel-into-any-
  cloud-foundry-data-service


§  Cloud Foundry Samples
  https://github.com/SpringSource/cloudfoundry-samples




                                                                                  41
Resources

§  Spring Auto Reconfiguration
  http://blog.springsource.org/2011/11/04/using-cloud-foundry-services-with-spring-
  part-2-auto-reconfiguration/


§  Spring Insight for Cloud Foundry
  http://insight.cloudfoundry.com/


§  Cloud Foundry Namespace
  http://blog.springsource.org/2011/11/09/using-cloud-foundry-services-with-spring-
  applications-part-3-the-cloud-namespace/


§  Spring Profiles
  http://blog.springsource.org/2011/11/10/using-cloud-foundry-services-with-spring-
  part-4-%E2%80%93-spring-profiles/


                                                                                  42
Resources

§  Spring Integration
  http://www.springsource.org/spring-integration
  https://github.com/SpringSource/spring-integration


§  Samples
  https://github.com/SpringSource/cloudfoundry-samples
  https://github.com/markfisher/springone-wgrus




                                                         43
THANK YOU!
     Sign up for a free account at: http://www.cloudfoundry.com/




Email:      ghillert@vmware.com
Twitter:    https://twitter.com/ghillert
Blog:       http://blog.hillert.com

                                                                   44
1 of 44

More Related Content

What's hot(20)

Introduction to WebMvc.fnIntroduction to WebMvc.fn
Introduction to WebMvc.fn
VMware Tanzu343 views
Security model for a remote companySecurity model for a remote company
Security model for a remote company
Pierre Mavro159 views
Spring Boot on Kubernetes/OpenShiftSpring Boot on Kubernetes/OpenShift
Spring Boot on Kubernetes/OpenShift
Kamesh Sampath1.5K views
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
NexThoughts Technologies3.3K views
Session 4 - News from ACS CommunitySession 4 - News from ACS Community
Session 4 - News from ACS Community
tcloudcomputing-tw3.8K views
If Hemingway Wrote JavaDocsIf Hemingway Wrote JavaDocs
If Hemingway Wrote JavaDocs
VMware Tanzu448 views

Viewers also liked(20)

Cloud Foundry Technical OverviewCloud Foundry Technical Overview
Cloud Foundry Technical Overview
cornelia davis96.5K views
Cloudfoundry architectureCloudfoundry architecture
Cloudfoundry architecture
Ramnivas Laddad18.4K views
Bluemix IoT Cloud Foundry Meetup slidesBluemix IoT Cloud Foundry Meetup slides
Bluemix IoT Cloud Foundry Meetup slides
Valerie Lampkin963 views
Devoxx 2014 presentationDevoxx 2014 presentation
Devoxx 2014 presentation
Eric Cattoir2.8K views
Cloud foundryCloud foundry
Cloud foundry
Isuru Perera2.5K views
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
Andy Piper1.9K views
Cloud Foundry 101Cloud Foundry 101
Cloud Foundry 101
Juan Pablo Genovese821 views
What is BOSH? An over-overviewWhat is BOSH? An over-overview
What is BOSH? An over-overview
Juan Pablo Genovese951 views
Cloud Foundry Command LineCloud Foundry Command Line
Cloud Foundry Command Line
Julia R Nash490 views
Cloud Foundry BootcampCloud Foundry Bootcamp
Cloud Foundry Bootcamp
Joshua Long2.7K views
Cloud Foundry, the Open Platform As A ServiceCloud Foundry, the Open Platform As A Service
Cloud Foundry, the Open Platform As A Service
Patrick Chanezon10.5K views
What's New in Cloud FoundryWhat's New in Cloud Foundry
What's New in Cloud Foundry
Jennifer Hickey2.8K views
Introduction to Cloud Foundry #JJUGIntroduction to Cloud Foundry #JJUG
Introduction to Cloud Foundry #JJUG
Toshiaki Maki9.9K views

More from Gunnar Hillert(16)

Recently uploaded(20)

CXL at OCPCXL at OCP
CXL at OCP
CXL Forum203 views
ChatGPT and AI for Web DevelopersChatGPT and AI for Web Developers
ChatGPT and AI for Web Developers
Maximiliano Firtman161 views
Liqid: Composable CXL PreviewLiqid: Composable CXL Preview
Liqid: Composable CXL Preview
CXL Forum120 views

Cloud Foundry for Spring Developers

  • 1. Cloud Foundry for Spring Developers Gunnar Hillert, Member of Technical Staff, Spring Integration © 2011 SpringSource, A division of VMware. All rights reserved
  • 2. Agenda §  Overview §  Deployment §  Debugging §  Profiling §  Agnostic War Files §  Modular Cloud Apps 2
  • 3. What is Cloud Foundry? 3
  • 4. 4
  • 5. Three Layers of Cloud Computing §  SaaS •  Software as a Service §  PaaS •  Platform as a Service §  IaaS •  Infrastructure as a Service 5
  • 6. Choice of clouds .js Data Services Private     Clouds     …   Msg Services Public   Clouds   .COM Other Micro   Services Clouds   6
  • 7. Broad Support for Languages/Application Frameworks §  JVM •  Spring, Grails, Roo, Lift, plain Java §  Ruby •  Rails, Sinatra §  Node.js §  Community contributions •  Erlang, Python, PHP 7
  • 8. JVM Frameworks §  Unit of deployment: Java WAR files •  Can run any standard War file •  Servlet 2.5 •  Don’t assume particular container §  Spring, Grails, Lift framework •  Auto-reconfiguration goodies 8
  • 9. Services §  Relational database •  Postgres •  MySQL §  Key-value store •  Redis §  Document store •  MongoDB §  Messaging •  RabbitMQ 9
  • 10. Open Source §  Source code available under Apache License v2.0 •  https://github.com/cloudfoundry/ •  VCAP •  https://github.com/cloudfoundry/vcap •  Project Website •  http://cloudfoundry.org/ 10
  • 12. Architecture Architecture 25 Thursday, October 27, 11 12
  • 14. Deployment Options §  VMC •  Ruby based command line tool §  SpringSource Tool Suite (STS) §  Grails §  Spring Roo Cloud Foundry Addon §  Cloud Foundry Maven Plugin §  vcap-java-client •  Used by STS and Cloud Foundry Maven Plugin 14
  • 16. Debugging 16
  • 17. Debugging §  Start Cloud Foundry applications in debug mode §  Set Break Points for Micro Cloud Foundry §  STS 2.8.1 supports it §  Coming with Micro Cloud Foundry 1.1.1 (Currently RC) 17
  • 18. Caldecott §  TCP over HTTP tunnel §  Local client §  Remote server 18
  • 19. Caldecott - Multiple Services and Sessions §  One vcc server instance •  Manages multiple tunnels §  One vcc client instance per service •  Multiple local apps may share a client if they connect to the same remote server:port •  Each listens on different local port 19
  • 21. Profiling 21
  • 22. Profiling – Spring Insight §  Providing real-time application runtime performance and behavior information for Java Spring applications §  Beta available for CloudFoundry.com §  Signup at: insight.cloudfoundry.com §  Write your own plugins •  https://github.com/SpringSource/spring-insight-plugins 22
  • 23. DEMO Spring Insight for Cloud Foundry 23
  • 25. Agnostic War Files – Toolbox §  Auto Reconfiguration §  Cloud Namespace §  Spring 3.1 Profiles 25
  • 26. Agnostic War Files – Auto Reconfiguration §  Move existing Applications easily to Cloud Foundry §  Makes 2 modifications at deploy time: •  Adds additional Jar •  Updates web.xml §  BeanFactoryPostProcessor examines the application context before creating beans §  Swaps existing beans of matching types 26
  • 27. Agnostic War Files – Auto Reconfiguration Service Type Replaced Bean Type MySQL javax.sql.DataSource Postgres javax.sql.DataSource Redis org.sf.data.redis.connection.RedisConnectionFactory MongoDB org.sf.data.document.mongodb.MongoDbFactory RabbitMQ org.sf.amqp.rabbit.connection.ConnectionFactory 27
  • 28. Agnostic War Files – Auto Reconfiguration §  Limitations •  one service of a given service type •  one bean of the matching type •  If application does not follow limits, auto-reconfiguration mechanism will not take place 28
  • 29. Agnostic War Files – Cloud Namespace §  Explicit configuration of Cloud Foundry Services §  Finer grained control of configuration parameters §  Necessary when configuring multiple services of same type 29
  • 30. Agnostic War Files – Cloud Namespace §  Setup – Maven <dependency> <groupId>org.cloudfoundry</groupId> <artifactId>cloudfoundry-runtime</artifactId> <version>0.8.1</version> </dependency> §  Setup – Spring Application Context <?xml version="1.0" encoding="UTF-8"?> <beans … xmlns:cloud="http://schema.cloudfoundry.org/spring" xsi:schemaLocation=“http://schema.cloudfoundry.org/spring http://schema.cloudfoundry.org/spring/cloudfoundry-spring-0.8.xsd"> 30
  • 31. Available Namespace Elements §  Define and use a DataSource <cloud:data-source id="dataSource" /> <bean id="jdbcTemplate” class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource" /> </bean> §  Optional Subelements •  <cloud:connection> •  <cloud:pool> 31
  • 32. Available Namespace Elements §  MongoDB Support •  <cloud:mongo-db-factory> §  Redis Support •  <cloud:redis-connection-factory> §  RabbitMQ •  <cloud:rabbit-connection-factory> §  Autocreate Services •  <cloud:service-scan> 32
  • 33. Agnostic War Files – Spring Profiles §  Spring 3.1 adds new support for environments §  Deploy to Cloud Foundry and Stand-alone Containers <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg ref="mongoDbFactory" /> </bean> <beans profile="default"> <mongo:db-factory id="mongoDbFactory" dbname="pwdtest" host="127.0.0.1" port="27017" username="test_user" password=”s3cr3t" /> </beans> <beans profile="cloud"> <cloud:mongo-db-factory id="mongoDbFactory" /> </beans> 33
  • 36. Benefits of App-level Modularity §  Efficient Elasticity §  Fault Isolation §  Dynamic Configuration §  “always-on”/Rolling Upgrades 36
  • 39. Resources 39
  • 40. Resources §  Cloud Foundry on Ubuntu http://blog.dustinkirkland.com/2011/08/howto-install-cloudfoundry-server- paas.html §  VMC http://support.cloudfoundry.com/entries/20012337-getting-started-guide- command-line-vmc-users http://cloudfoundry.zendesk.com/entries/20012462-getting-started-guide-sts-users http://blog.dustinkirkland.com/2011/07/getting-started-with-cloudfoundry.html http://blog.cloudfoundry.com/post/9037486110/vmc-everywhere 40
  • 41. Resources §  Cloud Foundry Maven Plugin http://blog.springsource.com/2011/09/22/rapid-cloud-foundry-deployments-with- maven/ https://github.com/cloudfoundry/vcap-java-client/tree/master/cloudfoundry-maven- plugin (Sources + Reference Documentation) §  Caldecott http://blog.cloudfoundry.com/post/12928974099/now-you-can-tunnel-into-any- cloud-foundry-data-service §  Cloud Foundry Samples https://github.com/SpringSource/cloudfoundry-samples 41
  • 42. Resources §  Spring Auto Reconfiguration http://blog.springsource.org/2011/11/04/using-cloud-foundry-services-with-spring- part-2-auto-reconfiguration/ §  Spring Insight for Cloud Foundry http://insight.cloudfoundry.com/ §  Cloud Foundry Namespace http://blog.springsource.org/2011/11/09/using-cloud-foundry-services-with-spring- applications-part-3-the-cloud-namespace/ §  Spring Profiles http://blog.springsource.org/2011/11/10/using-cloud-foundry-services-with-spring- part-4-%E2%80%93-spring-profiles/ 42
  • 43. Resources §  Spring Integration http://www.springsource.org/spring-integration https://github.com/SpringSource/spring-integration §  Samples https://github.com/SpringSource/cloudfoundry-samples https://github.com/markfisher/springone-wgrus 43
  • 44. THANK YOU! Sign up for a free account at: http://www.cloudfoundry.com/ Email: ghillert@vmware.com Twitter: https://twitter.com/ghillert Blog: http://blog.hillert.com 44

Editor's Notes

  1. Cloud Controller Main Brain
  2. http://blog.springsource.com/2011/09/22/rapid-cloud-foundry-deployments-with-maven/git clone https://github.com/SpringSource/cloudfoundry-samples.gitcd cloudfoundry-samples/hello-javamvn clean packagevmc helpvmc target http://api.cloudfoundry.comVmc info
  3. ----- Meeting Notes (11/28/11 13:16) -----
  4. Sometime Autoconfiguration is not sufficient