javaoracle-coherence

Programmatically determine Coherence master member


I need to run a piece of my java code by only one Coherence cluster member. So, I chose the master member for this. Is there an API to check out whether the current member is the master coordinator member? I am using Oracle Coherence 12.1.3-0-0


Solution

  • NamedCache cache = CacheFactory.getCache("cacheName");
    Cluster c = cache.getCacheService().getCluster();
    if (c.getLocalMember().equals(c.getOldestMember())) {
      //do the stuff
    }