Class HazelcastClusterSafetyManager

java.lang.Object
com.atlassian.confluence.cluster.safety.AbstractClusterSafetyManager
com.atlassian.confluence.cluster.hazelcast.HazelcastClusterSafetyManager
All Implemented Interfaces:
ClusterSafetyManager

public class HazelcastClusterSafetyManager extends AbstractClusterSafetyManager
  • Field Details

    • SAFETY_MAP_PREFIX

      public static final String SAFETY_MAP_PREFIX
  • Constructor Details

  • Method Details

    • verify

      public void verify(long runIntervalMs)
      Description copied from interface: ClusterSafetyManager
      Ensures cluster is safe. If not, panic procedure is initiated.
      Specified by:
      verify in interface ClusterSafetyManager
      Overrides:
      verify in class AbstractClusterSafetyManager
    • shouldRun

      protected boolean shouldRun(List<String> members, String thisNode, long runIntervalMs)
      This job is created with "runOncePerCluster=false". It means that we invoke the job on every node once per timeout. The logic of this method decides which exactly node the task should be run on.

      In other words, this is like "runOncePerCluster=true", but with guarantee that eventually the task will be run on each node.

    • getSyncClusterTime

      protected long getSyncClusterTime()
    • getSeedFromTime

      protected long getSeedFromTime(long timeMs, long runIntervalMs)
    • onDatabaseNumberIsMissed

      protected void onDatabaseNumberIsMissed(@NonNull String lastCacheModifier, @NonNull Integer cacheSafetyNumber, int nextValue)
      Description copied from class: AbstractClusterSafetyManager
      Method is called when safety number is missed in database. By default it updates safety number in the cache and database.
      Overrides:
      onDatabaseNumberIsMissed in class AbstractClusterSafetyManager
      Parameters:
      lastCacheModifier - last cache modifier
      cacheSafetyNumber - safety number in cache
      nextValue - next safety number to put into the cache and database
    • onCacheNumberIsMissed

      protected void onCacheNumberIsMissed(@NonNull Integer dbSafetyNumber, int nextValue)
      Description copied from class: AbstractClusterSafetyManager
      Method is called when safety number is missed in cache. By default it updates safety number in the cache and database.
      Overrides:
      onCacheNumberIsMissed in class AbstractClusterSafetyManager
      Parameters:
      dbSafetyNumber - safety number in database
      nextValue - next safety number to put into the cache and database
    • onNumbersAreDifferent

      protected void onNumbersAreDifferent(@NonNull String lastCacheModifier, @NonNull Integer dbSafetyNumber, @NonNull Integer cacheSafetyNumber, int nextValue) throws ClusterPanicException
      Description copied from class: AbstractClusterSafetyManager
      Method is called when safety numbers in cache and database are not equal. By default this method throws ClusterPanicException to trigger cluster panic.
      Overrides:
      onNumbersAreDifferent in class AbstractClusterSafetyManager
      Parameters:
      lastCacheModifier - last cache modifier
      dbSafetyNumber - safety number in database
      cacheSafetyNumber - safety number in cache
      nextValue - next safety number to put into the cache and database
      Throws:
      ClusterPanicException - in a case if panic should be triggered
    • onNumbersAreEqual

      protected void onNumbersAreEqual(@NonNull String lastCacheModifier, @NonNull Integer dbSafetyNumber, @NonNull Integer cacheSafetyNumber, int nextValue)
      Description copied from class: AbstractClusterSafetyManager
      Method is called when safety numbers in cache and database are equal. By default it updates safety number in the cache and database.
      Overrides:
      onNumbersAreEqual in class AbstractClusterSafetyManager
      Parameters:
      lastCacheModifier - last cache modifier
      dbSafetyNumber - safety number in database
      cacheSafetyNumber - safety number in cache
      nextValue - next safety number to put into the cache and database
    • onNumbersMissed

      protected void onNumbersMissed(int nextValue)
      Description copied from class: AbstractClusterSafetyManager
      Method is called when safety numbers in cache and database are missed. By default it updates safety number in the cache and database.
      Overrides:
      onNumbersMissed in class AbstractClusterSafetyManager
      Parameters:
      nextValue - next safety number to put into the cache and database
    • handlePanic

      protected void handlePanic()
      Specified by:
      handlePanic in class AbstractClusterSafetyManager
    • logRuntimeInfo

      protected void logRuntimeInfo()
      Specified by:
      logRuntimeInfo in class AbstractClusterSafetyManager
    • getLogger

      protected org.slf4j.Logger getLogger()
      Specified by:
      getLogger in class AbstractClusterSafetyManager
    • getSafetyNumberMap

      protected com.hazelcast.map.IMap<String,Integer> getSafetyNumberMap()
      Specified by:
      getSafetyNumberMap in class AbstractClusterSafetyManager
    • getSafetyNumberModifierMap

      protected com.hazelcast.map.IMap<String,String> getSafetyNumberModifierMap()
      Specified by:
      getSafetyNumberModifierMap in class AbstractClusterSafetyManager
    • getNextValue

      protected int getNextValue()
      Overrides:
      getNextValue in class AbstractClusterSafetyManager
    • encodeClusterSize

      protected int encodeClusterSize(int nextValue)
    • decodeClusterSize

      protected int decodeClusterSize(int dbSafetyNumber)