Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×

Running your Spring Apps in the Cloud Javaone 2014

Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Cargando en…3
×

Eche un vistazo a continuación

1 de 34 Anuncio
Anuncio

Más Contenido Relacionado

Presentaciones para usted (20)

A los espectadores también les gustó (20)

Anuncio

Similares a Running your Spring Apps in the Cloud Javaone 2014 (20)

Anuncio

Más reciente (20)

Running your Spring Apps in the Cloud Javaone 2014

  1. 1. Running Your Spring Apps in the Cloud At JavaOne Cornelia Davis Director, Platform Engineering, Cloud Foundry, Pivotal cdavis@pivotal.io | @cdavisafc | October 2014 © Copyright 2013 Pivotal. All rights reserved. 1
  2. 2. Let’s push an app © Copyright 2013 Pivotal. All rights reserved. 2
  3. 3. Overview: Deploying App to Cloud Foundry Runtime ① Upload app bits and metadata push app Router + app MD ② Create and bind services ③ Stage application ④ Deploy application ⑤ Manage application health …which is a whole ‘nother topic Service credentials Service Broker Node(s) Cloud Foundry Runtime (PaaS) Blobstore DB Cloud Controller DEA DEA DEA DEA + = © Copyright 2013 Pivotal. All rights reserved. 3
  4. 4. Software © Copyright 2013 Pivotal. All rights reserved. 4
  5. 5. Software is Changing Industries $3.5B valuation –Financial Services $3.5B valuation – Travel & Hospitality $17B valuation – Transportation $1.1B acquisition by Monsanto – Agriculture $19B valuation – Entertainment $3.2B acquisition by Google– Digital Home © Copyright 2013 Pivotal. All rights reserved. 5
  6. 6. Spring Trader Reference Application from VMWare to demonstrate the vFabric Suite https://github.com/cf-platform-eng/springtrader-cf © Copyright 2013 Pivotal. All rights reserved. 6
  7. 7. From here … © Copyright 2013 Pivotal. All rights reserved. 7
  8. 8. Agenda (1/2)  Auto reconfiguration  Services plans  Apps and Manifests  Cross-site scripting  JNDI  Service Catalog  Spring Cloud Connector © Copyright 2013 Pivotal. All rights reserved. 8
  9. 9. Agenda (2/2)  Apps as Services  Define Service Type  XSS © Copyright 2013 Pivotal. All rights reserved. 9
  10. 10. Cross-site Scripting hhtttptp:/://s/tpraridnegrtwraedbe.rc.cfaopmp/sw.ieob http://springtrader.com/services http://traderservices.cfapps.io © Copyright 2013 Pivotal. All rights reserved. 10
  11. 11. Cross-site Scripting http://traderfront.cfapps.io One war file © Copyright 2013 Pivotal. All rights reserved. 11
  12. 12. JNDI  Service Instances Old: <jee:jndi-lookup id="dataSource" jndi-name="jdbc/nanodb" /> © Copyright 2013 Pivotal. All rights reserved. 12
  13. 13. Spring Cloud VCAP_SERVICES={"cleardb-n/ a":[{"name":"tradersql","label":"cleardb-n/ a","tags":["mysql","relational"],"plan":"spark","credentials":{"jdbcUrl":"jd bc:mysql://baf8a1e6a292a2:79581497@us-cdbr-east- 05.cleardb.net:3306/ad_595d583f143adee","uri":"mysql://baf8a1e6a292a2:79581497 @us-cdbr-east- 05.cleardb.net:3306/ad_595d583f143adee?reconnect=true","name":"ad_595d583f143a dee","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://kl rdpgoo:mLpx_XtpEY7eJg-rG489FRs_J-jArqP6@tiger.cloudamqp.com/klrdpgoo"}}]} New: <cloud:data-source id="dataSource" service-name="tradersql"> characterEncoding=UTF-8;defaultTransactionIsolation=2”/> VCAP_SERVICES locally cf bind-service traderfront tradersql <cloud:connection properties="sessionVariables=sql_mode='ANSI'; <cloud:pool pool-size="2" max-wait-time="200" /> </cloud:data-source> OR <cloud:data-source id="dataSource"> ... © Copyright 2013 Pivotal. All rights reserved. 13
  14. 14. (Big-A) Applications and Manifests http://traderfront.cfapps.io One war file Another war file © Copyright 2013 Pivotal. All rights reserved. 14
  15. 15. (Big-A) Applications and Manifests --- timeout: 180 memory: 1G domain: cfapps.io instances: 1 services: - tradersql - tradermessaging applications: - name: traderback Global properties apply to all applications path: dist/spring-nanotrader-asynch-services-1.0.1.BUILD-SNAPSHOT.war host: traderback - name: traderfront path: dist/spring-nanotrader-services-1.0.1.BUILD-SNAPSHOT.war host: traderfront © Copyright 2013 Pivotal. All rights reserved. 15
  16. 16. Services Marketplace and Plans <cloud:data-source id="dataSource"> <cloud:connection properties="sessionVariables=sql_mode='ANSI'; characterEncoding=UTF-8;defaultTransactionIsolation=2”/> <cloud:pool pool-size="2" max-wait-time="200" /> </cloud:data-source> © Copyright 2013 Pivotal. All rights reserved. 16
  17. 17. Auto-reconfiguration <rabbit:connection-factory id="connectionFactory" host="${NANO_RABBIT_HOST:localhost}" port="${NANO_RABBIT_PORT:5672}"/> Old: New: <cloud:rabbit-connection-factory id="connectionFactory"/> USE AUTORECONFIGURATION WITH CARE!! (esp. in production) © Copyright 2013 Pivotal. All rights reserved. 17
  18. 18. Deal with Cross-site Scripting <script> … accessing doc.something </script> … doc = XMLHTTPRequest http://example.com/foo … When one domain is responsible for both the HTML (with embedded scripts) and the content of the XMLHTTPRequest, all is fine. © Copyright 2013 Pivotal. All rights reserved. 18
  19. 19. Deal with Cross-site Scripting EVIL <script> … accessing doc.something </script> … doc = XMLHTTPRequest http://example.com/foo … When different domains: • Request will be sent • Browser will not make response available To accommodate: • Service lists domains from which requests will be allowed © Copyright 2013 Pivotal. All rights reserved. 19
  20. 20. Spring Cloud Connector Extension: HTTP Web Service public 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); } … } SpringCloud built in: • Amqp • Mongo • Monitoring • Mysql • Oracle • Postgresql • Redis • Smtp © Copyright 2013 Pivotal. All rights reserved. 20
  21. 21. Spring Cloud Connector Extension: HTTP Web Service public class BasicHttpWebServiceInfoCreator extends CloudFoundryServiceInfoCreator<BasicHttpWebServiceInfo>{ public BasicHttpWebServiceInfoCreator() { super(new Tags(), "http"); } public BasicHttpWebServiceInfo createServiceInfo(Map<String,Object> serviceData) { @SuppressWarnings("unchecked") Map<String,Object> credentials = (Map<String, Object>) serviceData.get("credentials"); String id = (String) serviceData.get("name"); String uri = getStringFromCredentials(credentials, "uri", "url"); return new BasicHttpWebServiceInfo(id, uri); } } Here’s the tricky part: Put a file called org.springframework.cloud.cloudfoundry.CloudFoundryServiceInfoCreator on your classpath containing com.gopivotal.cloudfoundry.example.springcloud.BasicHttpWebServiceInfoCreator https://github.com/spring-cloud/spring-cloud-connectors/tree/master/spring-cloud-core © Copyright 2013 Pivotal. All rights reserved. 21
  22. 22. Cross-site Scripting © Copyright 2013 Pivotal. All rights reserved. 22
  23. 23. Apps as Services cf create-service … tradersql cf create-service … tradermessaging Message Broker Data Tier © Copyright 2013 Pivotal. All rights reserved. 23
  24. 24. Apps as Services cf push traderback cf bind-service traderback stsql cf bind-service traderback stmessaging Message Broker Trader Back Data Tier © Copyright 2013 Pivotal. All rights reserved. 24
  25. 25. Apps as Services cf push traderfront cf bind-service traderfront stsql cf bind-service traderfront stmessaging Trader Front Message Broker Trader Back Data Tier © Copyright 2013 Pivotal. All rights reserved. 25
  26. 26. Apps as Services Trader Front cf cups traderfront -p '{"uri": "http://traderfront.cfapps.io/api/"}' Message Broker Trader Back Data Tier app is a service © Copyright 2013 Pivotal. All rights reserved. 26
  27. 27. Apps as Services Trader Web cf push traderweb cf bind-service traderweb traderfront Trader Front Message Broker Trader Back Data Tier app is a service © Copyright 2013 Pivotal. All rights reserved. 27
  28. 28. And that is the current state of the repo © Copyright 2013 Pivotal. All rights reserved. 28
  29. 29. Login Session Replication Originally designed to use Gemfire peer to peer Trader Front Trader Front Trader Front © Copyright 2013 Pivotal. All rights reserved. 29
  30. 30. Login Session Replication DEA Firewalled application containers restrict this! Trader Front Trader Front Trader Front © Copyright 2013 Pivotal. All rights reserved. 30
  31. 31. Login Session Replication Redis for session state caching – Java buildpack v2.1 BUT, we aren’t using HTTP sessions for auth tokens! (but the idea is right) Pull Requests Welcome!! Trader Front Trader Front Trader Front https://github.com/cloudfoundry/java-buildpack/blob/master/docs/container-tomcat.md#session-replication © Copyright 2013 Pivotal. All rights reserved. 31
  32. 32. … to here © Copyright 2013 Pivotal. All rights reserved. 32
  33. 33. © Copyright 2013 Pivotal. All rights reserved. 33
  34. 34. A NEW PLATFORM FOR A NEW ERA

Notas del editor

  • Cloud Foundry PaaS

    An application runs in a DEA, which is a droplet execution agent. The Cloud Controller orchestrates the routing and lifecycle of all DEAs in the pool. Routers manage application traffic. Health Manager reports mismatched application states to the CC. A service broker provides an interface for services (native or external). A messaging bus manages all system communication. Apps are accessed directly through the router while web and CLI clients (e.g., vmc, STS) access Cloud Controller via RESTful services.
  • Software is eating the world - executives cite software as the top factor impacting their organizations. Companies effectively using software development to achieve competitive advantage are more profitable than their peers
  • Organizations such as Square ($3.5B valuation, Financial Services), Uber ($3.5B valuation, Transportation), Netflix ($19B valuation, Media and Entertainment), Airbnb ($3.5B valuation, Hospitality), the Climate Corporation ($1.1B acquisition, Agriculture) and Etsy ($600M valuation, Boutique Retail) are using software to change industries and disrupt business models
  • Push the app
  • Push the app
  • Push the app

×