"I do not recall distinctly when it began, but it was months ago."At my previous job I was given the following problem to consider: is it possible for a Java application (with just a single JVM) to connect to more than one Coherence cluster? In this context, the word "connect" means that the application actually joins the clusters in question, rather than simply works through a proxy such as provided by Coherence*Extend. I was able to determine that the answer was "yes", however the solution was not as straightforward as one might think. It's not possible to just load two Coherence instances into the JVM by calling a constructor with the necessary parameters, as Coherence makes extensive use of system properties and default configuration files in lieu of defining constructors for a client to call. In addition Coherence uses the Singleton pattern in conjuction with several key classes. That said, there is a solution and that's what this post is all about.
"Nyarlathotep" - H.P. Lovecraft
Code is not dead if it can still compile,
And with strange rework its death may yield style.
(with apologies to H.P. Lovecraft)
Random thoughts on Java and coding in general.
Showing posts with label Coherence. Show all posts
Showing posts with label Coherence. Show all posts
Wednesday, May 18, 2011
Joining Multiple Coherence Clusters
Thursday, October 28, 2010
Coherence: One thread is not enough!
It surprised me no end to find out that the when using a Distributed Cache for Coherence, the default number of daemon threads used to process incoming requests was zero, meaning that all work is performed on the service thread for that cache. This will make a major impact when you are using a cache to handle a large number of concurrent requests. Fortunately, it's not hard to fix this.
You inform me, that no Part must be missing if the finest Effects are to be had, but you can not but know how hard it is to be sure.
- "The Case of Charles Dexter Ward", H.P. Lovecraft
Tuesday, September 21, 2010
Coherence: when the key is not the whole key
Yog-Sothoth is the key and guardian of the gate. Past, present, future, all are one in Yog-Sothoth. He knows where the Old Ones broke through of old, and where They shall break through again.Recently at work I was involved in implementing a distributed cache with Coherence to improve performance with a third party web service. Integrating the call to the web service with the cache was not difficult, however I did encounter a twist in that calls to the web service required information which, while tracked by that service, did not in any way affect the result we got back from the service. In other words, only part of the key was needed to correctly retrieve a value from the cache, however all of the key was needed to create the value to add to the cache.
- "The Dunwich Horror", H.P. Lovecraft
My first thought was that this would be simple to deal with since all Coherence caches are ultimately just extensions of
java.util.Map. If we defined the equals and hashCode methods using just the properties relevant to retrieving items from the cache we could have the best of both worlds: the data would be present when needed to call the external web service and the cache would not include redundant entries. However this did not work, and the particulars of why and what I did to fix things are the topics for this post.
Subscribe to:
Posts (Atom)