Sunday, September 5, 2010

Coherence multiple clusters in same jvm

The BIG question is: how can I connect to multiple clusters (different multicast/unicast addresses) from within the same JVM?

The answer I get from the experts is: only by having separate classloaders.

Which is not always easy to do, especially when you don't have control on the way your client is deployed and packaged. Like in OSB.


Hot google searches: IsolatingClassLoader, BlockingClassLoader

See this http://forums.oracle.com/forums/thread.jspa?threadID=929695
on multiple Coherence in same JVM


"all you need to do is ensure that Coherence is loaded by two independent class loaders and not from a common parent class loader."

This one also is very revealing

http://forums.oracle.com/forums/thread.jspa?threadID=586481

"They will of course be contained within separate web application class loaders."


More on the 2 caches here:
http://forums.oracle.com/forums/thread.jspa?threadID=587007

"You can define a path to the cache configuration descriptor in your operation configuration override file (tangosol-coherence=override.xml) or specify it in the system property "tangosol.coherence.cacheconfig"."


And here:

http://forums.oracle.com/forums/thread.jspa?threadID=1079608

It is possible to do what you ask but it comes with a whole set of issues that need to be worked around. We run multiple Coherence instances in a single JVM (usually something like 2 storage nodes, an extend proxy and a client) for unit/acceptance tests. This is done with a special implementation of a classloader so each Coherence instance runs isolated by its own classloader - in the same way that web applications all run isolated from eachother in a web container like Tomcat. A number of Coherence settings can be overriden using System properties and we have also implemented classloader aware system properties, so each of our Coherence instances has its own system properties related to the classloader that it is contained in.



Here a very pictorial view, going in depth in the concept of "Coherence Cluster Node Isolation"

http://wiki.tangosol.com/display/COH34UG/Cluster+Node+Isolation+in+Coherence*Web

2 comments:

Robert Varga said...

Hi Pierluigi,

you could take a look at the following page, I created a small library to make things a bit easier (outside of a container):

http://coherence.politext.info/multiple-coherence-nodes-in-a-jvm

vernetto said...

hello Robert,
thank you very much for your valuable input.
I really wish I had some time to cooperate with you on Coherence, it would be nice to have some open source tools regarding Coherence.
It's a wonderful product, indeed.
I had the opportunity to work with Adam Korczak and Michal Stawowski and they taught me so much. Can you please send me your email so we can keep in touch?
Thanks!
Pierre