Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing a java object across a cluster

My requirement is to share a java object across a cluster.

I get Confused

  • whether to write an EJB and share the java objects across the cluster or
  • to use any third party such as infinispan or memecached or terracotta or
  • what about JCache?

with the constraint that

  • I can't change any of my source code with specific to any application server (such as implementing the weblogic's singleton services).
  • I can't offer two builds for cluster and non cluster environment.
  • Performance should not be downgraded.
  • I am looking for only open source third party if I need to use it.
  • It need to work in weblogic , Websphere , Jbos and Tomcat too.

Can any one come up with the best option with these constraints in mind.

like image 847
Dineshkumar Avatar asked Aug 07 '13 11:08

Dineshkumar


2 Answers

It can depend on the use case of the objects you want to share in the cluster.

I think it comes down to really the following options in most complex to least complex

Distributed cacheing http://www.ehcache.org

Distributed cacheing is good if you need to ensure that an object is accessible from a cache on every node. I have used ehache to distribute quite successfully, no need to setup a terracotta server unless you need the scale, can just point instances together via rmi. Also works synchronously and asynchronously depending on requirements. Also cache replication is handy if nodes go down so cache is actually redundant and dont lose anything. Good if you need to make sure that the object has been updated across all the nodes.

Clustered Execution/data distribution http://www.hazelcast.com/

Hazelcast is also a nice option as provides a way of executing java classes across a cluster. This is more useful if you have an object that represents a unit of work that needs to be performed and you dont care so much where it gets executed.

Also useful for distributed collections, i.e. a distributed map or queue

Roll your own RMI/Jgroups

Can write your own client/server but I think you will start to run into issues that the bigger frameworks solve if the requirements of the objects your dealing with starts to get complex. Realistically Hazelcast is really simple and should really eliminate the need to roll your own.

like image 93
vcetinick Avatar answered Oct 24 '22 07:10

vcetinick


It's not open source, but Oracle Coherence would easily solve this problem.

If you need an implementation of JCache, the only one that I'm aware of being available today is Oracle Coherence; see: http://docs.oracle.com/middleware/1213/coherence/develop-applications/jcache_part.htm

For the sake of full disclosure, I work at Oracle. The opinions and views expressed in this post are my own, and do not necessarily reflect the opinions or views of my employer.

like image 1
cpurdy Avatar answered Oct 24 '22 08:10

cpurdy