Class HazelcastClusterSafetyManager

    • Field Detail

      • SAFETY_MAP_PREFIX

        public static final String SAFETY_MAP_PREFIX
    • Method Detail

      • 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
      • 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
      • encodeClusterSize

        protected int encodeClusterSize​(int nextValue)
      • decodeClusterSize

        protected int decodeClusterSize​(int dbSafetyNumber)