running your spring apps in the cloud

Download Running Your Spring Apps in the Cloud

If you can't read please download the document

Upload: spring-io

Post on 14-Jun-2015

589 views

Category:

Software


3 download

DESCRIPTION

Speaker: Cornelia Davis Developing for the Cloud Track The Spring Trader application was debuted at SpringOne 2GX in 2012 and presented an application that demonstrates a multitude of Pivotal Application Fabric components working together – tcServer, RabbitMQ, SQLFire and Gemfire. In this session we will take that application and make (a few) modifications (mostly to config) to get it running on the same components in the cloud, specifically on the Cloud Foundry PaaS. We’ll show you how to use the Spring Cloud project to configure the deployment, how to leverage a cloud services catalog, how to implement a cross-site scripting solution (and why), how to do session state caching and we’ll discuss (the dangers of) auto reconfiguration. If you bring a laptop you can have your own instance of the app running by the end of the session.

TRANSCRIPT

  • 1. Running your Spring Apps in the CloudCornelia Davis@cdavisafc 2014 SpringOne 2GX. All rights reserved. Do not distribute without permission.

2. Lets push an app 3. Overview: Deploying App toCloud Foundry Runtime Upload appbits andmetadatapush appRouter Create and bind services Stage application Deploy application Manage application healthwhich is a whole nother topicCloud FoundryRuntime (PaaS)Blobstore DBCloudControllerService BrokerNode(s)DEADEADEADEA+ app MD+ =Servicecredentials 4. Software 5. Software is Changing Industries$3.5B valuationFinancial Services$3.5B valuation Travel & Hospitality$3.5B valuation Transportation$1.1B acquisition byMonsanto Agriculture$19B valuation Entertainment$3.2B acquisition byGoogle Digital Home 6. Spring TraderReference Application from VMWare to demonstrate the vFabric Suitehttps://github.com/cf-platform-eng/springtrader-cf 7. From here 8. Agenda (1/2) Auto reconfiguration Services plans Apps and Manifests Cross-site scripting JNDI Service Catalog Spring Cloud Connector 9. Agenda (2/2) Apps as Services Define Service Type XSS 10. Cross-site Scriptinghhtttptp:/://s/tpraridnegrtwraedbe.rc.cfaopmp/sw.ieobhttp://springtrader.com/serviceshttp://traderservices.cfapps.io 11. Cross-site Scriptinghttp://traderfront.cfapps.ioOne war file 12. JNDI Service Instances 13. Spring Cloud ConnectorVCAP_SERVICES locallycf bind-service traderfront tradersqlVCAP_SERVICES={"cleardb-n/a":[{"name":"tradersql","label":"cleardb-n/a","tags":["mysql","relational"],"plan":"spark","credentials":{"jdbcUrl":"jdbc:mysql://baf8a1e6a292a2:[email protected]:3306/ad_595d583f143adee","uri":"mysql://baf8a1e6a292a2:[email protected]:3306/ad_595d583f143adee?reconnect=true","name":"ad_595d583f143adee","hostname":"us-cdbr-east-05.cleardb.net","port":"3306","username":"baf8a1e6a292a2","password":"79581497"}}],"cloudamqp-n/a":[{"name":"tradermessaging","label":"cloudamqp-n/a","tags":["amqp","rabbitmq"],"plan":"lemur","credentials":{"uri":"amqp://klrdpgoo:[email protected]/klrdpgoo"}}]}New:OR... 14. (Big-A) Applications and Manifestshttp://traderfront.cfapps.ioOne war fileAnother war file 15. (Big-A) Applications and Manifests---timeout: 180memory: 1Gdomain: cfapps.ioinstances: 1services:- tradersql- tradermessagingapplications:- name: traderbackGlobal properties apply to all applicationspath: dist/spring-nanotrader-asynch-services-1.0.1.BUILD-SNAPSHOT.warhost: traderback- name: traderfrontpath: dist/spring-nanotrader-services-1.0.1.BUILD-SNAPSHOT.warhost: traderfront 16. Services Marketplace and Plans 17. Auto-reconfigurationOld:New:USE AUTORECONFIGURATION WITH CARE!! (esp. in production) 18. Deal with Cross-site ScriptingEVILdoc = XMLHTTPRequesthttp://example.com/fooWhen different domains: Request will be sent Browser will not makeresponse availableTo accommodate: Service lists domainsfrom which requests willbe allowed 19. Spring Cloud Connector Extension: HTTP Web ServiceSpringCloud Connector built in: Amqp Mongo Monitoring Mysql Oracle Postgresql Redis Smtppublic class BasicHttpWebServiceInfo extends UriBasedServiceInfo {public BasicHttpWebServiceInfo(String id, String host,int port, String username,String password, String virtualHost){super(id, "http", host, port, username, password, virtualHost);}public BasicHttpWebServiceInfo(String id, String uri)throws CloudException {super(id, uri);}} 20. Spring Cloud Connector Extension: HTTP Web Servicepublic class BasicHttpWebServiceInfoCreator extends CloudFoundryServiceInfoCreator{public BasicHttpWebServiceInfoCreator() {super(new Tags(), "http");}public BasicHttpWebServiceInfo createServiceInfo(Map serviceData) {@SuppressWarnings("unchecked")Map credentials = (Map) serviceData.get("credentials");String id = (String) serviceData.get("name");String uri = getStringFromCredentials(credentials, "uri", "url");return new BasicHttpWebServiceInfo(id, uri);Heres the tricky part:Put a file called org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator on yourclasspath containingcom.gopivotal.cloudfoundry.example.springcloud.BasicHttpWebServiceInfoCreatorhttps://github.com/spring-cloud/spring-cloud-connectors/tree/master/spring-cloud-core}} 21. Cross-site Scripting 22. Apps as Servicescf create-service tradersqlcf create-service tradermessagingMessage BrokerData Tier 23. Apps as Servicescf push traderbackcf bind-service traderback stsqlcf bind-service traderback stmessagingMessage Broker Trader BackData Tier 24. Apps as Servicescf push traderfrontcf bind-service traderfront stsqlcf bind-service traderfront stmessagingTrader Front Message Broker Trader BackData Tier 25. Apps as ServicesTrader Frontcf cups traderfront-p '{"uri":"http://traderfront.cfapps.io/api/"}'Message Broker Trader BackData Tier 26. Apps as ServicesTrader Front Message Broker Trader BackData TierTrader Webcf push traderwebcf bind-service traderweb traderfront 27. Session State CachingOriginally designed to useGemfire peer to peerTrader FrontTrader FrontTrader Front 28. Session State CachingDEAFirewalled applicationcontainers restrict this!Trader FrontTrader FrontTrader Front 29. Session State CachingRedis for session statecaching Java buildpack v2.1Pull RequestsWelcome!!Trader FrontTrader FrontTrader Fronthttps://github.com/cloudfoundry/java-buildpack/blob/master/docs/container-tomcat.md#session-replication 30. to here 31. Learn More. Stay Connected Try it out! Register for a free trial account at run.pivotal.io https://github.com/cf-platform-eng/springtrader-cf Further Sessions: 10:45: Simplify Cloud Applications using Spring Cloud 2:30: Developing Microservices for PaaS with Springand Cloud Foundry32 32. Contents Title slide Contents Using this template Intro Inserting slide & applying layout Layouts Fonts Colors Notes for reviewers34 Logos and clip art Logos Event logos and icons Project icons Tool suite icons Document icons Additional icons Clip art Clip art 33. Using this Template35 34. IntroThis template has been carefully prepared with specific layouts,colors, fonts and more. This short intro will outline the basiccomponents of this template.Note: This template includes slides with approved color palette,fonts, logos and clip art. Its a good idea to keep these slides inorder to quickly access these assets then delete the slides whenyou have finished creating your presentation.36 35. Inserting New Slides and Applying Layouts To create different types of slides, select New Slide and applydesired Layout If you make formatting changes to a slide and want to reapply thedefault settings, click Reset37 36. LayoutsThere are 11 layouts Title Slide Presentation title with author name and contact info. Use only once in presentation. Title Only Standard slide with no text content box, do not use for section title Title and Content (1 Col) Standard slide with title and text content box Title and Content (2 Col) Standard slide with title and two text content boxes Comparison Standard slide with title and two text content boxes with subtitles Section Title Use between sections Table Quick and easy way to get a table with brand colors Bar Chart Quick and easy way to get a bar chart with brand colors Line Chart Quick and easy way to get a line chart with brand colors Pie Chart Quick and easy way to get a pie chart with brand colors Code Formatting Quick and easy way to get preferred code formatting38 37. Fonts Title (24pt, bold) All body text is Arial Subhead (22pt) Level Two (18pt)o Level Three (16pt)o Level Four (16pt) Use the Decrease/Increase Indenttools to change bullet levels Click on the Home ribbon, Paragraph tab Line spacing is set in master slides39 38. Brand Colors40Brand ColorsR: 241G: 241B: 241SpringR: 109G: 179B: 63R: 153G: 153B: 153R: 52G: 48B: 45SpringOne 2GX 2014Theme ColorsR: 64G: 173B: 100R: 77G: 172B: 169R: 109G: 179B: 63R: 63G: 129B: 179R: 238G: 238B: 238R: 51G: 51B: 51R: 255G: 255B: 255R: 84G: 108B: 159R: 218G: 102B: 102R: 226G: 161B: 47R: 143G: 136B: 73R: 125G: 78B: 128 39. Notes for ReviewersTo provide comments, click the speech icon.If you're viewing this deck online, the icon is in the footerIf you're a collaborator, the icon is on the lower left hand sideTo view the proposed dialog for each slide, you need to be added asa collaborator, login to SlideShare, then View > Show Notes.To be added as a collaborator (which also allows slide editing),please setup a SlideRocket account with your VMware address andemail Ben.41 40. Logos and Clip Art42 41. Logos43 42. Event Logos and Icons44 43. Project Icons45SpringFrameworkSpringSecuritySpringDataSpringBatchSpringIntegrationSpringReactorSpringAMQPSpringHateoasSpringMobileSpringAndroidSpringSocialGroovy SpringWeb ServicesSpringWeb FlowSpringXDSpringBootSpringLDAPGrails 44. Tool Suite Icons46Spring Tool Suite Groovy / Grails Tool Suite 45. Document Icons47Spring Framework Support ToolsGuides Tutorials Reference App 46. Additional IconsEngineering Releases Apple Linux Windows48Twitter Github StackOverflowContinuousIntegrationIssues Metrics Forums /Blog @DiscussionAll Author Broadcast Date NewsEventProfessionalSupportCommunitySupportLocation 47. Clip Art49 48. Clip Art50