1 Reply Latest reply on Jun 8, 2007 5:55 AM by Manik Surtani

    Recipe for serial read ?

    Yuri Ushakov Newbie


      I can't seem to find a way to do serial reading, is there a commonly known solution for it?

      In particular, I need to run a certain process in scope of cluster, but only one JVM should run it. For this I have a node /status, it has key "active" whose value is either "true" or "false". When JVMs start, each checks for the "active" flag, and if it's false, they run the process. And for only one JVM to run, they need to wait on the read lock, otherwise all of them start the process, because they simultaneously read "false" from the node.

      I'm doing reading and writing within a DummyUserTransaction, and I tried multiple variations - pessimistic/serialisable, optimistic, etc - sooner or later there a case of mis-synchronisation on the cache data.

      Thanks for any tips,

        • 1. Re: Recipe for serial read ?
          Manik Surtani Master

          We don't do distributed locks (mainly for performance reasons - athough as people have asked for it, we have it on the roadmap as a feature. http://jira.jboss.com/jira/browse/JBCACHE-1098)

          If you want to run a process as a singleton, you could test whether you are the cluster coordinator. Depending on which version of JBoss Cache you are using, you would need to get a hold of the JGroups channel and register a MembershipListener and listen for the viewChange event so you can update your status if the coordinator changes.