Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... ·...

85
@plmuir 1 Pete Muir Red Hat, Inc. May 2012 Real World Infinispan Wednesday, 16 May 12

Transcript of Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... ·...

Page 1: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir1

Pete MuirRed Hat, Inc.May 2012

Real World Infinispan

Wednesday, 16 May 12

Page 2: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Agenda

•Introduction•What is Infinispan?•Principle use cases•Key features

•Hands-on demo•build an application using infinispan

•Extras•Querying the Grid•Database - OGM•Performance tuning - RadarGun

•Conclusion

Wednesday, 16 May 12

Page 3: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Lab Setup

•Download the lab zip:

•Unzip the lab to your disk to a location of your choice•If you are a git user, you can clone the repository:

•each stage of this lab has a checkpoint which is branched, you can check out the code for each Checkpoint using:

git clone git://github.com/infinispan/infinispan-labs.git

git checkout -b checkpointX origin/checkpointX

http://bit.ly/infinispan-labs

Wednesday, 16 May 12

Page 4: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Lab Setup

•Follow along using

•Download JBoss AS 7.1.1 from

•Unzip JBoss AS to your disk to a location of your choice

http://bit.ly/infinispan-labs

http://jboss.org/jbossas/downloads

Wednesday, 16 May 12

Page 5: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Introduction

Wednesday, 16 May 12

Page 6: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

So what is Infinispan?

•Distributed, in memory, data structure•Highly available•Elastic•Open source

Wednesday, 16 May 12

Page 7: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Distributed Data structure

Wednesday, 16 May 12

Page 8: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

High availability

•Memory is volatile•Make redundant copies

•Total replication (Replication Mode)•Partial replication (Distribution Mode)

•Topology changes•Node will crash!•Re-arrange state

Wednesday, 16 May 12

Page 9: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Elasticity

•Expect•Node additions•Node removals

•Topology changes •are totally consistent•do not "stop the world"

Wednesday, 16 May 12

Page 10: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Access modes

•Embedded•client and node on same VM•fast!

•Client/server•different processes•multiple protocols

•REST•Memcached•Hotrod

Wednesday, 16 May 12

Page 11: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Embedded access

Wednesday, 16 May 12

Page 12: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Client/server access

Server endpoints- REST- Memcached- Hotrod

Wednesday, 16 May 12

Page 13: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Main use cases  

•Local cache•e.g. Hibernate 2nd level cache

•Cluster of caches•More caching capacity•Co-located clients

•Data Grid•dedicated cluster of servers•remote access

Wednesday, 16 May 12

Page 14: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Good old caching...

•Local cache•java.util.Map

•And some more•eviction•expiry•write through/behind•passivation•preloading•notifications

Wednesday, 16 May 12

Page 15: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Use Case 1: Local Cache

Wednesday, 16 May 12

Page 16: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Use Case 2: Cluster of caches

Wednesday, 16 May 12

Page 17: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Use Case 3: Data grid

Wednesday, 16 May 12

Page 18: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Use Case 3: Data grid

Wednesday, 16 May 12

Page 19: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Key features

•Cloud oriented•Transactions•Querying•Map/Reduce and Dist Executors•Cache loaders•Management

•JMX•RHQ

Wednesday, 16 May 12

Page 20: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Hands on Demo

Wednesday, 16 May 12

Page 21: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Reliable Multipoint Communication

Wednesday, 16 May 12

Page 22: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Why do you care?

Wednesday, 16 May 12

Page 23: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Shall we try it out?

•In the lab project you'll find a test script for your network. Run it!

•LAB_HOME/nic-test•If all goes well, you'll get two windows in which you can draw up on your screen. Draw on one, see it in both.•Easy to try: JGroups has no dependencies!

Wednesday, 16 May 12

Page 24: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

What is unreliable ?

•Messages get •dropped

•too big (UDP has a size limit), no fragmentation•buffer overflow at the receiver, switch

•NIC, IP network buffer

•reordered•We don't know who is in a cluster (IP multicast)

•we don't know when a new node joins, leaves, or crashes•Fast sender might overwhelm slower receiver(s)

•flow control

Wednesday, 16 May 12

Page 25: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

So what Is JGroups ?

•Library for reliable cluster communication•Provides

•Fragmentation•Message retransmission•Flow control•Ordering•Group membership, membership change notification

•LAN or WAN based•IP multicasting transport default for LAN•TCP transport default for WAN•Autodiscovery of cluster members

Wednesday, 16 May 12

Page 26: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Terminology

Message Address View Group topology

Wednesday, 16 May 12

Page 27: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Discovery Protocols

•PING, MPING, BPING, ..•TCP_PING•JDBC_PING•S3_PING•CASSANDRA_PING

Wednesday, 16 May 12

Page 28: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Eviction and expiration

Wednesday, 16 May 12

Page 29: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Expiration

•Time based•lifespan•max idle

•Expired entries removed•from cache•from persistent store (if any)

Wednesday, 16 May 12

Page 30: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Configuration

Wednesday, 16 May 12

Page 31: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Eviction

•Memory is finite•something has to give!

•Evict based on data access•Bounded caches

Wednesday, 16 May 12

Page 32: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Eviction strategies

•None (default)•Unordered•FIFO•LRU•LIRS

Wednesday, 16 May 12

Page 33: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

LIRS

•Low Inter-reference Recency Set replacement•Hybrid

•frequency of access•time of the last access

Wednesday, 16 May 12

Page 34: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Passivation

•Evict to external store•file, database...

•Cheaper than remote access (?)•Use the right eviction policy

•keep relevant bits in memory

Wednesday, 16 May 12

Page 35: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Configuration

Wednesday, 16 May 12

Page 36: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Tuning eviction

•What eviction policy should I use?•Measure, don’t guess

•Cache JMX stats•hits/misses ratio

•Memory issues?•Aggressive wakeup interval

Wednesday, 16 May 12

Page 37: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Listeners

Wednesday, 16 May 12

Page 38: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Listener types

•Cache listeners•data: added, remove, changed, entry loaded•transaction: completed, registered•topology: changed, data rehashed

•Cache manager listeners•cache started/stopped, view changed/merge

Wednesday, 16 May 12

Page 39: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Synchronicity

•listener executes in caller’s thread (default)•keep it short!

•Or async

Wednesday, 16 May 12

Page 40: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

•Listeners are local•Can veto an operation•Participate in transactions•Do not work on RemoteCacheManager

Wednesday, 16 May 12

Page 41: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Transactions

Wednesday, 16 May 12

Page 42: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Agenda

•Transactions•optimistic/pessimistic• JTA support

•XA (or not)•Recovery•Deadlock avoidance

Wednesday, 16 May 12

Page 43: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Cache types

•Non transactional•Transactional

•optimistic•pessimistic•TransactionManager required

•No mixed-access

Wednesday, 16 May 12

Page 44: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Transactional caches

•Optimistic•no locks before prepare•small lock scope

•Pessimistic•lock acquired on each write•writes block writes•reads do not block

•locks held longer

Wednesday, 16 May 12

Page 45: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Pessimistic or Optimistic?

•Optimistic•low contention•high contention -> many rollbacks•disable version check

•Pessimistic•high key contention•rollbacks are less desirable

•more costly/more guarantees

Wednesday, 16 May 12

Page 46: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

JTA integration

•JTA transactions•known API

•Multiple options•full xa (XAResource)•less strict (Synchronization)

Wednesday, 16 May 12

Page 47: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

XA or not?

•XA •proper distributed transactions•recovery enabled

•or not

•Synchronization•cache backed by a data store •Transaction more efficient•1PC optimisation•TransactionManager not writing logs •Hibernate 2LC

Wednesday, 16 May 12

Page 48: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Recovery

•When is needed?•prepare successful, commit fails•inconsistent state!

•How to handle it•TransactionManager informs SysAdmin•JMX tooling exposed to•force commit•force rollback

Wednesday, 16 May 12

Page 49: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Modes of Operation

Wednesday, 16 May 12

Page 50: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Consistent Hashing: DIST

Wednesday, 16 May 12

Page 51: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Clustering: Cache modes

•DIST•Sync/Async

•REPL•Sync/Async

•LOCAL•Doesn't have async

•INV•Sync/Async

Wednesday, 16 May 12

Page 52: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

DIST again

Wednesday, 16 May 12

Page 53: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

DIST + VNodes

Wednesday, 16 May 12

Page 54: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Client Server

Wednesday, 16 May 12

Page 55: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Peer to peer

Wednesday, 16 May 12

Page 56: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Client/Server Architecture

Supported ProtocolsRESTMemcachedHot Rod

Wednesday, 16 May 12

Page 57: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Hotrod?!

•Wire protocol for client server communications•Open•Language independent•Built-in failover and load balancing•Smart routing•xa support - to come

Wednesday, 16 May 12

Page 58: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Server Endpoint Comparison

Protocol Client Libraries Clustered? Smart Routing Load Balancing/Failover

REST Text N/A Yes No Any HTTP load balancer

Memcached Text Plenty Yes No Only with predefined server list

Hot Rod Binary Java, Python Yes Yes Dynamic

Wednesday, 16 May 12

Page 59: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Client/Server - when?

•Client not affected by server topology changes•Multiple apps share the same grid •Tier management

•incompatible JVM tuning•security

•Non-JVM clients

Wednesday, 16 May 12

Page 60: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Cache Stores

Wednesday, 16 May 12

Page 61: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Why use cache stores?

•Durability•More caching capacity•Warm caches

•preload

Wednesday, 16 May 12

Page 62: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Features

•Chaining•more than one per cache

•Passivation•with eviction

•Async•write behind

•Shared

Wednesday, 16 May 12

Page 63: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Types of cache stores

•File system•FileCacheStore•BdbjeCacheStore

•JDBC•Cloud cache store (JCouds)

Wednesday, 16 May 12

Page 64: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

More cache stores

•RemoteCacheStore•use Hotrod

•Cassandra •ClusterCacheStore

•alternative to state transfer•Custom!

Wednesday, 16 May 12

Page 65: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Extras

Wednesday, 16 May 12

Page 66: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Querying

Wednesday, 16 May 12

Page 67: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

To query a Grid

•What's in C7 ?

•Where is the white King?

Object p =

cache.get(“c7”);

Wednesday, 16 May 12

Page 68: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Infinispan and Queries

•How to query the grid•Key access•Statistics•Map/Reduce•Indexing of stored objects

•Integrate with existing search engines•Scale•Highly available

Wednesday, 16 May 12

Page 69: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Indexing of stored objects

•Maven module: infinispan-query•Configuration: indexing=true

•Will trigger on annotated objects•Integrates hibernate-search-engine•Based on Apache Lucene

Wednesday, 16 May 12

Page 70: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Enable indexing

Configuration c = new Configuration() .fluent() .indexing() .addProperty( "hibernate.search.option", "value" ) .build();CacheManager manager = new DefaultCacheManager(c);

Wednesday, 16 May 12

Page 71: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Annotate your objects

@ProvidedId @Indexed

public class Book implements Serializable {

@Field String title;

@Field String author;

@Field String editor;

...

}

Wednesday, 16 May 12

Page 72: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Search them!

SearchManager sm = Search.getSearchManager(cache); Query query = sm.buildQueryBuilderForClass(Book.class) .get() .phrase() .onField("title") .sentence("in action") .createQuery(); List<Object> list = sm.getQuery(query).list();

Wednesday, 16 May 12

Page 73: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Lucene API, storing in Infinispan

Wednesday, 16 May 12

Page 74: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Limited write concurrency

Wednesday, 16 May 12

Page 75: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Example of multi-cache app

Wednesday, 16 May 12

Page 76: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Wednesday, 16 May 12

Page 77: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

•OGM: Object/Grid Mapper•Implements JPA for NoSQL engines

•Infinispan as first supported “engine”•More coming

•Simplified migration across different NoSQL, SQL databases

•With transactions, or whatever is possible.•Fast? Contribute tests and use cases!

Wednesday, 16 May 12

Page 78: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

•JPA on NoSQL: an approach with Hibernate OGM•Devoxx 2011

•November 17th (conf Day 4) - 14:00 – 15:00•Emmanuel Bernard

Wednesday, 16 May 12

Page 79: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Conclusion

Wednesday, 16 May 12

Page 80: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Use Cases

•Local Cache•Distributed Cache•Data Grid

Wednesday, 16 May 12

Page 81: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Access Modes

•Embedded•Remote

•Hot Rod•REST•Memcache

Wednesday, 16 May 12

Page 82: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Control

•Eviction•Expiration•Management

Wednesday, 16 May 12

Page 83: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Transaction & Locking

•XA•Local

Wednesday, 16 May 12

Page 84: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Persistence

•Cache Stores

Wednesday, 16 May 12

Page 85: Real World Infinispan - Amazon S3s3-eu-west-1.amazonaws.com/presentations2012/55... · 2012-05-25 · Real World Infinispan Wednesday, 16 May 12. @plmuir Agenda •Introduction •What

@plmuir

Q&A

Wednesday, 16 May 12