On 10 September 2010 15:08, Mats Henrikson <mats(a)zakalwe.com> wrote:
However, when the shunned host rejoins the cluster, whether the
cluster is SYNC or ASYNC, it is now possible that it has missed a
number of invalidation messages, and as a result may have stale data.
This is the problem I am trying to address.
Is there an alternative solution to this problem?
As I still haven't been able to find a solution to this I made my own,
and this is just a post that might help somebody else in the same
situation, or perhaps I might get some feedback from people more
familiar with JBossCache than me.
And I know this is a bit of a hack.
I changed my JBossCache-Hibernate 2nd level cache to
INVALIDATION_ASYNC, in order to avoid the ReplicationExceptions you
get on the alive nodes when there is an unresponsive node.
I then extended SharedJBossCacheRegionFactory (and configured
Hibernate to use that as the 2nd level cache class) and overrode the
start() method. In the start() method I called super.start(), followed
by getting the CacheInstanceManager, and used that to register as a
CacheListener for ViewChangedEvents. Once I get a suitable
ViewChangedEvent that suggests that the node has just rejoined the
cache cluster I can then clear my Hibernate 2nd level cache, ensuring
that the node has no stale data.
Mats