Current Carbon-Kernel v4.4.0 caching is based on JCache v0.5. This Blog is about new JSR107 (JCache) v1.0 update in Carbon-Kernel based on new Hazelcast caching provider.
Topics
What is JCache
Whats in latest JSR107 (JCache) in high level view
WSO2 Caching
New caching API changes in WSO2 Caching
Examples of new caching API
What is JCache ?
Caching is proven method to increase scalability and performance. JCache (JSR 107) is a standard caching API for Java. It can keeps some data in low-latency data structures for some period.It provides an API to create and work with in-memory cache of objects. It allows to create, access, update and remove entries from caches.JCache API only provides set of high level components (interfaces) to work with caching other than thinking about the implementation of the caching
Some common use cases
Client side caching of Web service calls
Caching of expensive computations such as rendered images
Caching of data
Servlet response caching
Caching of domain object graphs
Latest JSR107 (JCache) in high level view
Caching Provider – used to control Caching Managers and can deal with several of them, Cache Manager – deals with create, read, destroy operations on a Cache Cache – stores entries (the actual data) and exposes CRUD interfaces to deal with the entries Entry – abstraction on top of a key-value pair akin to a java.util.Map
WSO2 Caching
Core Features
Local and distributed mode
L1 and L2 caching model for distributed mode
Multi-tenancy
Local and distributed mode: carbon kernel has 2 different jcache implementations called local and distributed, default it use local cache when the Axis2 clustering is enabled it use distributed cache.In jcache v0.5 for distributed map carbon-kernel used Hazelcast distributed maps but in new jcache v1.0 for distributed cache it use Hazelcast caches.
L1 and L2 caching model for distributed mode: In order to improve performance there are 2 types of caching models called L1(Level 1) and L2(Level 2) caching, L1 cache is implemented by HashMaps, and new L2 cache is implemented by Hazelcast cache (wrapper of jcache v1.0 API).Every first time it checks in L1 cache but if the value is located in the L2 cache, then the value is also stored in the L1 cache
Multi-tenancy: It can cache and provide tenant specific data and make it available in every and each cluster members.
Sequence diagram of L1 and L2 caching model
In the distributed mode, if a cache entry is removed, invalidated or changed then the Hazelcast Cache Entry listeners that registered will trigger on each and every Hazelcast cluster member, In that same time L1 cache and the L2 cache being removed or updated
Sequence diagram of remove item
New caching API changes in WSO2 Caching
In previous jcache version, to create a CacheManager object had to call CacheManagerFactory and parse the name to CacheManager
To create a custom cache with custom configuration no need to call createCacheBuilder() to and parse the configuraion object, now CacheManager can directly call getCache() by parsing a cacheName and CacheConfiguration object
Other than that the org.wso2.carbon.caching.impl.CacheImpl class distributedCache is changed to Hazelcast cache (v4.3) insted of using Hazelcast Maps
Because the Hazelcast cache is distrbuted one, There's no need of having registered OSGI service called DistributedMapProvider so the service intarface has removed from the org.wso2.carbon.caching and also from the org.wso2.carbon.core.clustering.HazelcastDistributedMapProvider
Other API changes are done to
org.wso2.carbon.user.core
org.wso2.carbon.registry.core
Examples of new caching API
Example: Simple cache creation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Example: Using cache configuration with a custom cache expiry
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Copy appropriate activemq jars to $CEP_HOME/repository/components/lib
If you are using activemq-5.9.1, above 5.8.x you cannot find activemq-core-x.x.jar now it has been split into two jars activemq-broker-5.x and activemq-client-5.x. In order to configure you only need these 3 jars to copied inside lib.
This is very use full for raspberry pi projects.Email temperature information, notify things when you not there.And the best thing is its really easy to configure.I'll go through step by step.
First thing is to install ssmtp.
sudo apt-get install ssmtp
Edit and add new configurations to ssmtp.conf file.
nano /etc/ssmtp/ssmtp.conf [add new line or change current lines ]
root=your.email@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
hostname=localhost
UseTLS=Yes
AuthUser=your.email
AuthPass=your.password
UseSTARTTLS=Yes
FromLineOverride=YES
ctrl+O [nano save]
ctrl+X [nano exit]
Install mailutils to send emails from terminal.
sudo apt-get install mailutils
Sending a test mail
echo "Email Body [Happy Coding]" | mail -s "Email Subject [Finally Done]" your.email@gmail.com
Possible errors and how to fix them.
mail: cannot send message: Process exited with a non-zero status
check the error log >> cat /var/log/mail.err or cat /var/log/mail.log
If its Authorization failed (xxxxxxxxxxxxxxxxxxxxxxxxxx)
I'm currently using Linux 3.13.0-24-generic x86_64 kernel version of linux mint with OpenGL version of 2.1 Mesa 10.1.0 follow this link to check OpenGL version [link]
You need to go through only three steps
Download OpenGL C++ libraries.
Setup and install eclipse CDT bundle.
Configure the eclipse libraries [simple].
Test OpenGL application.
Download OpenGL C++ dependencies
In terminal use sudo apt-get install libglu1-mesa-dev freeglut3-dev
Setup and install eclipse CDT bundle
In eclipse Help > Install New Software
Add new cdt installation path http://download.eclipse.org/tools/cdt/releases/8.5
Tick CDT Main Features hit next and finish the process and restart the eclipse