JBoss Cache Affinity Split Example.
| Information Note that although this example works with JBoss Cache 2.x.x, GridGain Affinity Load Balancing works with any cache. You can even use it without cache, if you just need to guarantee stickiness of jobs. JBoss Cache is picked just for demonstration purpose here. |
This example demonstrates usage of GridGain together with JBoss Cache 2.x.x. It shows how with GridGain and JBoss Cache you can co-locate data access with your processing logic.
Since JBoss cache does not give you any way to know where your data are located (on which node in cache) we used consistent hashing algorithm to support it. The basic idea behind the consistent hashing algorithm is to hash both objects and caches using the same hash function. The reason to do this is to map the cache to an interval, which will contain a number of object hashes. If the cache is removed then its interval is taken over by a cache with an adjacent interval. All the other caches remain unchanged.
See http://weblogs.java.net/blog/tomwhite/archive/2007/11/consistent_hash.html
for additional details.
You can find this example at ${GRIDGAIN_HOME}/examples/jbosscache/src folder in package org.gridgain.examples.jbosscache. Source code is fully Javadoc-ed and you can find the examples' Javadoc at ${GRIDGAIN_HOME}/examples/javadoc folder.
Package:
org.gridgain.examples.jbosscache
| Class | Description |
|---|---|
| GridJbossCacheExample.java | This is main class in this example. It basically starts grid locally (local node) and executes task that maps jobs to the nodes according to used data keys. |
| GridJbossCacheExampleTask.java | This class represents all the logic necessary for split into jobs and map them to the proper cache node. There are two methods in this class responsible for splitting method invocation into multiple sub-calls and aggregating results back from splits. |
| GridJbossCacheManager.java | It is a simple convenience wrapper around JBoss Cache API. |
| GridJbossCacheExampleNodeLoader.java | Grid node startup class for JBoss Cache example. This class starts JBoss Cache and GridGain node. |
This example is working with JBoss Cache 2.x.x. Example that is working with JBoss Cache 3.x.x will be available at new release, but you can find short description how to run current example with JBoss Cache 3.x.x. here - Affinity MapReduce with JBoss Cache 3.x.x
