Class HazelcastClusterSafetyManager
java.lang.Object
com.atlassian.confluence.cluster.safety.AbstractClusterSafetyManager
com.atlassian.confluence.cluster.hazelcast.HazelcastClusterSafetyManager
- All Implemented Interfaces:
ClusterSafetyManager
-
Field Summary
Fields inherited from class com.atlassian.confluence.cluster.safety.AbstractClusterSafetyManager
NON_CLUSTERED_NODE_NAME, NOT_FOUND_STATEMENT, random, SAFETY_NUMBER, SAFETY_NUMBER_MODIFIER
-
Constructor Summary
ConstructorDescriptionHazelcastClusterSafetyManager
(ClusterSafetyDao clusterSafetyDao, com.atlassian.event.api.EventPublisher eventPublisher, ClusterManagerInternal clusterManager, com.hazelcast.core.HazelcastInstance hazelcastInstance, ActivityMonitor activityMonitor, ScheduledExecutorService executor, LicenseService licenseService, LoggingConfigService loggingConfigService) -
Method Summary
Modifier and TypeMethodDescriptionprotected int
decodeClusterSize
(int dbSafetyNumber) protected int
encodeClusterSize
(int nextValue) protected org.slf4j.Logger
protected int
protected long
getSeedFromTime
(long timeMs, long runIntervalMs) protected long
protected void
protected void
protected void
onCacheNumberIsMissed
(@NonNull Integer dbSafetyNumber, int nextValue) Method is called when safety number is missed in cache.protected void
onDatabaseNumberIsMissed
(@NonNull String lastCacheModifier, @NonNull Integer cacheSafetyNumber, int nextValue) Method is called when safety number is missed in database.protected void
onNumbersAreDifferent
(@NonNull String lastCacheModifier, @NonNull Integer dbSafetyNumber, @NonNull Integer cacheSafetyNumber, int nextValue) Method is called when safety numbers in cache and database are not equal.protected void
onNumbersAreEqual
(@NonNull String lastCacheModifier, @NonNull Integer dbSafetyNumber, @NonNull Integer cacheSafetyNumber, int nextValue) Method is called when safety numbers in cache and database are equal.protected void
onNumbersMissed
(int nextValue) Method is called when safety numbers in cache and database are missed.protected boolean
This job is created with "runOncePerCluster=false".void
verify
(long runIntervalMs) Ensures cluster is safe.Methods inherited from class com.atlassian.confluence.cluster.safety.AbstractClusterSafetyManager
getEventPublisher, getLicenseService, getNodeName, isLogEnabled, updateSafetyNumber
-
Field Details
-
SAFETY_MAP_PREFIX
-
-
Constructor Details
-
HazelcastClusterSafetyManager
public HazelcastClusterSafetyManager(ClusterSafetyDao clusterSafetyDao, com.atlassian.event.api.EventPublisher eventPublisher, ClusterManagerInternal clusterManager, com.hazelcast.core.HazelcastInstance hazelcastInstance, ActivityMonitor activityMonitor, ScheduledExecutorService executor, LicenseService licenseService, LoggingConfigService loggingConfigService) - Since:
- 7.6
-
-
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 interfaceClusterSafetyManager
- Overrides:
verify
in classAbstractClusterSafetyManager
-
shouldRun
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 classAbstractClusterSafetyManager
- Parameters:
lastCacheModifier
- last cache modifiercacheSafetyNumber
- safety number in cachenextValue
- next safety number to put into the cache and database
-
onCacheNumberIsMissed
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 classAbstractClusterSafetyManager
- Parameters:
dbSafetyNumber
- safety number in databasenextValue
- 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 throwsClusterPanicException
to trigger cluster panic.- Overrides:
onNumbersAreDifferent
in classAbstractClusterSafetyManager
- Parameters:
lastCacheModifier
- last cache modifierdbSafetyNumber
- safety number in databasecacheSafetyNumber
- safety number in cachenextValue
- 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 classAbstractClusterSafetyManager
- Parameters:
lastCacheModifier
- last cache modifierdbSafetyNumber
- safety number in databasecacheSafetyNumber
- safety number in cachenextValue
- 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 classAbstractClusterSafetyManager
- Parameters:
nextValue
- next safety number to put into the cache and database
-
handlePanic
protected void handlePanic()- Specified by:
handlePanic
in classAbstractClusterSafetyManager
-
logRuntimeInfo
protected void logRuntimeInfo()- Specified by:
logRuntimeInfo
in classAbstractClusterSafetyManager
-
getLogger
protected org.slf4j.Logger getLogger()- Specified by:
getLogger
in classAbstractClusterSafetyManager
-
getSafetyNumberMap
- Specified by:
getSafetyNumberMap
in classAbstractClusterSafetyManager
-
getSafetyNumberModifierMap
- Specified by:
getSafetyNumberModifierMap
in classAbstractClusterSafetyManager
-
getNextValue
protected int getNextValue()- Overrides:
getNextValue
in classAbstractClusterSafetyManager
-
encodeClusterSize
protected int encodeClusterSize(int nextValue) -
decodeClusterSize
protected int decodeClusterSize(int dbSafetyNumber)
-