SlideShare une entreprise Scribd logo
1  sur  39
@payara_fish 
JSR107 
Come, Code, Cache, Compute! 
Steve Millidge
@payara_fish 
Agenda 
• Basic Caching 
– Cache API 
– Cache Configuration 
• Cache Events 
• Cache Computations
@payara_fish 
What is JSR107? 
JCACHE JavaTM Temporary Caching API
Time delay in requesting an operation 
and it being initiated 
@payara_fish
1Gb Ethernet : 25 – 30MB/s 
10Gb Ethernet : 250 – 350MB/s 
Infiniband : 6GB/s (maybe) 
@payara_fish
PING TIMES 
Local : 57μs 
LAN segment : 300μs 
LAN: switches : 4ms 
UK : 30ms 
USA : 100ms 
3G : 100s ms 
@payara_fish
@payara_fish 
Spinning Rust 
Source: tomshardware.com 
Typical SSD Speed 
540MB/s 
Disk BUS Speeds 
SATA 1.0 : 150MB/s 
SATA 2.0 : 300MB/s 
SATA 3.0 : 600MB/s 
SAS : 600MB/s 
Fibre Channel : 1GB/s 
Infiniband : 1GB/s
@payara_fish 
DDR3 1600 : 12.8GB/s
@payara_fish
@payara_fish 
Caching Concepts 
Caching 
Provider 
Cache 
Manager 
Cache 
Entry 
Key 
Value
@payara_fish 
Core Concepts 
• CachingProvider 
– Retrieves and closes Cache Managers 
• CacheManager 
– Creates and destroys caches 
• Cache 
– Contains Objects in Key Value Pairs
@payara_fish 
Simple Cache Code Architecture 
Coherence 
Cache Node 
(Simple Code) 
Coherence 
Cache Node 
(Get Example) 
Coherence 
Cache Node 
(Put Example) 
Stock
@payara_fish 
Code Interlude
CachingProvider cp = Caching.getCachingProvider(); 
@payara_fish 
CacheManager cm = cp.getCacheManager(); 
MutableConfiguration<String, Stock> config 
= new MutableConfiguration<>(); 
config.setStoreByValue(true) 
.setTypes(String.class,Stock.class) 
.setManagementEnabled(true) 
.setStatisticsEnabled(true); 
Cache<String, Stock> cache = cm.createCache("J12014", 
config); 
System.out.println(cache.get("PAYA"));
@payara_fish 
Further Cache Methods 
cache.replace("PAYA",new Stock(28.0,"PAYA"); 
cache.remove(“PAYA”); 
stock = cache.getAndPut("PAYA", new 
Stock(27.0,"PAYA")); 
stock = cache.getAndReplace("PAYA",new 
Stock(28.0,"PAYA")); 
stock = cache.getAndRemove("PAYA"); 
cache.putIfAbsent("PAYA", stock);
@payara_fish 
Events
@payara_fish 
Core Concepts Events 
• CacheEntryListener 
– Receives Events relating to specific Keys 
– Subinterfaces for Created, Expired, 
Updated, Removed 
• CacheEntryEventFilter 
– Filters Events Before Delivery 
– Useful in distributed caches
@payara_fish 
Events API 
Coherence 
Cache Node 
(Simple Code) 
Coherence 
Cache Node 
(Stock Ticker) 
Coherence 
Cache Node 
(PriceTicker) 
Listener Stock
@payara_fish 
Code Interlude
CachingProvider cp = Caching.getCachingProvider(); 
CacheManager cm = cp.getCacheManager(); 
MutableConfiguration<String, Stock> config 
@payara_fish 
= new MutableConfiguration<>(); 
config.setStoreByValue(true) 
.setTypes(String.class, Stock.class) 
.setManagementEnabled(true). 
setStatisticsEnabled(true); 
Cache<String, Stock> cache = cm.createCache("J12014", 
config); 
while (true) { 
cache.put("PAYA", new Stock(Math.random() * 
20.0d, "PAYA")); 
Thread.sleep(1000); 
}
@payara_fish 
public class StockListener implements 
CacheEntryUpdatedListener<>, Serializable{ 
@Override 
public void onUpdated(Iterable<> itrbl) throws 
CacheEntryListenerException 
{ 
Iterator<CacheEntryEvent<> i = itrbl.iterator(); 
while (i.hasNext()) { 
System.out.println(i.next().getValue()); 
} 
} 
}
MutableCacheEntryListenerConfiguration<> lConf 
@payara_fish 
= new 
MutableCacheEntryListenerConfiguration<>( 
FactoryBuilder.factoryOf(new StockListener()), 
null, false, false); 
cache.registerCacheEntryListener(lConf); 
while (true) { 
Thread.sleep(1000); 
}
@payara_fish 
Listerner Interfaces 
• CacheEntryCreatedListener<K,V> 
– onCreated() 
• CacheEntryExpiredListener<K,V> 
– onExpired() 
• CacheEntryRemovedListener<K,V> 
– onRemoved() 
• CacheEntryUpdatedListener<K,V> 
– onUpdated()
@payara_fish 
Listener semantics 
• Are fired after the entry is mutated in the cache 
• if synchronous are fired, for a given key, in the order 
that events occur 
• block the calling thread until the listener returns, 
where the listener was registered as synchronous 
• that are asynchronous iterate through multiple 
events with an undefined ordering, except that 
events on the same key are in the order that the 
events occur.
@payara_fish 
Events Demo 
http://demo.c2b2.co.uk:7080/
@payara_fish 
Compute!
@payara_fish 
Compute Architecture 
Coherence 
Cache Node 
(Simple Code) 
Coherence 
Cache Node 
(Simple Code) 
StoScktockStocSktock StoScktockStocSktock 
Coherence 
Cache Node 
(Revalue) 
Entry 
Processor 
Entry 
Processor 
Coherence 
Cache Node 
(FindStock)
@payara_fish 
Key Cache Methods 
• invoke(Key,EntryProcessor,args) 
• invokeAll(Set<Key>,EntryProcessor,args) 
• Entry Processor Interface 
T process(MutableEntry<K,V>,Object … args)
@payara_fish 
Code Interlude
public class PrintStock implements 
EntryProcessor<String, Stock, String>, Serializable 
{ 
@Override 
public String process(MutableEntry<String, Stock> 
me, Object... os) throws EntryProcessorException 
@payara_fish 
{ 
System.out.println(me.getValue() + " IS HERE 
........... "); 
return null; 
} 
}
CachingProvider cp = Caching.getCachingProvider(); 
@payara_fish 
CacheManager cm = cp.getCacheManager(); 
MutableConfiguration<String,Stock> config = 
new MutableConfiguration<>(); 
config.setStoreByValue(true) 
.setTypes(String.class,Stock.class) 
.setManagementEnabled(true) 
.setStatisticsEnabled(true); 
Cache<String,Stock> cache = 
cm.createCache("J12014",config); 
cache.invoke("PAYA", new PrintStock());
@payara_fish 
Other JSR107 Features 
• Cache Loader and Cache Writers 
– Implements Read through and write 
through caching for persistence stores 
• Statistics 
– JMX Statistics (demo) 
• CDI Integration 
– Annotations for automatic cache 
interactions
@payara_fish 
CacheLoader and CacheWriter 
• Integrate with external resource 
– JPA Caching 
– Memcached integration 
– NoSQL integration 
• Provide read through and write 
through capability
@payara_fish 
CacheLoader and CacheWriter 
• CacheLoader for read through 
– load(Key) 
– loadAll(Iterable<Key>) 
– Added to Cache Configuration 
• CacheWriter for write through 
– write, writeAll 
– delete, deleteAll 
– Added to Cache Configuration
@payara_fish 
JSR 107 Annotations 
• @CacheDefaults 
• @CacheResult 
• @CachePut 
• @CacheRemove 
• @CacheRemoveAll
@payara_fish 
Example Annotations 
package my.app; 
@CacheDefaults(cacheName="domainCache") 
public class DomainDao { 
@CacheResult 
public Domain getDomain(String domainId, int index) { 
... 
} 
@CacheRemove 
public void deleteDomain(String domainId, int index) { 
... 
} 
@CacheResult(cacheName="allDomains") 
public List<Domain> getAllDomains() { 
... 
} 
}
@payara_fish 
Example Annotations 
package my.app; 
public class DomainDao { 
@CachePut(cacheName="domainCache") 
public void updateDomain(String domainId, int index, 
@CacheValue Domain 
domain) { 
... 
} 
}
@payara_fish 
Learn More 
• https://jcp.org/en/jsr/detail?id=107 
• https://github.com/jsr107 
• https://groups.google.com/forum/#!foru 
m/jsr107
@payara_fish

Contenu connexe

Tendances

MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
Boxed Ice
 
Memcached Presentation @757rb
Memcached Presentation @757rbMemcached Presentation @757rb
Memcached Presentation @757rb
Ken Collins
 
Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...
Odoo
 

Tendances (20)

Common scenarios in vcl
Common scenarios in vclCommon scenarios in vcl
Common scenarios in vcl
 
Caching and tuning fun for high scalability
Caching and tuning fun for high scalabilityCaching and tuning fun for high scalability
Caching and tuning fun for high scalability
 
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDBMongoUK 2011 - Rplacing RabbitMQ with MongoDB
MongoUK 2011 - Rplacing RabbitMQ with MongoDB
 
Beyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the codeBeyond PHP - It's not (just) about the code
Beyond PHP - It's not (just) about the code
 
MongoDB Tokyo - Monitoring and Queueing
MongoDB Tokyo - Monitoring and QueueingMongoDB Tokyo - Monitoring and Queueing
MongoDB Tokyo - Monitoring and Queueing
 
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
DevOpsDays Warsaw 2015: Running High Performance And Fault Tolerant Elasticse...
 
C* Summit EU 2013: Cassandra Internals
C* Summit EU 2013: Cassandra Internals C* Summit EU 2013: Cassandra Internals
C* Summit EU 2013: Cassandra Internals
 
Beyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the codeBeyond PHP - it's not (just) about the code
Beyond PHP - it's not (just) about the code
 
MongoDB - Monitoring & queueing
MongoDB - Monitoring & queueingMongoDB - Monitoring & queueing
MongoDB - Monitoring & queueing
 
Replication MongoDB Days 2013
Replication MongoDB Days 2013Replication MongoDB Days 2013
Replication MongoDB Days 2013
 
Cassandra
CassandraCassandra
Cassandra
 
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
Java и Linux — особенности эксплуатации / Алексей Рагозин (Дойче Банк)
 
Memcached Presentation @757rb
Memcached Presentation @757rbMemcached Presentation @757rb
Memcached Presentation @757rb
 
Prometheus Storage
Prometheus StoragePrometheus Storage
Prometheus Storage
 
BATTLESTAR GALACTICA : Saison 5 - Les Cylons passent dans le cloud avec Vert....
BATTLESTAR GALACTICA : Saison 5 - Les Cylons passent dans le cloud avec Vert....BATTLESTAR GALACTICA : Saison 5 - Les Cylons passent dans le cloud avec Vert....
BATTLESTAR GALACTICA : Saison 5 - Les Cylons passent dans le cloud avec Vert....
 
How Secure Are Docker Containers?
How Secure Are Docker Containers?How Secure Are Docker Containers?
How Secure Are Docker Containers?
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebBDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
 
Advanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMXAdvanced Apache Cassandra Operations with JMX
Advanced Apache Cassandra Operations with JMX
 
Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...Tips on how to improve the performance of your custom modules for high volume...
Tips on how to improve the performance of your custom modules for high volume...
 
Go Programming Patterns
Go Programming PatternsGo Programming Patterns
Go Programming Patterns
 

Similaire à Jsr107 come, code, cache, compute!

Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Tom Diederich
 

Similaire à Jsr107 come, code, cache, compute! (20)

Gimme Caching - The JCache Way
Gimme Caching - The JCache WayGimme Caching - The JCache Way
Gimme Caching - The JCache Way
 
Scalable Integration with JBoss Fuse
Scalable Integration with JBoss FuseScalable Integration with JBoss Fuse
Scalable Integration with JBoss Fuse
 
Cache is King: Get the Most Bang for Your Buck From Ruby
Cache is King: Get the Most Bang for Your Buck From RubyCache is King: Get the Most Bang for Your Buck From Ruby
Cache is King: Get the Most Bang for Your Buck From Ruby
 
Simplifying Apache Cascading
Simplifying Apache CascadingSimplifying Apache Cascading
Simplifying Apache Cascading
 
Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19Kick your database_to_the_curb_reston_08_27_19
Kick your database_to_the_curb_reston_08_27_19
 
Think Distributed: The Hazelcast Way
Think Distributed: The Hazelcast WayThink Distributed: The Hazelcast Way
Think Distributed: The Hazelcast Way
 
Distributed caching and computing v3.7
Distributed caching and computing v3.7Distributed caching and computing v3.7
Distributed caching and computing v3.7
 
Scaling Your Cache
Scaling Your CacheScaling Your Cache
Scaling Your Cache
 
Apache Spark Structured Streaming + Apache Kafka = ♡
Apache Spark Structured Streaming + Apache Kafka = ♡Apache Spark Structured Streaming + Apache Kafka = ♡
Apache Spark Structured Streaming + Apache Kafka = ♡
 
mysqlnd query cache plugin: user-defined storage handler
mysqlnd query cache plugin: user-defined storage handlermysqlnd query cache plugin: user-defined storage handler
mysqlnd query cache plugin: user-defined storage handler
 
Speed Things Up with Transients
Speed Things Up with TransientsSpeed Things Up with Transients
Speed Things Up with Transients
 
Kafka Streams: the easiest way to start with stream processing
Kafka Streams: the easiest way to start with stream processingKafka Streams: the easiest way to start with stream processing
Kafka Streams: the easiest way to start with stream processing
 
Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)Ingesting streaming data for analysis in apache ignite (stream sets theme)
Ingesting streaming data for analysis in apache ignite (stream sets theme)
 
Python在豆瓣的应用
Python在豆瓣的应用Python在豆瓣的应用
Python在豆瓣的应用
 
Non-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.jsNon-blocking I/O, Event loops and node.js
Non-blocking I/O, Event loops and node.js
 
Hadoop Integration in Cassandra
Hadoop Integration in CassandraHadoop Integration in Cassandra
Hadoop Integration in Cassandra
 
Scaling with Python: SF Python Meetup, September 2017
Scaling with Python: SF Python Meetup, September 2017Scaling with Python: SF Python Meetup, September 2017
Scaling with Python: SF Python Meetup, September 2017
 
High performance java ee with j cache and cdi
High performance java ee with j cache and cdiHigh performance java ee with j cache and cdi
High performance java ee with j cache and cdi
 
Java In-Process Caching - Performance, Progress and Pittfalls
Java In-Process Caching - Performance, Progress and PittfallsJava In-Process Caching - Performance, Progress and Pittfalls
Java In-Process Caching - Performance, Progress and Pittfalls
 
Java In-Process Caching - Performance, Progress and Pitfalls
Java In-Process Caching - Performance, Progress and PitfallsJava In-Process Caching - Performance, Progress and Pitfalls
Java In-Process Caching - Performance, Progress and Pitfalls
 

Plus de C2B2 Consulting

Through the JMX Window
Through the JMX WindowThrough the JMX Window
Through the JMX Window
C2B2 Consulting
 
Through the JMX Window
Through the JMX WindowThrough the JMX Window
Through the JMX Window
C2B2 Consulting
 

Plus de C2B2 Consulting (20)

Monitoring Oracle SOA Suite - UKOUG Tech15 2015
Monitoring Oracle SOA Suite - UKOUG Tech15 2015Monitoring Oracle SOA Suite - UKOUG Tech15 2015
Monitoring Oracle SOA Suite - UKOUG Tech15 2015
 
Hands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx PolandHands-on Performance Tuning Lab - Devoxx Poland
Hands-on Performance Tuning Lab - Devoxx Poland
 
Monitoring Oracle SOA Suite
Monitoring Oracle SOA SuiteMonitoring Oracle SOA Suite
Monitoring Oracle SOA Suite
 
Advanced queries on the Infinispan Data Grid
Advanced queries on the Infinispan Data Grid Advanced queries on the Infinispan Data Grid
Advanced queries on the Infinispan Data Grid
 
Through the JMX Window
Through the JMX WindowThrough the JMX Window
Through the JMX Window
 
Building WebLogic Domains With WLST
Building WebLogic Domains With WLSTBuilding WebLogic Domains With WLST
Building WebLogic Domains With WLST
 
Hands-on Performance Workshop - The science of performance
Hands-on Performance Workshop - The science of performanceHands-on Performance Workshop - The science of performance
Hands-on Performance Workshop - The science of performance
 
JBoss Clustering on OpenShift
JBoss Clustering on OpenShiftJBoss Clustering on OpenShift
JBoss Clustering on OpenShift
 
Dr. Low Latency or: How I Learned to Stop Worrying about Pauses and Love the ...
Dr. Low Latency or: How I Learned to Stop Worrying about Pauses and Love the ...Dr. Low Latency or: How I Learned to Stop Worrying about Pauses and Love the ...
Dr. Low Latency or: How I Learned to Stop Worrying about Pauses and Love the ...
 
Through the JMX Window
Through the JMX WindowThrough the JMX Window
Through the JMX Window
 
Oracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at Scale
Oracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at ScaleOracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at Scale
Oracle Coherence & WebLogic 12c Web Sockets: Delivering Real Time Push at Scale
 
Java Middleware Surgery
Java Middleware Surgery Java Middleware Surgery
Java Middleware Surgery
 
Jax London 2013
Jax London 2013Jax London 2013
Jax London 2013
 
Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...
Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...
Oracle SOA Suite Performance Tuning- UKOUG Application Server & Middleware SI...
 
'Deploying with GlassFish & Docker'
'Deploying with GlassFish & Docker' 'Deploying with GlassFish & Docker'
'Deploying with GlassFish & Docker'
 
'JMS @ Data Grid? Hacking the Glassfish messaging for fun & profit'
'JMS @ Data Grid? Hacking the Glassfish messaging for fun & profit' 'JMS @ Data Grid? Hacking the Glassfish messaging for fun & profit'
'JMS @ Data Grid? Hacking the Glassfish messaging for fun & profit'
 
'New JMS features in GlassFish 4.0' by Nigel Deakin
'New JMS features in GlassFish 4.0' by Nigel Deakin'New JMS features in GlassFish 4.0' by Nigel Deakin
'New JMS features in GlassFish 4.0' by Nigel Deakin
 
Coherence sig-nfr-web-tier-scaling-using-coherence-web
Coherence sig-nfr-web-tier-scaling-using-coherence-webCoherence sig-nfr-web-tier-scaling-using-coherence-web
Coherence sig-nfr-web-tier-scaling-using-coherence-web
 
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at ScaleJUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
JUDCon 2013- JBoss Data Grid and WebSockets: Delivering Real Time Push at Scale
 
GeeCon- 'www.NoSQL.com' by Mark Addy
GeeCon- 'www.NoSQL.com' by Mark Addy GeeCon- 'www.NoSQL.com' by Mark Addy
GeeCon- 'www.NoSQL.com' by Mark Addy
 

Dernier

%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Dernier (20)

Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

Jsr107 come, code, cache, compute!

  • 1. @payara_fish JSR107 Come, Code, Cache, Compute! Steve Millidge
  • 2. @payara_fish Agenda • Basic Caching – Cache API – Cache Configuration • Cache Events • Cache Computations
  • 3. @payara_fish What is JSR107? JCACHE JavaTM Temporary Caching API
  • 4. Time delay in requesting an operation and it being initiated @payara_fish
  • 5. 1Gb Ethernet : 25 – 30MB/s 10Gb Ethernet : 250 – 350MB/s Infiniband : 6GB/s (maybe) @payara_fish
  • 6. PING TIMES Local : 57μs LAN segment : 300μs LAN: switches : 4ms UK : 30ms USA : 100ms 3G : 100s ms @payara_fish
  • 7. @payara_fish Spinning Rust Source: tomshardware.com Typical SSD Speed 540MB/s Disk BUS Speeds SATA 1.0 : 150MB/s SATA 2.0 : 300MB/s SATA 3.0 : 600MB/s SAS : 600MB/s Fibre Channel : 1GB/s Infiniband : 1GB/s
  • 10. @payara_fish Caching Concepts Caching Provider Cache Manager Cache Entry Key Value
  • 11. @payara_fish Core Concepts • CachingProvider – Retrieves and closes Cache Managers • CacheManager – Creates and destroys caches • Cache – Contains Objects in Key Value Pairs
  • 12. @payara_fish Simple Cache Code Architecture Coherence Cache Node (Simple Code) Coherence Cache Node (Get Example) Coherence Cache Node (Put Example) Stock
  • 14. CachingProvider cp = Caching.getCachingProvider(); @payara_fish CacheManager cm = cp.getCacheManager(); MutableConfiguration<String, Stock> config = new MutableConfiguration<>(); config.setStoreByValue(true) .setTypes(String.class,Stock.class) .setManagementEnabled(true) .setStatisticsEnabled(true); Cache<String, Stock> cache = cm.createCache("J12014", config); System.out.println(cache.get("PAYA"));
  • 15. @payara_fish Further Cache Methods cache.replace("PAYA",new Stock(28.0,"PAYA"); cache.remove(“PAYA”); stock = cache.getAndPut("PAYA", new Stock(27.0,"PAYA")); stock = cache.getAndReplace("PAYA",new Stock(28.0,"PAYA")); stock = cache.getAndRemove("PAYA"); cache.putIfAbsent("PAYA", stock);
  • 17. @payara_fish Core Concepts Events • CacheEntryListener – Receives Events relating to specific Keys – Subinterfaces for Created, Expired, Updated, Removed • CacheEntryEventFilter – Filters Events Before Delivery – Useful in distributed caches
  • 18. @payara_fish Events API Coherence Cache Node (Simple Code) Coherence Cache Node (Stock Ticker) Coherence Cache Node (PriceTicker) Listener Stock
  • 20. CachingProvider cp = Caching.getCachingProvider(); CacheManager cm = cp.getCacheManager(); MutableConfiguration<String, Stock> config @payara_fish = new MutableConfiguration<>(); config.setStoreByValue(true) .setTypes(String.class, Stock.class) .setManagementEnabled(true). setStatisticsEnabled(true); Cache<String, Stock> cache = cm.createCache("J12014", config); while (true) { cache.put("PAYA", new Stock(Math.random() * 20.0d, "PAYA")); Thread.sleep(1000); }
  • 21. @payara_fish public class StockListener implements CacheEntryUpdatedListener<>, Serializable{ @Override public void onUpdated(Iterable<> itrbl) throws CacheEntryListenerException { Iterator<CacheEntryEvent<> i = itrbl.iterator(); while (i.hasNext()) { System.out.println(i.next().getValue()); } } }
  • 22. MutableCacheEntryListenerConfiguration<> lConf @payara_fish = new MutableCacheEntryListenerConfiguration<>( FactoryBuilder.factoryOf(new StockListener()), null, false, false); cache.registerCacheEntryListener(lConf); while (true) { Thread.sleep(1000); }
  • 23. @payara_fish Listerner Interfaces • CacheEntryCreatedListener<K,V> – onCreated() • CacheEntryExpiredListener<K,V> – onExpired() • CacheEntryRemovedListener<K,V> – onRemoved() • CacheEntryUpdatedListener<K,V> – onUpdated()
  • 24. @payara_fish Listener semantics • Are fired after the entry is mutated in the cache • if synchronous are fired, for a given key, in the order that events occur • block the calling thread until the listener returns, where the listener was registered as synchronous • that are asynchronous iterate through multiple events with an undefined ordering, except that events on the same key are in the order that the events occur.
  • 25. @payara_fish Events Demo http://demo.c2b2.co.uk:7080/
  • 27. @payara_fish Compute Architecture Coherence Cache Node (Simple Code) Coherence Cache Node (Simple Code) StoScktockStocSktock StoScktockStocSktock Coherence Cache Node (Revalue) Entry Processor Entry Processor Coherence Cache Node (FindStock)
  • 28. @payara_fish Key Cache Methods • invoke(Key,EntryProcessor,args) • invokeAll(Set<Key>,EntryProcessor,args) • Entry Processor Interface T process(MutableEntry<K,V>,Object … args)
  • 30. public class PrintStock implements EntryProcessor<String, Stock, String>, Serializable { @Override public String process(MutableEntry<String, Stock> me, Object... os) throws EntryProcessorException @payara_fish { System.out.println(me.getValue() + " IS HERE ........... "); return null; } }
  • 31. CachingProvider cp = Caching.getCachingProvider(); @payara_fish CacheManager cm = cp.getCacheManager(); MutableConfiguration<String,Stock> config = new MutableConfiguration<>(); config.setStoreByValue(true) .setTypes(String.class,Stock.class) .setManagementEnabled(true) .setStatisticsEnabled(true); Cache<String,Stock> cache = cm.createCache("J12014",config); cache.invoke("PAYA", new PrintStock());
  • 32. @payara_fish Other JSR107 Features • Cache Loader and Cache Writers – Implements Read through and write through caching for persistence stores • Statistics – JMX Statistics (demo) • CDI Integration – Annotations for automatic cache interactions
  • 33. @payara_fish CacheLoader and CacheWriter • Integrate with external resource – JPA Caching – Memcached integration – NoSQL integration • Provide read through and write through capability
  • 34. @payara_fish CacheLoader and CacheWriter • CacheLoader for read through – load(Key) – loadAll(Iterable<Key>) – Added to Cache Configuration • CacheWriter for write through – write, writeAll – delete, deleteAll – Added to Cache Configuration
  • 35. @payara_fish JSR 107 Annotations • @CacheDefaults • @CacheResult • @CachePut • @CacheRemove • @CacheRemoveAll
  • 36. @payara_fish Example Annotations package my.app; @CacheDefaults(cacheName="domainCache") public class DomainDao { @CacheResult public Domain getDomain(String domainId, int index) { ... } @CacheRemove public void deleteDomain(String domainId, int index) { ... } @CacheResult(cacheName="allDomains") public List<Domain> getAllDomains() { ... } }
  • 37. @payara_fish Example Annotations package my.app; public class DomainDao { @CachePut(cacheName="domainCache") public void updateDomain(String domainId, int index, @CacheValue Domain domain) { ... } }
  • 38. @payara_fish Learn More • https://jcp.org/en/jsr/detail?id=107 • https://github.com/jsr107 • https://groups.google.com/forum/#!foru m/jsr107