Sunday, 19 August 2007

Hidden gems in JBoss Cache 2.0.0.GA

JBoss Cache 2.0.0.GA is out and as you can see from Manik's last entry, we're already moving forward...and fast. Before JBoss Cache 2.0 is forgotten, let's have a quick glance at some hidden gems that came within it:

1.- Singleton Cache Store Functionality

Cache stores are backend stores for data handled within JBoss Cache. Until now, the main two strategies to configure these cache stores were:

  • sharing a cache store between all JBoss Cache instances.
  • each instance having its own cache store.
Each strategy has its own caveats. For example, what if an user wanted to use a file based shared cache store, but the file system (i.e. shared NFS) did not support concurrent access/updates to it? An alternative solution would have been to configure JBoss Cache so that for each instance to had its own cache store. However, the user would have gone from having to manage/maintain one cache store to having to maintain N cache stores. Singleton Cache Store functionality was designed and developed to respond to the demands of such end users.

When cache loaders, which interact with cache stores, are configured for singleton store, only the JBoss Cache instance in the coordinator of cluster interacts with the cache store. The rest of nodes replicate changes to the coordinator which is in charge of putting them in the store. When such coordinator leaves the cluster, or stops working, a new coordinator is elected which takes charge of communicating with the cache store. This allows for only one JBoss Cache instance to interact with the cache store at a time.

More information on Singleton Cache Store functionality and configuration options can be found in the JBoss Cache 2.0 documentation.

2.- Transforming Cache Loaders

In JBoss Cache 2.0, the format of the data stored in the File and JDBC cache loaders has been changed so that it uses the JBoss Cache marshaling framework, created to improve replication efficiency, to format data to be stored in these cache stores.

At JBoss, division of Red Hat, we think about our product's end users and when implementing such data format change, we realised that some of JBoss Cache's users might have populated cache stores in JBoss Cache 1.x format. Even though JBoss Cache 2.0 is a major release, we wanted to provide our a way to transform existing cache stores from 1.x format to 2.x format. Because of this, we created a set of one-off Transforming Cache Loaders whose job is:
  • read data from cache stores the way we did in JBoss Cache 1.x
  • write data to cache stores in JBoss Cache 2.x format.
Together with this, an example was created which recursively reads the contents of the cache store via these Transforming Cache Loaders, and stores the data read back into the cache store. Just run this example with the parameters of your cache loader and the entire cache store will be transformed.

The Transforming Cache Loaders, necessary libraries to understand JBoss Cache 1.x and example mentioned can be found within the JBoss Cache 2.0.0.GA distribution ZIP file that can be downloaded from here.

More information on Transforming Cache Loaders can be found in the JBoss Cache 2.0 documentation.

No comments: