How to get correct state of cluster during plugin initialization

ClusterManager#isSeniorClusterMember method returns ‘true’ until the node in cluster receives ‘joinCluster’ event.

Scenario:

  • Custom built plugin name ‘cltest’ deployed with other Openfire plugins and HazelCast
  • cltest loads up. Its determining cluster status using ClusterManager.,isClusteringAvailable && ClusterManager.isSeniorClusterMemebr. This condition returns ‘true’ on all the nodes cluster until each node received ‘joinCluster’.

How to determine cluster state in this situation ?

The behaviour of ClusterManager#isSeniorClusterMember is probably as not as it should be - but given how long the API has been around it would be unwise to change it’s operation today.

With that in mind, ClusterManager.isSeniorClusterMemberOrNotClustered() is a new API that will wait until clustering has completed initialising and return an appropriate value. It’s been available since Openfire 4.3.0, i.e. for over 2 years now.

If you’re working with an older version of Openfire, I’d strongly recommend upgrading as there has been a lot of work done in improving the behaviour of clustering over the past years. If that is not possible for whatever reason, you could consider paying one of the Openfire professional partners listed at Ignite Realtime: Support - Professional Partners to retrofit ClusterManager.isSeniorClusterMemberOrNotClustered() to a new minor version of Openfire that you are using.

Greg