Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red...
Transcript of Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red...
![Page 1: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/1.jpg)
Before we begin
1 git clone [email protected]:qa/pv243-a4m36jee-2016-infinispan-
seminar-autumn.git
2 cd pv243-a4m36jee-2016-infinispan-seminar-autumn
3 git checkout task1
4 mvn clean package
5 mvn wildfly:run
Optionally:
1 wget http://downloads.jboss.org/infinispan/9.2.1.Final/
infinispan-server-9.2.1.Final-bin.zip
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 1 / 59
![Page 2: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/2.jpg)
Infinispan
Vojtech Juranek
JBoss - a division by Red Hat
12. 4. 2018, FI MUNI, Brno
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 2 / 59
![Page 3: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/3.jpg)
Course materials download
Course materials, including this presentation:https://developer.jboss.org/wiki/AdvancedJavaEELabFIMUNIJaro2018/
This presentation (and the source code):https://github.com/vjuranek/presentations/tree/master/MUNI_Brno2018_spring
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 3 / 59
![Page 4: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/4.jpg)
Data today
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 4 / 59
![Page 5: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/5.jpg)
Data today
Source: http://www.couchbase.com/nosql-resources/what-is-no-sql
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 5 / 59
![Page 6: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/6.jpg)
How big is Big data?
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 6 / 59
![Page 7: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/7.jpg)
How big is Big data?
Source: https://twitter.com/DEVOPS_BORAT/status/288698056470315008
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 6 / 59
![Page 8: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/8.jpg)
How big is Big data?
Source: https://twitter.com/DEVOPS_BORAT/status/288698056470315008
Data collection so large and complex it’s impossible to process it on one
computer
You can scale up, but sooner or later you’ll have to scale out
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 6 / 59
![Page 9: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/9.jpg)
Structure of the data
Source: http://www.couchbase.com/nosql-resources/what-is-no-sql
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 7 / 59
![Page 10: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/10.jpg)
Big data - some of the challenges
Analysis run on top of the huge amount of data
Ability to store huge amount of unstructured data (often for performance
reasons)
But also ability to talk to RDBMS or query structured data is often needed
as well
Highly scalable solution (also because of cost effectiveness)
Cloud architecture - everything is ephemeral
Information privacy
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 8 / 59
![Page 11: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/11.jpg)
NoSQL
Nature of the data
More flexible data mode
Better scalablity
Performance
Source: www.couchbase.com/sites/default/files/uploads/all/whitepapers/NoSQL-Whitepaper.pdf
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 9 / 59
![Page 12: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/12.jpg)
NoSQL
Source: https://twitter.com/devops_borat/status/141368065110708224
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 10 / 59
![Page 13: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/13.jpg)
Distributed databases
Good scalability
Better perfomance
But also bring a lot of different challenges
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 11 / 59
![Page 14: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/14.jpg)
Distributed systems
Source: https://twitter.com/mathiasverraes/status/632260618599403520
More related jokes on
https://martinfowler.com/bliki/TwoHardThings.html
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 12 / 59
![Page 15: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/15.jpg)
Distributed databases
You probably don’t want to implement it yourselves, just once example (read
after write/read your writes consistency):
Source: M. Kleppmann, Designing Data-Intensive Applications, O’Reilly Media, Inc., 2016
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 13 / 59
![Page 16: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/16.jpg)
Distributed databases and data intensive applications
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 14 / 59
![Page 17: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/17.jpg)
What is a in-memory data grid?
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 15 / 59
![Page 18: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/18.jpg)
What is a data grid?
In-memory = all data is kept in memoryGrid = too big to kept data on one node, data is distributed across
more/many nodes
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 16 / 59
![Page 19: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/19.jpg)
What is a data grid?
In-memory = all data is kept in memoryGrid = too big to kept data on one node, data is distributed across
more/many nodes
An in-memory distributed data store designed for fast access to large
volumes of data and scalability.
Commonly a complementary layer to the relational database or some
other persistent data storage, usually as a cache:
Source: Part of xkcd #908
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 16 / 59
![Page 20: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/20.jpg)
Key data grid characteristics
In-memory, distributed caching
Elastic and scalable
Advanced querying
Data replication
Processing for streaming data
Transaction capabilities
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 17 / 59
![Page 21: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/21.jpg)
Why in-memory
Lots of data is needed in real-time (BigData → FastData)
Some tasks can be completed much faster when data are kept in memory
Keeping data in memory during processing of whole application stack,
not only during processing in one application in the stack
With data replication you can keep your data only in memory (no need to
store them in persistent storage)
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 18 / 59
![Page 22: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/22.jpg)
Why in-memory
Lots of data is needed in real-time (BigData → FastData)
Some tasks can be completed much faster when data are kept in memory
Keeping data in memory during processing of whole application stack,
not only during processing in one application in the stack
With data replication you can keep your data only in memory (no need to
store them in persistent storage)
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 18 / 59
![Page 23: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/23.jpg)
Why in-memory
Lots of data is needed in real-time (BigData → FastData)
Some tasks can be completed much faster when data are kept in memory
Keeping data in memory during processing of whole application stack,
not only during processing in one application in the stack
With data replication you can keep your data only in memory (no need to
store them in persistent storage)
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 18 / 59
![Page 24: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/24.jpg)
Why in-memory
Lots of data is needed in real-time (BigData → FastData)
Some tasks can be completed much faster when data are kept in memory
Keeping data in memory during processing of whole application stack,
not only during processing in one application in the stack
With data replication you can keep your data only in memory (no need to
store them in persistent storage)
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 18 / 59
![Page 25: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/25.jpg)
Infinispan
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 19 / 59
![Page 26: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/26.jpg)
Infinispan
https://infinispan.org
https://github.com/infinispan
(Apache License, v2.0)
In-memory data grid platform, written in
Java
Schema-less (optionally), No-SQL
key-value data store
Distributed cache - offers massive
memory
Elastic and scalable - can run on
hundreds of nodes
Highly available - no SPOF, resilient to
node failures
Multi-version concurrency control (MVCC)
Transactional
Queryable
Processing for streaming data
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 20 / 59
![Page 27: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/27.jpg)
Infinispan cache
Infinispan takes care about all that hard stuff.
From user perspective Infinispan cache is just a map!
1 DefaultCacheManager cacheManager = new DefaultCacheManager(
"my_ispn_config.xml");
2 Cache<String, String> cache = cacheManager.getCache("
myCache");
3
4 cache.put("key", "value");
5 String value = cache.get("key");
ISPN configuration can be either programmatic (preferred for demos) or
via XML (preferred in production as you don’t have to re-compile the code
due to conf. changes).
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 21 / 59
![Page 28: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/28.jpg)
Infinispan (embedded) high level architecture
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 22 / 59
![Page 29: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/29.jpg)
Basic features: eviction
Removing entries from the cache: eviction
1 ConfigurationBuilder().eviction().size(5).strategy(
EvictionStrategy.LRU)
1 Configuration conf = new ConfigurationBuilder().eviction().size
(5).strategy(EvictionStrategy.LIRS).build();
2 EmbeddedCacheManager ecm = new DefaultCacheManager(conf);
3 Cache<String, String> cache = ecm.getCache();
4
5 for (int i = 0; i < 100; i++) {
6 cache.put("key" + i, "value" + i);
7 }
8
9 System.out.printf("Cache size: %d\n", cache.size());
10 ecm.stop();
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 23 / 59
![Page 30: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/30.jpg)
Basic features: cache listener
1 cache.addListener(new EntryCreatedListener());
There are actually two events emitted, before given operation happens
and once it’s finished.
You can distinguish them by calling isPre() on the event (true for
events prior the operation)
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 24 / 59
![Page 31: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/31.jpg)
1 @Listener
2 public class EntryCreatedListener {
3 @CacheEntryCreated
4 public void onCreated(CacheEntryCreatedEvent e) {
5 if (e.isPre()) {
6 System.out.printf("Created %s -> %s\n", e.getKey(),
e.getValue());
7 }
8 }
9 }
1 EmbeddedCacheManager cm = new DefaultCacheManager();
2 Cache<String, String> cache = cm.getCache();
3 cache.addListener(new EntryCreatedListener());
4
5 for (int i = 0; i < 100; i++) {
6 cache.put("key" + i, "value" + i);
7 }
8 cm.stop();
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 25 / 59
![Page 32: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/32.jpg)
Basic features: CDI
1 @Qualifier
2 @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.
METHOD})
3 @Retention(RetentionPolicy.RUNTIME)
4 @Documented
5 public @interface EvictionCache {
6 }
1 @ConfigureCache("testcache")
2 @EvictionCache
3 @Produces
4 public Configuration greetingCacheConfiguration() {
5 return new ConfigurationBuilder().eviction().strategy(
EvictionStrategy.LRU).size(5).build();
6 }
1 @Inject
2 @EvictionCache
3 private Cache<String, String> cache;
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 26 / 59
![Page 33: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/33.jpg)
Persistence: Cache stores
A way how to store cache content in some external (persistent) storage.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 27 / 59
![Page 34: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/34.jpg)
Persistence: Cache stores
A way how to store cache content in some external (persistent) storage.Two modes:
Synchronous (write-through)
Asynchronous (write-behind)
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 27 / 59
![Page 35: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/35.jpg)
Persistence: Cache stores
A way how to store cache content in some external (persistent) storage.Two modes:
Synchronous (write-through)
Asynchronous (write-behind)
Cache stores:
Single file store and soft-index file store
JDBC and JPA cache stores
LevelDB cache store
Cloud cache store
Remote store
Cassandra store
. . . and others
Also possible to define custom cache store.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 27 / 59
![Page 36: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/36.jpg)
Persistence: file cache store example
1 cfg.persistence().addSingleFileStore().location("/tmp/ispn-
store");
1 ConfigurationBuilder cfg = new ConfigurationBuilder();
2 cfg.persistence().addSingleFileStore();
3 DefaultCacheManager cm = new DefaultCacheManager(cfg.build());
4 Cache<String, String> cache = cm.getCache("test");
5
6 for (int i = 0; i < 100; i++) {
7 cache.put("key" + i, "value" + i);
8 }
9 System.out.printf("Cache size: %d\n", cache.size());
10
11 cache.stop();
12 cache.start();
13
14 System.out.printf("Cache size: %d\n", cache.size());
15 cm.stop();
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 28 / 59
![Page 37: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/37.jpg)
Querying
Support for indexing and searching of objects stored in the cache.
Search for data using data attributes instead of keys.
Uses Hibernate Search and Apache Lucene to index and search objects.
Queries can be constructed using ISPN fluent DSL API, Hibernate
Search Query DSL or directly Lucene query API.
Needs some data schema (protobuf file or annotations).
Combine queries and aggregation functions (but doesn’t support joins).
Sort, filter, and paginate query results.
Support for index or non-indexed queries.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 29 / 59
![Page 38: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/38.jpg)
Querying
Support for indexing and searching of objects stored in the cache.
Search for data using data attributes instead of keys.
Uses Hibernate Search and Apache Lucene to index and search objects.
Queries can be constructed using ISPN fluent DSL API, Hibernate
Search Query DSL or directly Lucene query API.
Needs some data schema (protobuf file or annotations).
Combine queries and aggregation functions (but doesn’t support joins).
Sort, filter, and paginate query results.
Support for index or non-indexed queries.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 29 / 59
![Page 39: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/39.jpg)
Querying
Support for indexing and searching of objects stored in the cache.
Search for data using data attributes instead of keys.
Uses Hibernate Search and Apache Lucene to index and search objects.
Queries can be constructed using ISPN fluent DSL API, Hibernate
Search Query DSL or directly Lucene query API.
Needs some data schema (protobuf file or annotations).
Combine queries and aggregation functions (but doesn’t support joins).
Sort, filter, and paginate query results.
Support for index or non-indexed queries.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 29 / 59
![Page 40: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/40.jpg)
Querying
Support for indexing and searching of objects stored in the cache.
Search for data using data attributes instead of keys.
Uses Hibernate Search and Apache Lucene to index and search objects.
Queries can be constructed using ISPN fluent DSL API, Hibernate
Search Query DSL or directly Lucene query API.
Needs some data schema (protobuf file or annotations).
Combine queries and aggregation functions (but doesn’t support joins).
Sort, filter, and paginate query results.
Support for index or non-indexed queries.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 29 / 59
![Page 41: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/41.jpg)
Querying
Support for indexing and searching of objects stored in the cache.
Search for data using data attributes instead of keys.
Uses Hibernate Search and Apache Lucene to index and search objects.
Queries can be constructed using ISPN fluent DSL API, Hibernate
Search Query DSL or directly Lucene query API.
Needs some data schema (protobuf file or annotations).
Combine queries and aggregation functions (but doesn’t support joins).
Sort, filter, and paginate query results.
Support for index or non-indexed queries.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 29 / 59
![Page 42: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/42.jpg)
Querying
Support for indexing and searching of objects stored in the cache.
Search for data using data attributes instead of keys.
Uses Hibernate Search and Apache Lucene to index and search objects.
Queries can be constructed using ISPN fluent DSL API, Hibernate
Search Query DSL or directly Lucene query API.
Needs some data schema (protobuf file or annotations).
Combine queries and aggregation functions (but doesn’t support joins).
Sort, filter, and paginate query results.
Support for index or non-indexed queries.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 29 / 59
![Page 43: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/43.jpg)
Querying
Support for indexing and searching of objects stored in the cache.
Search for data using data attributes instead of keys.
Uses Hibernate Search and Apache Lucene to index and search objects.
Queries can be constructed using ISPN fluent DSL API, Hibernate
Search Query DSL or directly Lucene query API.
Needs some data schema (protobuf file or annotations).
Combine queries and aggregation functions (but doesn’t support joins).
Sort, filter, and paginate query results.
Support for index or non-indexed queries.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 29 / 59
![Page 44: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/44.jpg)
Querying
Support for indexing and searching of objects stored in the cache.
Search for data using data attributes instead of keys.
Uses Hibernate Search and Apache Lucene to index and search objects.
Queries can be constructed using ISPN fluent DSL API, Hibernate
Search Query DSL or directly Lucene query API.
Needs some data schema (protobuf file or annotations).
Combine queries and aggregation functions (but doesn’t support joins).
Sort, filter, and paginate query results.
Support for index or non-indexed queries.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 29 / 59
![Page 45: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/45.jpg)
Examples: querying
1 public class Person {
2 String name;
3 String surname;
4
5 public Person(String name, String surname) {
6 this.name = name;
7 this.surname = surname;
8 }
9 }
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 30 / 59
![Page 46: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/46.jpg)
Examples: querying
1 ConfigurationBuilder cb = new ConfigurationBuilder();
2 EmbeddedCacheManager cm = new DefaultCacheManager(cb.build());
3 Cache<String, Person> cache = cm.getCache();
4 cache.put("person1", new Person("Will", "Shakespeare"));
5
6 // Obtain a query factory for the cache
7 QueryFactory<?> queryFactory = Search.getQueryFactory(cache);
8
9 // Construct a query
10 Query query = queryFactory.from(Person.class).having("name").eq
("Will").toBuilder().build();
11
12 // Execute the query
13 List<Person> matches = query.list();
14
15 matches.forEach(person -> System.out.printf("Match: %s", person
));
16 cm.stop();
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 31 / 59
![Page 47: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/47.jpg)
Transactions, consistency, locking and isolation
JTA-compliant transactions
Deadlock detection and recovery (e.g. when ISPN fails during commit
phase of the transaction)
Data versioning
Ensures consistency of data, consistency guarantee: lock for key K is
always acquired on the same node of the cluster (key primary owner),regardless of where the transaction originates
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 32 / 59
![Page 48: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/48.jpg)
Commercial break: JGroups
JGroups is a toolkit for reliable messaging written in Java.
It can be used to create clusters whose nodes can send messages to each
other.
Main features:
Cluster creation and deletion. Cluster nodes can be spread across LANs
or WANs.
Membership detection and notification about joined/left/crashed cluster
nodes.
Sending and receiving of node-to-cluster messages (point-to-multipoint).
Sending and receiving of node-to-node messages (point-to-point).
Detection and removal of crashed nodes.
More about JGroups in upcoming WildFly clustering course!
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 33 / 59
![Page 49: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/49.jpg)
Commercial break: JGroups
JGroups is a toolkit for reliable messaging written in Java.
It can be used to create clusters whose nodes can send messages to each
other.
Main features:
Cluster creation and deletion. Cluster nodes can be spread across LANs
or WANs.
Membership detection and notification about joined/left/crashed cluster
nodes.
Sending and receiving of node-to-cluster messages (point-to-multipoint).
Sending and receiving of node-to-node messages (point-to-point).
Detection and removal of crashed nodes.
More about JGroups in upcoming WildFly clustering course!
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 33 / 59
![Page 50: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/50.jpg)
Clustering modes
Under the hood leverages JGroups project for clustering.
Data is distributed and replicated in the background.
Nodes can be added or removed smoothly.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 34 / 59
![Page 51: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/51.jpg)
Clustering modes
Under the hood leverages JGroups project for clustering.
Data is distributed and replicated in the background.
Nodes can be added or removed smoothly.
Local - no clustering
Replicated
Invalidation
Distributed
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 34 / 59
![Page 52: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/52.jpg)
Infinispan modes
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 35 / 59
![Page 53: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/53.jpg)
Remote protocols
Hot Rod
hashing and topology aware
failover during topology changes
smart request routing
Memcached
REST
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 36 / 59
![Page 54: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/54.jpg)
Remote protocols
Hot Rod
hashing and topology aware
failover during topology changes
smart request routing
Memcached
REST
Protocol Format Client libs Clustered Smart routing Load balancing/ Failover
Hot Rod binary Java, C++, yes yes dynamicC#, JS
Memcached text many yes no only predefined server list
REST text any HTTP client yes no any HTTP load balancer
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 36 / 59
![Page 55: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/55.jpg)
Hot Rod clients
Compatible with Java and non-Java platforms. Based on Protocol Buffers -
Google’s data interchange format.
Clients for
Java
C#
C++
JavaScript
Python
Ruby
Python and Ruby clients have only basic functionality.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 37 / 59
![Page 56: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/56.jpg)
Management console
Easy configuration
Monitoring and statistics
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 38 / 59
![Page 57: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/57.jpg)
Some other features - brief and selective list
Full JSR-107 support (Java Temporary Caching API)
Advanced security feature (role based access, encryption, integration
with LDAP, Kerberos etc.)
Remote events
Continuous query
Client near cache
Rolling upgrades
Cross data center replication (also Hot Rod clients support failover to
another data center)
Command line interface
Distributed executors
Distributed streams
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 39 / 59
![Page 58: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/58.jpg)
Some other features - brief and selective list
Full JSR-107 support (Java Temporary Caching API)
Advanced security feature (role based access, encryption, integration
with LDAP, Kerberos etc.)
Remote events
Continuous query
Client near cache
Rolling upgrades
Cross data center replication (also Hot Rod clients support failover to
another data center)
Command line interface
Distributed executors
Distributed streams
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 39 / 59
![Page 59: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/59.jpg)
Some other features - brief and selective list
Full JSR-107 support (Java Temporary Caching API)
Advanced security feature (role based access, encryption, integration
with LDAP, Kerberos etc.)
Remote events
Continuous query
Client near cache
Rolling upgrades
Cross data center replication (also Hot Rod clients support failover to
another data center)
Command line interface
Distributed executors
Distributed streams
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 39 / 59
![Page 60: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/60.jpg)
Some other features - brief and selective list
Full JSR-107 support (Java Temporary Caching API)
Advanced security feature (role based access, encryption, integration
with LDAP, Kerberos etc.)
Remote events
Continuous query
Client near cache
Rolling upgrades
Cross data center replication (also Hot Rod clients support failover to
another data center)
Command line interface
Distributed executors
Distributed streams
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 39 / 59
![Page 61: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/61.jpg)
Some other features - brief and selective list
Full JSR-107 support (Java Temporary Caching API)
Advanced security feature (role based access, encryption, integration
with LDAP, Kerberos etc.)
Remote events
Continuous query
Client near cache
Rolling upgrades
Cross data center replication (also Hot Rod clients support failover to
another data center)
Command line interface
Distributed executors
Distributed streams
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 39 / 59
![Page 62: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/62.jpg)
Some other features - brief and selective list
Full JSR-107 support (Java Temporary Caching API)
Advanced security feature (role based access, encryption, integration
with LDAP, Kerberos etc.)
Remote events
Continuous query
Client near cache
Rolling upgrades
Cross data center replication (also Hot Rod clients support failover to
another data center)
Command line interface
Distributed executors
Distributed streams
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 39 / 59
![Page 63: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/63.jpg)
Some other features - brief and selective list
Full JSR-107 support (Java Temporary Caching API)
Advanced security feature (role based access, encryption, integration
with LDAP, Kerberos etc.)
Remote events
Continuous query
Client near cache
Rolling upgrades
Cross data center replication (also Hot Rod clients support failover to
another data center)
Command line interface
Distributed executors
Distributed streams
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 39 / 59
![Page 64: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/64.jpg)
Some other features - brief and selective list
Full JSR-107 support (Java Temporary Caching API)
Advanced security feature (role based access, encryption, integration
with LDAP, Kerberos etc.)
Remote events
Continuous query
Client near cache
Rolling upgrades
Cross data center replication (also Hot Rod clients support failover to
another data center)
Command line interface
Distributed executors
Distributed streams
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 39 / 59
![Page 65: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/65.jpg)
Some other features - brief and selective list
Full JSR-107 support (Java Temporary Caching API)
Advanced security feature (role based access, encryption, integration
with LDAP, Kerberos etc.)
Remote events
Continuous query
Client near cache
Rolling upgrades
Cross data center replication (also Hot Rod clients support failover to
another data center)
Command line interface
Distributed executors
Distributed streams
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 39 / 59
![Page 66: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/66.jpg)
Some other features - brief and selective list
Full JSR-107 support (Java Temporary Caching API)
Advanced security feature (role based access, encryption, integration
with LDAP, Kerberos etc.)
Remote events
Continuous query
Client near cache
Rolling upgrades
Cross data center replication (also Hot Rod clients support failover to
another data center)
Command line interface
Distributed executors
Distributed streams
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 39 / 59
![Page 67: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/67.jpg)
Examples of usecases
Cache for backend
Fast data backend
HTTP session off-loading
Hibernate 2-nd level cache
In-memory Lucene index
Fast data backend for Apache Spark or Hadoop
. . .
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 40 / 59
![Page 68: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/68.jpg)
OpenShift
Try Infinispan on OpenShift
https://www.openshift.com/
Platform as a Service (PaaS)
Source: http://dilbert.com/strip/2011-01-07
Search OpenShift demos on
https://github.com/infinispan-demos/links
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 41 / 59
![Page 69: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/69.jpg)
Summary
Amount and structure of the data has changed rapidly during past couple
of years.
Cloud applications and Big/Fast data require new approaches and tools,
data grids are important building blocks of such solutions.
Infinispan is mature and feature rich data grid solution, which integrates
well with other frameworks and can be used as backbone for new
generation of enterprise applications.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 42 / 59
![Page 70: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/70.jpg)
Summary
Amount and structure of the data has changed rapidly during past couple
of years.
Cloud applications and Big/Fast data require new approaches and tools,
data grids are important building blocks of such solutions.
Infinispan is mature and feature rich data grid solution, which integrates
well with other frameworks and can be used as backbone for new
generation of enterprise applications.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 42 / 59
![Page 71: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/71.jpg)
Summary
Amount and structure of the data has changed rapidly during past couple
of years.
Cloud applications and Big/Fast data require new approaches and tools,
data grids are important building blocks of such solutions.
Infinispan is mature and feature rich data grid solution, which integrates
well with other frameworks and can be used as backbone for new
generation of enterprise applications.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 42 / 59
![Page 72: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/72.jpg)
Summary
Amount and structure of the data has changed rapidly during past couple
of years.
Cloud applications and Big/Fast data require new approaches and tools,
data grids are important building blocks of such solutions.
Infinispan is mature and feature rich data grid solution, which integrates
well with other frameworks and can be used as backbone for new
generation of enterprise applications.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 42 / 59
![Page 73: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/73.jpg)
Materials from this course
This presentation:https://github.com/vjuranek/presentations/tree/master/CTU_Prague2016_fall
ISPN embedded tutorial (The Weather App): http://infinispan.org/tutorials/embedded
GitHub repo: https://github.com/infinispan/infinispan-embedded-tutorial
ISPN simple tutorials: https://github.com/infinispan/infinispan-simple-tutorials
ISPN qickstarts (simple applications) at the bottom of the page:http://infinispan.org/tutorials
Some more ISPN snippets: https://github.com/vjuranek/infinispan-snippets
Infinispan downloads:
Main ISPN download page: http://infinispan.org/download/
If you want to play with ISPN in Docker:https://hub.docker.com/r/jboss/infinispan-server/
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 43 / 59
![Page 74: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/74.jpg)
Further study materials
Infinispan documentation
JSR 107: JCACHE - Java Temporary Caching API
M. Surtani, F. Marchioni, Infinispan Data Grid Platform, Packt Publishing,
2012
W. dos Santos, Infinispan Data Grid Platform Definitive Guide, Packt
Publishing, 2015
M. Kleppmann, Designing Data-Intensive Applications, O’Reilly Media,
Inc., 2016
M. Takada, Distributed systems for fun and profit
B. Burke, A. Rubinger, Enterprise JavaBeans 3.1, 6th Edition, O’Reilly
Media, Inc., 2010
Coursera: Cloud Computing Concepts
Coursera: Cloud Computing Concepts: Part 2
Coursera: Cloud Computing Applications
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 44 / 59
![Page 75: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/75.jpg)
Student projects/theses with Infinispan
https://developer.jboss.org/wiki/StudentContributorProjectsWithInfinispan
https://diplomky.redhat.com/
Inerested to work with Infinispan but non of the theses is interesting for you - drop me an email onvjuranek[at]redhat.com, we try to figure out something.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 45 / 59
![Page 76: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/76.jpg)
Question?
Source: https://xkcd.com/1289/
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 46 / 59
![Page 77: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/77.jpg)
http://infinispan.org/
Thank you for your attention!
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 47 / 59
![Page 78: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/78.jpg)
Backup slides
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 48 / 59
![Page 79: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/79.jpg)
Infinispan embedded tutorial
Simple weather app using embedded Infinispan
http://infinispan.org/tutorials/embedded/
https://github.com/infinispan/infinispan-embedded-tutorial
1 git clone https://github.com/infinispan/infinispan-embedded
-tutorial.git
2 cd infinispan-embedded-tutorial
3 git checkout -f step-2
4 sed -i ’s/<!-- a/<a/;s/t -->/t>/’ pom.xml #switch to local
random weather service
5 mvn clean package
6 mvn exec:exec
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 49 / 59
![Page 80: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/80.jpg)
Basic features: expiration
Removing entries from the cache: expiration
1 ConfigurationBuilder().expiration().maxIdle(5000L)
1 Configuration conf = new ConfigurationBuilder().expiration().
maxIdle(expiration).build();
2 EmbeddedCacheManager ecm = new DefaultCacheManager(conf);
3 Cache<String, String> cache = ecm.getCache();
4
5 for (int i = 0; i < 100; i++) {
6 cache.put("key" + i, "value" + i);
7 }
8
9 System.out.printf("Cache size: %d\n", cache.size());
10 Thread.sleep(expiration);
11 System.out.printf("Cache size: %d\n", cache.size());
12
13 ecm.stop();
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 50 / 59
![Page 81: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/81.jpg)
Examples: querying with index
1 @Indexed
2 public class Person {
3 @Field(analyze = Analyze.NO)
4 String name;
5
6 @Field(analyze = Analyze.NO, indexNullAs = Field.
DEFAULT_NULL_TOKEN)
7 String surname;
8
9 public Person(String name, String surname) {
10 this.name = name;
11 this.surname = surname;
12 }
13 }
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 51 / 59
![Page 82: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/82.jpg)
Examples: querying with index
1 ConfigurationBuilder cb = new ConfigurationBuilder();
2 cb.indexing().index(Index.ALL); //.addProperty("default.
directory_provider", "ram");
3 EmbeddedCacheManager cm = new DefaultCacheManager(cb.build());
4 Cache<String, Person> cache = cm.getCache();
5 cache.put("person1", new Person("Will", "Shakespeare"));
6
7 // Obtain a query factory for the cache
8 QueryFactory<?> queryFactory = Search.getQueryFactory(cache);
9
10 // Construct a query
11 Query query = queryFactory.from(Person.class).having("name").eq
("Will").toBuilder().build();
12
13 // Execute the query
14 List<Person> matches = query.list();
15
16 matches.forEach(person -> System.out.printf("Match: %s", person
));
17 cm.stop();
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 52 / 59
![Page 83: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/83.jpg)
Big data characteristics
Volume: unprecedented amount of data being stored
Velocity: speed at which the data is generated
Variety: the type and nature of the data - from structured data in
traditional databases to unstructured text documents, email, video, audio
etc.
Variability: the amount of incoming data can highly vary
Veracity: the quality of captured data can vary greatly as well
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 53 / 59
![Page 84: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/84.jpg)
Analyst recognition
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 54 / 59
![Page 85: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/85.jpg)
Integration with other frameworks
Hibernate
2-nd level cache
Lucene directory
In-memory Lucene index
Apache Camel
Infinispan component for Camel
Hadoop
In-memory data source for Hadoop cluster
Apache Spark
Data source for Spark map-reduce jobs
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 55 / 59
![Page 86: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/86.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 87: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/87.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 88: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/88.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 89: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/89.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 90: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/90.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 91: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/91.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 92: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/92.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 93: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/93.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 94: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/94.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 95: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/95.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 96: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/96.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 97: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/97.jpg)
Transactions, consistency, locking and isolation (cont.)
Pessimistic and optimistic locking available
Pessimistic locking: resource is locked all the time during the transaction (in
ISPN when resource is changed, read is still possible).
Optimistic locking: state of the resource is saved at the beginning of the
transaction (prepare phase) and other transactions ca access the resource.
During commit phase of the resource is read again and if changed (write
skew), transaction is rolled back.
Isolation - how/when the changes made by one operation become visibleto other. Read committed and repeatable read isolation levels.
1 Thread1: tx.begin()2 Thread1: cache.get(k) returns v3 Thread2: tx.begin()4 Thread2: cache.get(k) returns v5 Thread2: cache.put(k, v2)6 Thread2: tx.commit()7 Thread1: cache.get(k)
With REPEATABLE READ, step 7 will still return v, while with
READ COMMITTED step 7 will return v2.
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 56 / 59
![Page 98: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/98.jpg)
Security
Role based access control
User authentication
Node authentication and authorization
Encryption of communication
Audit logging
Integration with LDAP and/or Kerberos server (includes Active Directory)
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 57 / 59
![Page 99: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/99.jpg)
Features in Infinispan 8
Functional API
Distributed streams
Continuous querying, grouping and aggregation
New management console
Integration with Apache Spark and Hadoop
. . . and more
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 58 / 59
![Page 100: Infinispan - JBoss · 2020. 6. 4. · Infinispan Vojtech Jurˇ anek´ JBoss - a division by Red Hat 12. 4. 2018, FI MUNI, Brno Vojtech Jurˇ ´anek (Red Hat) Infinispan 12. 4. 2018,](https://reader033.fdocuments.net/reader033/viewer/2022060923/60af03204ecac21ced2fcd75/html5/thumbnails/100.jpg)
Commercial break: Protocol Buffers
Protocol Buffers (protobuf) are language-neutral, platform-neutral,
extensible mechanism for serializing structured data developed by Google.
Supports C++, C#, Go, Java, Python.
You need to define data structure in protobuf file.
In ISPN you can use also annotations in the your model.
Example of protobuf file:
1 message Address {
2 required string street = 1;
3 required string postCode = 2;
4 }
5
6 message Person {
7 optional int32 id = 1;
8 required string name = 2;
9 required string surname = 3;
10 optional Address address = 4;
11 optional string license = 5;
12 enum Gender {
13 MALE = 0;
14 FEMALE = 1;
15 }
16 }
Vojtech Juranek (Red Hat) Infinispan 12. 4. 2018, FI MUNI, Brno 59 / 59