1. Persist and Replay Runtime Data
Using Apache Java Caching
System and Javassist
https://bitbucket.org/wishcoder/jcs.
marketdata.replay/wiki/Home
Ajay Singh | message4ajay@gmail.com | LinkedIn - https://www.linkedin.com/in/ajaysinghonline | Bitbucket - https://bitbucket.org/wishcoder
2. Persist and Replay Runtime Data
• The ability to persist data created at runtime is
useful when application states and data are
required to be replayed multiple times to
investigate application issues.
• This article demonstrates how to persist
runtime data to disk and load disk persisted
data to replay in new JVM instances.
Ajay Singh | message4ajay@gmail.com | LinkedIn - https://www.linkedin.com/in/ajaysinghonline | Bitbucket - https://bitbucket.org/wishcoder
3. Apache JCS and Javassist
• JCS is a distributed caching system written in
Java. Indexed Disk Auxiliary Cache is used to
persist data on disk. JCS only persist
Serializable java objects.
• Javassist (Java Programming Assistant) makes
Java bytecode manipulation simple. Javassist
is used to dynamically set values for transient
fields that are not persisted due to transient
nature.
Ajay Singh | message4ajay@gmail.com | LinkedIn - https://www.linkedin.com/in/ajaysinghonline | Bitbucket - https://bitbucket.org/wishcoder
7. Setup JCS - AUXILARY/DISK CACHE
props.put("jcs.auxiliary.DC", "org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory");
props.put("jcs.auxiliary.DC.attributes",
"org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes");
props.put("jcs.auxiliary.DC.attributes.DiskPath", “C:TradeCache”);
props.put("jcs.auxiliary.DC.attributes.MaxPurgatorySize", "10000000"); // 10000000
// If the maximum key size is less than 0, no limit will be placed on
// the number of keys. By default, the max key size is 5000.
props.put("jcs.auxiliary.DC.attributes.MaxKeySize", "-1");
// Use Thread Pool for disk operation
props.put("jcs.auxiliary.DC.attributes.EventQueueType", "POOLED");
props.put("jcs.auxiliary.DC.attributes.EventQueuePoolName", "disk_cache_event_queue");
// Disk Cache Event Queue Pool
props.put("thread_pool.disk_cache_event_queue.useBoundary", "false");
props.put("thread_pool.remote_cache_client.maximumPoolSize", "15");
props.put("thread_pool.disk_cache_event_queue.minimumPoolSize", "1");
props.put("thread_pool.disk_cache_event_queue.keepAliveTime", "3500");
props.put("thread_pool.disk_cache_event_queue.startUpSize", "1");
Ajay Singh | message4ajay@gmail.com | LinkedIn - https://www.linkedin.com/in/ajaysinghonline | Bitbucket - https://bitbucket.org/wishcoder
11. Javassist – Inject Transient Data
Javassist (Java Programming Assistant) makes
Java bytecode manipulation simple. Javassist is
used to dynamically set values for transient
fields that are not persisted due to transient
nature.
Ajay Singh | message4ajay@gmail.com | LinkedIn - https://www.linkedin.com/in/ajaysinghonline | Bitbucket - https://bitbucket.org/wishcoder
14. Javassist – Set Transient Data
• Read object from JCS Cache:
CompositeCacheManager ccm = CompositeCacheManager.getUnconfiguredInstance();
ccm.configure(props )
CacheAccess cCache = JCS.getInstance(“marketdata_cache”);
Object cachedObject = cCache.get(name);
• Initialize object that need to be injected in cached object
User user = new User(‘1’, ‘Name’);
• Inject Transient data in cached object
cachedObject = CacheReplayHelper.setNonSerializeSetter(cachedObject ,
"setSource", user );
Ajay Singh | message4ajay@gmail.com | LinkedIn - https://www.linkedin.com/in/ajaysinghonline | Bitbucket - https://bitbucket.org/wishcoder
15. Wiki and Source Repository
https://bitbucket.org/wishcoder/jcs.marketdata.replay/wiki/Home
Ajay Singh | message4ajay@gmail.com | LinkedIn - https://www.linkedin.com/in/ajaysinghonline | Bitbucket - https://bitbucket.org/wishcoder