Dynamic Distributed Data Clustering on OSGi
Join the DZone community and get the full member experience.Join For Free
If you’ve followed some of my past posts you’ll notice I try to keep my examples small and as simple as they need to be. If I were to describe my programming style its very much back to basics and I’m a huge proponent of simplicity.
I’ve whipped up a small example of how you can distribute data dynamically on OSGi using Hazelcast 1.4. I’ve really only scratched the surface of what you can do with this but thought I’d write up my first experiences with this light weight simple yet powerful framework.
Running the Example.
Download the cluster.zip example source code from:
Unzip the cluster.zip and start up 2 instances of eclipse 3.4. Open up the node01 and node02 directories in different instances of eclipse.
Click run light weight cluster in both instances of eclipse and Jetty should start up on port 9091 and 9092.
Open up two web browsers and in the first browser paste the following URL which will set cVal in a distributed Map on the first node.
In the second browser paste the following:
If you see the following you have successfully setup a dynamically distributed data cluster.
Where’s the magic?
If you have a look at SampleServlet.java the magic is on line 27 and 32 where we get the map and set a value. Hazelcast makes it look like we are dealing with an ordinary map but the reality is that it possesses extraordinary distributed capability.
If you have any questions on the demo feel free to drop me a line (email@example.com) or head on over to hazelcast.com.
Opinions expressed by DZone contributors are their own.