Apache Geode で始める Spring Data Gemfire

6
-1

Published on

2016/3/9 の JSUG 勉強会プレゼン資料です。

デモアプリケーションプロジェクト一式は以下においてあります。
https://github.com/AkihiroKitada/MySpringDataGemfireSamples

Published in: Engineering
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
6
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Apache Geode で始める Spring Data Gemfire

  1. 1. Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Apache Geode で始める Spring Data Gemfire Pivotal ジャパン株式会社 テクニカルサポートエンジニア 北田 顕啓 @quitada
  2. 2. 2 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ アジェンダ  Apache Geode とは?  Spring Data Gemfire とは?  Apache Geode で Spring Data Gemfire を使う  最後に…
  3. 3. 3 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Apache Geode とは?
  4. 4. 4 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Apache Geode とは?  Pivotal 社のインメモリデータグリッド製品、Pivotal GemFire のオープンソース版 • 2016 年 3 月現在、Apache Geode と Pivotal GemFire の差は C#/C++ クライアン トモジュール(Native Client、後述)の有無のみ  インメモリデータグリッド製品 Pivotal GemFire とは?* • スケールアウトする豪華な HashMap に対して… • SQL ライクなオブジェクトクエリーとか、コンティニュアスクエリー(後述)とかできます • データをディスクに永続化とかできます→NoSQL サーバーとしての側面 • MapReduce 的な処理ができます(ファンクション) • 柔軟な構成がとれます〜peer-to-peer、Client-Server(後述)、WAN Gateway • 同期&非同期イベント処理(後述)ができます • 様々なアクセス手段を提供します(独自 API、Memcached、REST API) *= 個人の感想です
  5. 5. 5 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Pivotal GemFire の構成例〜Client-Server 構成  GemFire のキャッシュを専用サーバーとして 起動、データやイベント処理をクライアントより 行う→Geode も同様の構成が可能  用語 • メンバー:データ格納プロセス • キャッシュ:データ格納先 • 分散システム:クラスターのこと • リージョン:データ格納テーブル • キャッシュサーバー:データサーバー • プール:サーバーへの接続プール 分散システム キャッシュ リージョン リージョン キャッシュサーバー キャッシュ リージョン リージョン キャッシュサーバー キャッシュ リージョン リージョン キャッシュサーバー メンバー群 Java クライアント C# クライアント C++ クライアント プール プール プール REST クライアント Memcached クライアント Native Client (Geode にはない)
  6. 6. 6 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Apache Geode の特徴的な機能〜イベント処理  Geode の各種処理に伴いイベントが発生 • RegionEvent、EntryEvent、TransactionEvent、CqEvent、GatewayEvent…  サブスクリプションによるイベントメッセージ受信設定 • インタレストの登録による受信イベントフィルタリング • クライアントは受信イベント種別を細かく設定可能  低レイテンシ(ミリ秒以下)  受信イベントに応じた処理駆動〜 **Listener  高可用性・耐障害性 Geode 1 Geode n … インタレスト登録
  7. 7. 7 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Apache Geode の特徴的な機能〜コンティニュアスクエリー(CQ)  サーバーサイドイベントをオブジェクト クエリーで直接フィルタリングを行い、 クライアントで選択的に受信  クエリーはサーバーサイドに配備され、 データ更新の度に評価され、条件を満たす イベントのみクライアントに送信  クライアントでイベント受信時に CQListener が駆動され、各種関連 ロジックの実行が可能 Geode キャッシュサーバー リージョン Geode クライアント ローカル キャッシュ データ更新 対象リージョンにおいて、 クエリーにヒットする データが更新 CQ リスナーに CQ イベントを送信 プール SELECT * FROM /Stock WHERE ticker = ‘GPV’ and price > 20
  8. 8. 8 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ <client-cache …> <pool name=”myPool" subscription-enabled="true"> <locator host="172.16.227.2" port="55221"/> </pool> <region name=“myRegion" refid="CACHING_PROXY"> <region-attributes pool-name=”myPool"> <cache-listener> <class-name>io.pivotal.akitada.SimpleCacheListener</class-name> </cache-listener> </region-attributes> </region> </client-cache> Apache Geode でクライアントプログラミング  ソースコード  キャッシュ設定ファイル(client-cache.xml) ClientCache cache = new ClientCacheFactory() .set("cache-xml-file", "client-cache.xml") .create(); Region<String, String> region = cache.getRegion(“myRegion"); region.put(“key1”, “value1”); クライアントキャッシュ生成 (サーバーアクセスのために 必要) アクセス先のリージョン取得 生成プール情報 (分散システム接続情報) リージョン情報 (プール名指定、 キャッシュリスナー付与) データ put
  9. 9. 9 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ (参考) SnppyData〜もう一つの GemFire オープンソース製品  2016 年 1 月に、Pivotal からスピンアウトした SnappyData 社よりリリース  Pivotal GemFire をベースに、HDFS データストア連携、 SQL インターフェース、Spark、AQP(Approximate Query Processing)技術を実装した、OLAP + OLTP 基盤  2016 年 3 月現在、v0.1 preview バージョンがリリース 済み  URL: http://www.snappydata.com
  10. 10. 10 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ gfsh による Geode 分散 システムの起動、 データ操作 Apache Geode
  11. 11. 11 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Gemfire とは?
  12. 12. 12 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Gemfire とは?(1/2)  Spring Data とは? • あらゆるデータソースに対して Spring フレームワークベースの一貫した容易な アクセス手段を提供  Spring Data Gemfire は Spring Data の “umbrella project” • Spring による GemFire リソースの生成・設定を行う XML ネームスペースのサ ポート • GemFire の Spring Data Repositories による抽象化 • アノテーションベースのファンクション実行 • インタレスト登録、コンティニュアス・クエリーの xml 設定 サポート • Spring Data GemFire 1.7 より、Apache Geode サポート
  13. 13. 13 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Gemfire によるコーディング例(1/2)  再掲) Geode API を用いたクライアント実装 ClientCache cache = new ClientCacheFactory() .set("cache-xml-file", "client-cache.xml") .create(); Region<String, String> region = cache.getRegion(“myRegion"); region.put(“key1”, “value1”); <client-cache …> <pool name=”myPool" subscription-enabled="true"> <locator host="172.16.227.2" port="55221"/> </pool> <region name=“myRegion" refid="CACHING_PROXY"> <region-attributes pool-name=”myPool"> <cache-listener> <class-name>io.pivotal.akitada.SimpleCacheListener</class-name> </cache-listener> </region-attributes> </region> </client-cache> ソースコード キャッシュ 設定ファイル
  14. 14. 14 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Gemfire によるコーディング例(2/2)  Spring Data Gemfire を用いたクライアント実装 ApplicationContext context= new ClassPathXmlApplicationContext("META-INF/path-to/cache-config.xml"); Region<String,String> region = context.getBean(Region.class); region.put("key1", "value1"); <beans ...> <gfe-data:datasource subscription-enabled="true"> <gfe-data:locator host="172.16.9.1" port="55221" /> </gfe-data:datasource> <gfe:client-region id="myRegion” shortcut="CACHING_PROXY"> <gfe:cache-listener> <bean class="io.pivotal.akitada.SimpleCacheListener" /> </gfe:cache-listener> </gfe:client-region> </beans> ソースコード キャッシュ 設定ファイル
  15. 15. 15 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Apache Geode で Spring Data Gemfire を使う
  16. 16. 16 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ STS を使って Apache Geode + Spring Data Gemfire でアプリ開発  STS とは? = Spring Tool Suite • Java IDE Eclipse ベースの Spring アプリケーション開発ツールスイート • http://spring.io/tools • 豊富な Spring プロジェクトテンプレート • すぐに Spring ベースの開発が始められる • Spring Data GemFire のプロジェクト テンプレートも用意 • 無償提供 • Pivotal による有償サポートも提供(Spring Enterprise Support)
  17. 17. 17 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Apache Geode + Spring Data Gemfire プロジェクトの作成  STS で Spring Data Gemfire プロジェクトを作成 • File > New > Spring Legacy Project にてダイアログ表示 • Templates: にて GemFire テンプレートから何か選択(例えば、Spring Data GemFire Client Project) • Maven プロジェクトを作成  pom.xml の編集 <properties> <spring.data.gemfire.version>1.7.4.RELEASE</spring.data.gemfire.version> : <dependencies> <dependency> <groupId>org.apache.geode</groupId> <artifactId>gemfire-core</artifactId> <version>1.0.0-incubating.M1</version> </dependency> 最新版 Spring Data Gemfire のバージョンを指定 dependencies の先頭 (Spring Data GemFire よりも 前)に、Geode の dependency を追加
  18. 18. 18 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Demo Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Spring Data Gemfire をちょっ と使った CacheListener の デモ Apache Geode + Spring Data Gemfire
  19. 19. 19 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 最後に…
  20. 20. 20 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ 今日のまとめとやり残したこと  今日のまとめ • Apache Geode の概要紹介 • Spring Data Gemfire の概要紹介 • Apache Geode + Spring Data Gemfire によるアプリケーション開発 事始め  やり残したこと • Apache Geode と Apache Ignite の 比較 • JavaConfig を使ったキャッシュの設定 • アノテーションを使った Spring 的なプ ログラミングの探求
  21. 21. 21 Unless otherwise indicated, these slides are © 2013-2016 Pivotal Software, Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Apache Geode / Spring Data Gemfire – 技術情報  Spring Data Gemfire supports Apache Geode • https://spring.io/blog/2015/06/12/spring-data-gemfire-supports-apache-geode  GitHub – spring-projects/spring-gemfire-examples: サンプルコード • https://github.com/spring-projects/spring-gemfire-examples  Apache Geode: プロジェクトホーム • http://geode.incubator.apache.org/  Spring Data Gemfire: プロジェクトホーム • http://projects.spring.io/spring-data-gemfire/  今回使用したデモ用アプリケーションプロジェクト一式 • https://github.com/AkihiroKitada/MySpringDataGemfireSamples

×