SlideShare a Scribd company logo
1 of 31
Download to read offline
1 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
クラウド時代のSpring Framework
Tsuyoshi Miyake, Pivotal Software, Inc.
@tsuyokb
2 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
アジェンダ
§ Spring Framework 振り返り
§ Spring 2015
§ Cloud Foundry
• 歴史
• Java/Spring との関連
§ Spring Cloud
• 概要
• 各種サブプロジェクトの詳細
3 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Framework 振り返り
4 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
“Don't call us, we'll call you
- Hollywood principle
5 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Framework とは、その昔何だったか?
§ Expert One-on-One J2EE Development without EJB – Chapter 7
“Introducing the Spring Framework” より
• Bean factory
• Application Context
• AOP framework
• Auto-proxing
• Transaction management
• DAO abstraction
• JDBC support
• Integration with O/R mapping tools
• Web MVC framework
• Remoting Support
6 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring 2015
7 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring IO Platform
8 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Cloud Foundry とは?
9 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring と Cloud Foundry のちょっとした歴史
“Cloud Foundry will be the natural
cloud deployment choice for Spring
developers.
Launching Cloud Foundry, The Industry’s First Open PaaS
Rod Johnson, Spring Engineering Blog, Apr 12 2011
10 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring/Java 開発者にとっての Cloud Foundry の 3 つの意味
As App Devs As Dev Ops CF Core
• UAA/Login Server
with Spring Security
• Java Buildpack
• Service Broker with
Spring Boot/MVC
• Spring + Grails native
support
• Gradle, Maven plugin
• Eclipse CF plugin
• Spring Cloud
(Today’s Topic)
11 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud
12 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud とは?
§ 分散環境で Cloud Native なアプリケーションを作成するためのフレームワーク
• SpringOne 2GX 2014 で発表
§ 元々は PaaS 上で利用できるサービスをアプリから使いやすくするためのもの
• 現在は Spring Cloud Connectors と呼ばれるもの
§ Spring Data 同様、複数プロジェクトを束ねるアンブレラ・プロジェクト
• Spring Cloud Config
• Spring Cloud Bus
• Spring Cloud Netflix
• Spring Cloud Connectors
13 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud Config (1/2)
§ 設定(Profile, Property)を外出しにして REST 経由でアクセスするしくみ
§ Config Server が設定を提供、Config Client が設定を利用
§ バックエンドは Git のレポジトリ(デフォルト)、バージョン管理ができる
Config ServerGit レポジトリ
アプリ A (Config Client)
1. Push Config 2. Source Config
param: xxx
アプリ B (Config Client) アプリ C (Config Client)
param: xxx param: xxx param: xxx
3. Pull Config
14 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud Config (2/2)
§ /{application}/{profile}[/{label}] => /foo/dev で foo-dev.properties にアクセス
§ @EnableConfigServer アノテーションで便利に ConfigServer になる
§ 暗号化のビルトイン・サポート
@Configuration
@EnableAutoConfiguration
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
15 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud Bus
§ 分散環境のノード間を Lightweight な Message Broker で結ぶ仕組み
§ 現在は AMQP のみのサポート
Config ServerGit レポジトリ
アプリ A (Config Client)
1. Update Config 2. Source Config
param: yyy
アプリ B (Config Client) アプリ C (Config Client)
param: yyy param: yyy param: yyy
4b. Pull Update
3. Post /bus/refresh
Config Bus
4a. メッセージ送信 5a. メッセージ受信
5b. Pull Update
16 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud Netflix
§ Netflix OSS を Spring Boot と組み合わせて便利(Annotation)に使う仕組み
• https://github.com/Netflix/
• http://netflix.github.io/
§ Service Discovery (Eureka)
§ Client Side Load Balancing (Ribbon)
§ Circuit Breaker (Hystrix)
§ Intelligent Routing (Zuul)
17 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Service Discovery (Eureka)
§ いわゆる Service Locator パターン
§ 自動で負荷分散 (round-robin)
§ @EnableDiscoveryClient で DiscoveryClient が Inject される
@SpringBootApplication
@EnableDiscoveryClient
public class Application {
@Autowired
DiscoveryClient discoveryClient;
public void consume() {
InstanceInfo instance =
discoveryClient.getNextServerFromEureka("hostname”, false);
}
}
Service
Registry
Producer
1. Register
Consumer
2. Discover
3. Connect
18 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Client Side Load Balancing (Ribbon)
§ 複数の負荷分散ルールに対応(round-robin、平均レスポンス時間、ランダム)
§ 単体で Fault tolerance 機能(サーバーリストを保持)
§ DiscoveryClient の代わりに LoadBalancerClient が Inject される
§ またはより便利に Ribbon-enabled な RestTemplate も Inject 可能
@Autowired
LoadBalancerClient lbClient;
public void consume() {
ServiceInstance instance = lbClient.choose("hostname”);
}
@Autowired
RestTemplate restTemplate;
public void consume() {
ProducerResponse response = restTemplate.getForObject(”http://producer”, ..);
}
19 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Circuit Breaker (Hystrix) (1/2)
§ “Release It!” Circuit breakers パターン
@EnableCircuitBreaker
public class Application {
@HystrixCommand(fallback = "doFallback")
public void doSomething() {}
public void doFallback() {}
}
Closed
call falis
(count failure)
call succeeds
(reset count)
Open
failure > threshold
(trip breaker)
timeout
(attempt reset)
Half-Open
call fails
(trip breaker)call succeeds
(reset)
20 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Circuit Breaker (Hystrix) (2/2)
21 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring Cloud Connectors
§ クラウド内のアプリケーション環境、およびサービスの抽象化
§ 多様なクラウドへの対応
• Cloud Foundry
• Heroku
• Local
§ 拡張性
• 新クラウド環境への対応
• 新サービスへの対応
• 新フレームワークへの対応
22 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
“Spring Cloud Connectors
= DI Container for Cloud OS
- 詠み人知らず
23 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring が昔、目指したもの
Application
Application Information
(Context)
Service
Service
Service
24 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Spring が今、目指しているもの
Application
Application Information
(Context)
Service
Service
Service
25 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Cloud Foundry: アプリケーションのデプロイ
① アプリケーショ
ンとメタデータ
の push
push app
Router
② サービスの作成とバインド
③ アプリケーションのステージング
④ アプリケーションのデプロイ
⑤ アプリケーションのヘルスチェック
Pivotal	CF	
Elastic	Runtime
Blobstore DB
Cloud
Controller
Service Broker
Node(s)
DEA
DEA
DEA
DEA
+ app MD
+ =
Service
credentials
26 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Cloud Foundry: サービスの作成とバインド
Router
Cloud	Foundry
Runtime	(ERS)
DB
Service
credentials
reserve resourcescreate service (HTTP) create service (HTTP)
bind service (HTTP)bind service (HTTP)
obtain connection
data
CLI Cloud
Controller
Service
Broker
Data
Service
27 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Service Scan (@ServiceScan)
§ Java Config (@Configuration) と併用
§ アプリケーションにバインドされたサービスをスキャン
§ 各サービスについて Bean を作成
§ (Option) クラウド環境でのみ有効にするためには @Profile(“cloud”) を追加
@Configuration
@ServiceScan
// @Profile("cloud”)
public class CloudConfig {
}
28 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Service Scan (@ServiceScan) カスタマイズ
§ パターン 1 : 同一タイプのサービス (e.g. DataSource) が 2 つ以上ある
§ パターン 2 : 各サービスの細かな設定が必要
§ パターン 3 : 独自サービスが必要
@Configuration
public class CloudConfig extends AbstractCloudConfig {
@Bean
public DataSource mysqlDataSource() {
return connectionFactory().dataSource("mysql-service");
}
@Bean
public DataSource postgresDataSource() {
PoolConfig poolConfig = new PoolConfig(20, 200);
ConnectionConfig connectionConfig = new
ConnectionConfig("characterEncoding=UTF-8");
DataSourceConfig serviceConfig = new DataSourceConfig(poolConfig,
connectionConfig);
return connectionFactory().dataSource("postgres-service”, serviceConfig);
}
}
29 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
新しいクラウド環境への拡張 (Cloud Platform) (1/2)
§ CloudConnector interface を実装
• isInMatchingCloud(): 意図した Cloud 環境かどうかを判定
• getApplicationInstanceInfo(): アプリケーションの情報(ID, ホスト名など)を返す
• getServiceInfos(): アプリケーションが利用可能なサービスの接続情報を返す
§ Cloud Platform の登録
• META-INF/services/org.springframework.cloud.CloudConnector に実装クラス
• java.util.ServiceLoader により load() される
public interface CloudConnector {
boolean isInMatchingCloud();
ApplicationInstanceInfo getApplicationInstanceInfo();
List<ServiceInfo> getServiceInfos();
}
30 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
新しいクラウド環境への拡張 (Cloud Platform) (2/2)
§ CloudFoundry での実装例 (CloudFoundryConnector)
public class CloudFoundryConnector extends
AbstractCloudConnector<Map<String,Object>> {
public boolean isInMatchingCloud() {
return environment.getEnvValue("VCAP_APPLICATION") != null;
}
public ApplicationInstanceInfo getApplicationInstanceInfo() {
Map<String, Object> rawApplicationInstanceInfo =
objectMapper.readValue(
environment.getEnvValue("VCAP_APPLICATION"), Map.class);
}
protected List<Map<String,Object>> getServicesData() {
String servicesString = environment.getEnvValue("VCAP_SERVICES");
}
}
31 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a
Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/
Learn More. Stay Connected.
§ Spring Cloud Project: http://projects.spring.io/spring-cloud/
§ Spring Cloud Source: https://github.com/spring-cloud
§ Spring Cloud Sample: https://github.com/spring-cloud-samples
§ Netflix OSS: http://netflix.github.io/
§ Spring Cloud Connectors Blogs
• https://spring.io/blog/2014/06/03/introducing-spring-cloud
• https://spring.io/blog/2014/07/29/using-spring-cloud-programmatically
• https://spring.io/blog/2014/08/05/extending-spring-cloud

More Related Content

What's hot

実例で学ぶ、明日から使えるSpring Boot Tips #jsug
実例で学ぶ、明日から使えるSpring Boot Tips #jsug実例で学ぶ、明日から使えるSpring Boot Tips #jsug
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
Toshiaki Maki
 

What's hot (20)

Introduction to Spring WebFlux #jsug #sf_a1
Introduction to Spring WebFlux #jsug #sf_a1Introduction to Spring WebFlux #jsug #sf_a1
Introduction to Spring WebFlux #jsug #sf_a1
 
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
実例で学ぶ、明日から使えるSpring Boot Tips #jsug実例で学ぶ、明日から使えるSpring Boot Tips #jsug
実例で学ぶ、明日から使えるSpring Boot Tips #jsug
 
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
Spring Framework 5.0による Reactive Web Application #JavaDayTokyoSpring Framework 5.0による Reactive Web Application #JavaDayTokyo
Spring Framework 5.0による Reactive Web Application #JavaDayTokyo
 
Introduction to Cloud Foundry #JJUG
Introduction to Cloud Foundry #JJUGIntroduction to Cloud Foundry #JJUG
Introduction to Cloud Foundry #JJUG
 
Spring Cloud Servicesの紹介 #pcf_tokyo
Spring Cloud Servicesの紹介 #pcf_tokyoSpring Cloud Servicesの紹介 #pcf_tokyo
Spring Cloud Servicesの紹介 #pcf_tokyo
 
Concourse x Spinnaker #concourse_tokyo
Concourse x Spinnaker #concourse_tokyoConcourse x Spinnaker #concourse_tokyo
Concourse x Spinnaker #concourse_tokyo
 
Spring Boot Actuator 2.0 & Micrometer
Spring Boot Actuator 2.0 & MicrometerSpring Boot Actuator 2.0 & Micrometer
Spring Boot Actuator 2.0 & Micrometer
 
Spring ❤️ Kotlin #jjug
Spring ❤️ Kotlin #jjugSpring ❤️ Kotlin #jjug
Spring ❤️ Kotlin #jjug
 
Serverless Spring 오충현
Serverless Spring 오충현Serverless Spring 오충현
Serverless Spring 오충현
 
From Zero to Hero with REST and OAuth2 #jjug
From Zero to Hero with REST and OAuth2 #jjugFrom Zero to Hero with REST and OAuth2 #jjug
From Zero to Hero with REST and OAuth2 #jjug
 
Building Distributed Systems with Netflix OSS and Spring Cloud
Building Distributed Systems with Netflix OSS and Spring CloudBuilding Distributed Systems with Netflix OSS and Spring Cloud
Building Distributed Systems with Netflix OSS and Spring Cloud
 
BOSH / CF Deployment in modern ways #cf_tokyo
BOSH / CF Deployment in modern ways #cf_tokyoBOSH / CF Deployment in modern ways #cf_tokyo
BOSH / CF Deployment in modern ways #cf_tokyo
 
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
Java Microservices with Spring Boot and Spring Cloud - Denver JUG 2019
 
Cloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven MicroservicesCloud-Native Streaming and Event-Driven Microservices
Cloud-Native Streaming and Event-Driven Microservices
 
Spring Up Your Graph
Spring Up Your GraphSpring Up Your Graph
Spring Up Your Graph
 
2017年のLINEのマイクロサービスを支えるSpring
2017年のLINEのマイクロサービスを支えるSpring2017年のLINEのマイクロサービスを支えるSpring
2017年のLINEのマイクロサービスを支えるSpring
 
Agile Development with OSGi
Agile Development with OSGiAgile Development with OSGi
Agile Development with OSGi
 
JVMs in Containers
JVMs in ContainersJVMs in Containers
JVMs in Containers
 
Getting Groovy with JHipster and Micronaut
Getting Groovy with JHipster and MicronautGetting Groovy with JHipster and Micronaut
Getting Groovy with JHipster and Micronaut
 
Cloud Foundry for Spring Developers
Cloud Foundry for Spring DevelopersCloud Foundry for Spring Developers
Cloud Foundry for Spring Developers
 

Viewers also liked

Spring Data in a Nutshell
Spring Data in a NutshellSpring Data in a Nutshell
Spring Data in a Nutshell
Tsuyoshi Miyake
 

Viewers also liked (16)

MySQLの文字コード事情 2017春版
MySQLの文字コード事情 2017春版MySQLの文字コード事情 2017春版
MySQLの文字コード事情 2017春版
 
はじめてのSpring Boot
はじめてのSpring BootはじめてのSpring Boot
はじめてのSpring Boot
 
Spring Data in a Nutshell
Spring Data in a NutshellSpring Data in a Nutshell
Spring Data in a Nutshell
 
Cloudera + MicrosoftでHadoopするのがイイらしい。 #CWT2016
Cloudera + MicrosoftでHadoopするのがイイらしい。 #CWT2016Cloudera + MicrosoftでHadoopするのがイイらしい。 #CWT2016
Cloudera + MicrosoftでHadoopするのがイイらしい。 #CWT2016
 
Cloudera Data Science WorkbenchとPySparkで 好きなPythonライブラリを 分散で使う #cadeda
Cloudera Data Science WorkbenchとPySparkで 好きなPythonライブラリを 分散で使う #cadedaCloudera Data Science WorkbenchとPySparkで 好きなPythonライブラリを 分散で使う #cadeda
Cloudera Data Science WorkbenchとPySparkで 好きなPythonライブラリを 分散で使う #cadeda
 
Spring Cloud in a Nutshell
Spring Cloud in a NutshellSpring Cloud in a Nutshell
Spring Cloud in a Nutshell
 
Cloudera in the Cloud #CWT2017
Cloudera in the Cloud #CWT2017Cloudera in the Cloud #CWT2017
Cloudera in the Cloud #CWT2017
 
#cwt2016 Apache Kudu 構成とテーブル設計
#cwt2016 Apache Kudu 構成とテーブル設計#cwt2016 Apache Kudu 構成とテーブル設計
#cwt2016 Apache Kudu 構成とテーブル設計
 
Cloud Native Hadoop #cwt2016
Cloud Native Hadoop #cwt2016Cloud Native Hadoop #cwt2016
Cloud Native Hadoop #cwt2016
 
Hue 4.0 / Hue Meetup Tokyo #huejp
Hue 4.0 / Hue Meetup Tokyo #huejpHue 4.0 / Hue Meetup Tokyo #huejp
Hue 4.0 / Hue Meetup Tokyo #huejp
 
先行事例から学ぶ IoT / ビッグデータの始め方
先行事例から学ぶ IoT / ビッグデータの始め方先行事例から学ぶ IoT / ビッグデータの始め方
先行事例から学ぶ IoT / ビッグデータの始め方
 
Clouderaが提供するエンタープライズ向け運用、データ管理ツールの使い方 #CW2017
Clouderaが提供するエンタープライズ向け運用、データ管理ツールの使い方 #CW2017Clouderaが提供するエンタープライズ向け運用、データ管理ツールの使い方 #CW2017
Clouderaが提供するエンタープライズ向け運用、データ管理ツールの使い方 #CW2017
 
How to go into production your machine learning models? #CWT2017
How to go into production your machine learning models? #CWT2017How to go into production your machine learning models? #CWT2017
How to go into production your machine learning models? #CWT2017
 
Apache Kuduは何がそんなに「速い」DBなのか? #dbts2017
Apache Kuduは何がそんなに「速い」DBなのか? #dbts2017Apache Kuduは何がそんなに「速い」DBなのか? #dbts2017
Apache Kuduは何がそんなに「速い」DBなのか? #dbts2017
 
Apache Kudu - Updatable Analytical Storage #rakutentech
Apache Kudu - Updatable Analytical Storage #rakutentechApache Kudu - Updatable Analytical Storage #rakutentech
Apache Kudu - Updatable Analytical Storage #rakutentech
 
大規模データに対するデータサイエンスの進め方 #CWT2016
大規模データに対するデータサイエンスの進め方 #CWT2016大規模データに対するデータサイエンスの進め方 #CWT2016
大規模データに対するデータサイエンスの進め方 #CWT2016
 

Similar to クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)

Similar to クラウド時代の Spring Framework (aka Spring Framework in Cloud Era) (20)

12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps – What EXACTLY Does that Mean for Spring Deve...
 
Spring Integration Done Bootifully
Spring Integration Done BootifullySpring Integration Done Bootifully
Spring Integration Done Bootifully
 
Spring Cloud on Kubernetes
Spring Cloud on KubernetesSpring Cloud on Kubernetes
Spring Cloud on Kubernetes
 
riffing on Knative - Scott Andrews
riffing on Knative - Scott Andrewsriffing on Knative - Scott Andrews
riffing on Knative - Scott Andrews
 
Caching for Microservives - Introduction to Pivotal Cloud Cache
Caching for Microservives - Introduction to Pivotal Cloud CacheCaching for Microservives - Introduction to Pivotal Cloud Cache
Caching for Microservives - Introduction to Pivotal Cloud Cache
 
SDLC for Pivotal Platform powered by Spring Initializr and Concourse
SDLC for Pivotal Platform powered by Spring Initializr and ConcourseSDLC for Pivotal Platform powered by Spring Initializr and Concourse
SDLC for Pivotal Platform powered by Spring Initializr and Concourse
 
Cloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud ServicesCloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud Services
 
Cloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud ServicesCloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud Services
 
Developing Real-Time Data Pipelines with Apache Kafka
Developing Real-Time Data Pipelines with Apache KafkaDeveloping Real-Time Data Pipelines with Apache Kafka
Developing Real-Time Data Pipelines with Apache Kafka
 
Cloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud ServicesCloud Native Java with Spring Cloud Services
Cloud Native Java with Spring Cloud Services
 
Quickly Build Spring Boot Applications to Consume Public Cloud Services
Quickly Build Spring Boot Applications to Consume Public Cloud ServicesQuickly Build Spring Boot Applications to Consume Public Cloud Services
Quickly Build Spring Boot Applications to Consume Public Cloud Services
 
Heavyweights: Tipping the Scales with Very Large Foundations
Heavyweights: Tipping the Scales with Very Large FoundationsHeavyweights: Tipping the Scales with Very Large Foundations
Heavyweights: Tipping the Scales with Very Large Foundations
 
[2015-11월 정기 세미나] Cloud Native Platform - Pivotal
[2015-11월 정기 세미나] Cloud Native Platform - Pivotal[2015-11월 정기 세미나] Cloud Native Platform - Pivotal
[2015-11월 정기 세미나] Cloud Native Platform - Pivotal
 
Simplifying Apache Geode with Spring Data
Simplifying Apache Geode with Spring DataSimplifying Apache Geode with Spring Data
Simplifying Apache Geode with Spring Data
 
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
12 Factor, or Cloud Native Apps - What EXACTLY Does that Mean for Spring Deve...
 
Steeltoe: Develop .NET Microservices Without Cloud Platform Lock-In
Steeltoe: Develop .NET Microservices Without Cloud Platform Lock-InSteeltoe: Develop .NET Microservices Without Cloud Platform Lock-In
Steeltoe: Develop .NET Microservices Without Cloud Platform Lock-In
 
Connecting All Abstractions with Istio
Connecting All Abstractions with IstioConnecting All Abstractions with Istio
Connecting All Abstractions with Istio
 
Lattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring ApplicationsLattice: A Cloud-Native Platform for Your Spring Applications
Lattice: A Cloud-Native Platform for Your Spring Applications
 
S1P: Spring Cloud on PKS
S1P: Spring Cloud on PKSS1P: Spring Cloud on PKS
S1P: Spring Cloud on PKS
 
P to V to C: The Value of Bringing “Everything” to Containers
P to V to C: The Value of Bringing “Everything” to ContainersP to V to C: The Value of Bringing “Everything” to Containers
P to V to C: The Value of Bringing “Everything” to Containers
 

More from Tsuyoshi Miyake

Artifact Driven CI/CD
Artifact Driven CI/CDArtifact Driven CI/CD
Artifact Driven CI/CD
Tsuyoshi Miyake
 

More from Tsuyoshi Miyake (19)

猿でもわかる DevOps
猿でもわかる DevOps猿でもわかる DevOps
猿でもわかる DevOps
 
はじめての JFrog Platform V2
はじめての JFrog Platform V2はじめての JFrog Platform V2
はじめての JFrog Platform V2
 
はじめての JFrog Distribution
はじめての JFrog Distributionはじめての JFrog Distribution
はじめての JFrog Distribution
 
はじめての JFrog Pipelines
はじめての JFrog Pipelinesはじめての JFrog Pipelines
はじめての JFrog Pipelines
 
はじめての JFrog Xray
はじめての JFrog Xrayはじめての JFrog Xray
はじめての JFrog Xray
 
はじめての JFrog Artifactory
はじめての JFrog Artifactoryはじめての JFrog Artifactory
はじめての JFrog Artifactory
 
はじめての JFrog Platform
はじめての JFrog Platformはじめての JFrog Platform
はじめての JFrog Platform
 
猿でもわかる Helm
猿でもわかる Helm猿でもわかる Helm
猿でもわかる Helm
 
Artifact Driven CI/CD
Artifact Driven CI/CDArtifact Driven CI/CD
Artifact Driven CI/CD
 
猿でもわかるサーバーレス
猿でもわかるサーバーレス猿でもわかるサーバーレス
猿でもわかるサーバーレス
 
Java 開発者のための次世代 DevOps: BinOps
Java 開発者のための次世代 DevOps: BinOpsJava 開発者のための次世代 DevOps: BinOps
Java 開発者のための次世代 DevOps: BinOps
 
カエルと実践するコンテナ
カエルと実践するコンテナカエルと実践するコンテナ
カエルと実践するコンテナ
 
猿でもわかるコンテナ・オーケストレーション
猿でもわかるコンテナ・オーケストレーション猿でもわかるコンテナ・オーケストレーション
猿でもわかるコンテナ・オーケストレーション
 
猿でもわかるコンテナ
猿でもわかるコンテナ猿でもわかるコンテナ
猿でもわかるコンテナ
 
カエルと実践する CI/CD CD 編
カエルと実践する CI/CD CD 編カエルと実践する CI/CD CD 編
カエルと実践する CI/CD CD 編
 
カエルと実践する CI/CD CI 編
カエルと実践する CI/CD CI 編カエルと実践する CI/CD CI 編
カエルと実践する CI/CD CI 編
 
猿でもわかる CI/CD
猿でもわかる CI/CD猿でもわかる CI/CD
猿でもわかる CI/CD
 
カエルと実践するバイナリ・リポジトリマネージャー
カエルと実践するバイナリ・リポジトリマネージャーカエルと実践するバイナリ・リポジトリマネージャー
カエルと実践するバイナリ・リポジトリマネージャー
 
猿でもわかるバイナリ・リポジトリマネージャー
猿でもわかるバイナリ・リポジトリマネージャー猿でもわかるバイナリ・リポジトリマネージャー
猿でもわかるバイナリ・リポジトリマネージャー
 

Recently uploaded

Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 

Recently uploaded (20)

How to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cfHow to Check CNIC Information Online with Pakdata cf
How to Check CNIC Information Online with Pakdata cf
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
الأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهلهالأمن السيبراني - ما لا يسع للمستخدم جهله
الأمن السيبراني - ما لا يسع للمستخدم جهله
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 
ADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptxADP Passwordless Journey Case Study.pptx
ADP Passwordless Journey Case Study.pptx
 
Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 

クラウド時代の Spring Framework (aka Spring Framework in Cloud Era)

  • 1. 1 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ クラウド時代のSpring Framework Tsuyoshi Miyake, Pivotal Software, Inc. @tsuyokb
  • 2. 2 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ アジェンダ § Spring Framework 振り返り § Spring 2015 § Cloud Foundry • 歴史 • Java/Spring との関連 § Spring Cloud • 概要 • 各種サブプロジェクトの詳細
  • 3. 3 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Framework 振り返り
  • 4. 4 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ “Don't call us, we'll call you - Hollywood principle
  • 5. 5 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Framework とは、その昔何だったか? § Expert One-on-One J2EE Development without EJB – Chapter 7 “Introducing the Spring Framework” より • Bean factory • Application Context • AOP framework • Auto-proxing • Transaction management • DAO abstraction • JDBC support • Integration with O/R mapping tools • Web MVC framework • Remoting Support
  • 6. 6 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring 2015
  • 7. 7 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring IO Platform
  • 8. 8 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Cloud Foundry とは?
  • 9. 9 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring と Cloud Foundry のちょっとした歴史 “Cloud Foundry will be the natural cloud deployment choice for Spring developers. Launching Cloud Foundry, The Industry’s First Open PaaS Rod Johnson, Spring Engineering Blog, Apr 12 2011
  • 10. 10 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring/Java 開発者にとっての Cloud Foundry の 3 つの意味 As App Devs As Dev Ops CF Core • UAA/Login Server with Spring Security • Java Buildpack • Service Broker with Spring Boot/MVC • Spring + Grails native support • Gradle, Maven plugin • Eclipse CF plugin • Spring Cloud (Today’s Topic)
  • 11. 11 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud
  • 12. 12 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud とは? § 分散環境で Cloud Native なアプリケーションを作成するためのフレームワーク • SpringOne 2GX 2014 で発表 § 元々は PaaS 上で利用できるサービスをアプリから使いやすくするためのもの • 現在は Spring Cloud Connectors と呼ばれるもの § Spring Data 同様、複数プロジェクトを束ねるアンブレラ・プロジェクト • Spring Cloud Config • Spring Cloud Bus • Spring Cloud Netflix • Spring Cloud Connectors
  • 13. 13 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud Config (1/2) § 設定(Profile, Property)を外出しにして REST 経由でアクセスするしくみ § Config Server が設定を提供、Config Client が設定を利用 § バックエンドは Git のレポジトリ(デフォルト)、バージョン管理ができる Config ServerGit レポジトリ アプリ A (Config Client) 1. Push Config 2. Source Config param: xxx アプリ B (Config Client) アプリ C (Config Client) param: xxx param: xxx param: xxx 3. Pull Config
  • 14. 14 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud Config (2/2) § /{application}/{profile}[/{label}] => /foo/dev で foo-dev.properties にアクセス § @EnableConfigServer アノテーションで便利に ConfigServer になる § 暗号化のビルトイン・サポート @Configuration @EnableAutoConfiguration @EnableConfigServer public class ConfigServerApplication { public static void main(String[] args) { SpringApplication.run(ConfigServerApplication.class, args); } }
  • 15. 15 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud Bus § 分散環境のノード間を Lightweight な Message Broker で結ぶ仕組み § 現在は AMQP のみのサポート Config ServerGit レポジトリ アプリ A (Config Client) 1. Update Config 2. Source Config param: yyy アプリ B (Config Client) アプリ C (Config Client) param: yyy param: yyy param: yyy 4b. Pull Update 3. Post /bus/refresh Config Bus 4a. メッセージ送信 5a. メッセージ受信 5b. Pull Update
  • 16. 16 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud Netflix § Netflix OSS を Spring Boot と組み合わせて便利(Annotation)に使う仕組み • https://github.com/Netflix/ • http://netflix.github.io/ § Service Discovery (Eureka) § Client Side Load Balancing (Ribbon) § Circuit Breaker (Hystrix) § Intelligent Routing (Zuul)
  • 17. 17 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Service Discovery (Eureka) § いわゆる Service Locator パターン § 自動で負荷分散 (round-robin) § @EnableDiscoveryClient で DiscoveryClient が Inject される @SpringBootApplication @EnableDiscoveryClient public class Application { @Autowired DiscoveryClient discoveryClient; public void consume() { InstanceInfo instance = discoveryClient.getNextServerFromEureka("hostname”, false); } } Service Registry Producer 1. Register Consumer 2. Discover 3. Connect
  • 18. 18 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Client Side Load Balancing (Ribbon) § 複数の負荷分散ルールに対応(round-robin、平均レスポンス時間、ランダム) § 単体で Fault tolerance 機能(サーバーリストを保持) § DiscoveryClient の代わりに LoadBalancerClient が Inject される § またはより便利に Ribbon-enabled な RestTemplate も Inject 可能 @Autowired LoadBalancerClient lbClient; public void consume() { ServiceInstance instance = lbClient.choose("hostname”); } @Autowired RestTemplate restTemplate; public void consume() { ProducerResponse response = restTemplate.getForObject(”http://producer”, ..); }
  • 19. 19 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Circuit Breaker (Hystrix) (1/2) § “Release It!” Circuit breakers パターン @EnableCircuitBreaker public class Application { @HystrixCommand(fallback = "doFallback") public void doSomething() {} public void doFallback() {} } Closed call falis (count failure) call succeeds (reset count) Open failure > threshold (trip breaker) timeout (attempt reset) Half-Open call fails (trip breaker)call succeeds (reset)
  • 20. 20 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Circuit Breaker (Hystrix) (2/2)
  • 21. 21 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Cloud Connectors § クラウド内のアプリケーション環境、およびサービスの抽象化 § 多様なクラウドへの対応 • Cloud Foundry • Heroku • Local § 拡張性 • 新クラウド環境への対応 • 新サービスへの対応 • 新フレームワークへの対応
  • 22. 22 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ “Spring Cloud Connectors = DI Container for Cloud OS - 詠み人知らず
  • 23. 23 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring が昔、目指したもの Application Application Information (Context) Service Service Service
  • 24. 24 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring が今、目指しているもの Application Application Information (Context) Service Service Service
  • 25. 25 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Cloud Foundry: アプリケーションのデプロイ ① アプリケーショ ンとメタデータ の push push app Router ② サービスの作成とバインド ③ アプリケーションのステージング ④ アプリケーションのデプロイ ⑤ アプリケーションのヘルスチェック Pivotal CF Elastic Runtime Blobstore DB Cloud Controller Service Broker Node(s) DEA DEA DEA DEA + app MD + = Service credentials
  • 26. 26 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Cloud Foundry: サービスの作成とバインド Router Cloud Foundry Runtime (ERS) DB Service credentials reserve resourcescreate service (HTTP) create service (HTTP) bind service (HTTP)bind service (HTTP) obtain connection data CLI Cloud Controller Service Broker Data Service
  • 27. 27 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Service Scan (@ServiceScan) § Java Config (@Configuration) と併用 § アプリケーションにバインドされたサービスをスキャン § 各サービスについて Bean を作成 § (Option) クラウド環境でのみ有効にするためには @Profile(“cloud”) を追加 @Configuration @ServiceScan // @Profile("cloud”) public class CloudConfig { }
  • 28. 28 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Service Scan (@ServiceScan) カスタマイズ § パターン 1 : 同一タイプのサービス (e.g. DataSource) が 2 つ以上ある § パターン 2 : 各サービスの細かな設定が必要 § パターン 3 : 独自サービスが必要 @Configuration public class CloudConfig extends AbstractCloudConfig { @Bean public DataSource mysqlDataSource() { return connectionFactory().dataSource("mysql-service"); } @Bean public DataSource postgresDataSource() { PoolConfig poolConfig = new PoolConfig(20, 200); ConnectionConfig connectionConfig = new ConnectionConfig("characterEncoding=UTF-8"); DataSourceConfig serviceConfig = new DataSourceConfig(poolConfig, connectionConfig); return connectionFactory().dataSource("postgres-service”, serviceConfig); } }
  • 29. 29 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 新しいクラウド環境への拡張 (Cloud Platform) (1/2) § CloudConnector interface を実装 • isInMatchingCloud(): 意図した Cloud 環境かどうかを判定 • getApplicationInstanceInfo(): アプリケーションの情報(ID, ホスト名など)を返す • getServiceInfos(): アプリケーションが利用可能なサービスの接続情報を返す § Cloud Platform の登録 • META-INF/services/org.springframework.cloud.CloudConnector に実装クラス • java.util.ServiceLoader により load() される public interface CloudConnector { boolean isInMatchingCloud(); ApplicationInstanceInfo getApplicationInstanceInfo(); List<ServiceInfo> getServiceInfos(); }
  • 30. 30 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 新しいクラウド環境への拡張 (Cloud Platform) (2/2) § CloudFoundry での実装例 (CloudFoundryConnector) public class CloudFoundryConnector extends AbstractCloudConnector<Map<String,Object>> { public boolean isInMatchingCloud() { return environment.getEnvValue("VCAP_APPLICATION") != null; } public ApplicationInstanceInfo getApplicationInstanceInfo() { Map<String, Object> rawApplicationInstanceInfo = objectMapper.readValue( environment.getEnvValue("VCAP_APPLICATION"), Map.class); } protected List<Map<String,Object>> getServicesData() { String servicesString = environment.getEnvValue("VCAP_SERVICES"); } }
  • 31. 31 Unless otherwise indicated, these slides are © 2015 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Learn More. Stay Connected. § Spring Cloud Project: http://projects.spring.io/spring-cloud/ § Spring Cloud Source: https://github.com/spring-cloud § Spring Cloud Sample: https://github.com/spring-cloud-samples § Netflix OSS: http://netflix.github.io/ § Spring Cloud Connectors Blogs • https://spring.io/blog/2014/06/03/introducing-spring-cloud • https://spring.io/blog/2014/07/29/using-spring-cloud-programmatically • https://spring.io/blog/2014/08/05/extending-spring-cloud