Class AbstractClusterSafetyManager
- java.lang.Object
-
- com.atlassian.confluence.cluster.safety.AbstractClusterSafetyManager
-
- All Implemented Interfaces:
ClusterSafetyManager
- Direct Known Subclasses:
DefaultClusterSafetyManager
,HazelcastClusterSafetyManager
public abstract class AbstractClusterSafetyManager extends Object implements ClusterSafetyManager
Contains common functionality for clustered and standalone safety managers
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
NON_CLUSTERED_NODE_NAME
protected static String
NOT_FOUND_STATEMENT
protected Random
random
static String
SAFETY_NUMBER
static String
SAFETY_NUMBER_MODIFIER
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractClusterSafetyManager(ClusterSafetyDao clusterSafetyDao, com.atlassian.event.api.EventPublisher eventPublisher, ClusterManager clusterManager, LicenseService licenseService)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ClusterManager
getClusterManager()
com.atlassian.event.api.EventPublisher
getEventPublisher()
LicenseService
getLicenseService()
protected abstract org.slf4j.Logger
getLogger()
protected int
getNextValue()
protected @NonNull String
getNodeName()
protected abstract Map<String,Integer>
getSafetyNumberMap()
protected abstract Map<String,String>
getSafetyNumberModifierMap()
protected abstract void
handlePanic()
boolean
isLogEnabled()
protected abstract void
logRuntimeInfo()
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 void
updateSafetyNumber(int nextValue)
Updates safety number in cache and databasevoid
verify(long runInterval)
Ensures cluster is safe.
-
-
-
Field Detail
-
NOT_FOUND_STATEMENT
protected static final String NOT_FOUND_STATEMENT
- See Also:
- Constant Field Values
-
NON_CLUSTERED_NODE_NAME
protected static final String NON_CLUSTERED_NODE_NAME
- See Also:
- Constant Field Values
-
SAFETY_NUMBER_MODIFIER
public static final String SAFETY_NUMBER_MODIFIER
- See Also:
- Constant Field Values
-
SAFETY_NUMBER
public static final String SAFETY_NUMBER
- See Also:
- Constant Field Values
-
random
protected final Random random
-
-
Constructor Detail
-
AbstractClusterSafetyManager
protected AbstractClusterSafetyManager(ClusterSafetyDao clusterSafetyDao, com.atlassian.event.api.EventPublisher eventPublisher, ClusterManager clusterManager, LicenseService licenseService)
-
-
Method Detail
-
verify
public void verify(long runInterval)
Description copied from interface:ClusterSafetyManager
Ensures cluster is safe. If not, panic procedure is initiated.- Specified by:
verify
in interfaceClusterSafetyManager
-
onDatabaseNumberIsMissed
protected void onDatabaseNumberIsMissed(@NonNull String lastCacheModifier, @NonNull Integer cacheSafetyNumber, int nextValue) throws ClusterPanicException
Method is called when safety number is missed in database. By default it updates safety number in the cache and database.- Parameters:
lastCacheModifier
- last cache modifiercacheSafetyNumber
- safety number in cachenextValue
- next safety number to put into the cache and database- Throws:
ClusterPanicException
- in a case if panic should be triggered
-
onCacheNumberIsMissed
protected void onCacheNumberIsMissed(@NonNull Integer dbSafetyNumber, int nextValue) throws ClusterPanicException
Method is called when safety number is missed in cache. By default it updates safety number in the cache and database.- Parameters:
dbSafetyNumber
- safety number in databasenextValue
- 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) throws ClusterPanicException
Method is called when safety numbers in cache and database are equal. By default it updates safety number in the cache and database.- 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
-
onNumbersAreDifferent
protected void onNumbersAreDifferent(@NonNull String lastCacheModifier, @NonNull Integer dbSafetyNumber, @NonNull Integer cacheSafetyNumber, int nextValue) throws ClusterPanicException
Method is called when safety numbers in cache and database are not equal. By default this method throwsClusterPanicException
to trigger cluster panic.- 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
-
onNumbersMissed
protected void onNumbersMissed(int nextValue)
Method is called when safety numbers in cache and database are missed. By default it updates safety number in the cache and database.- Parameters:
nextValue
- next safety number to put into the cache and database- Throws:
ClusterPanicException
- in a case if panic should be triggered
-
updateSafetyNumber
protected void updateSafetyNumber(int nextValue)
Updates safety number in cache and database- Parameters:
nextValue
- safety number to be updated in cache and db
-
getNodeName
protected @NonNull String getNodeName()
-
isLogEnabled
public boolean isLogEnabled()
-
getNextValue
protected int getNextValue()
-
getLogger
protected abstract org.slf4j.Logger getLogger()
-
logRuntimeInfo
protected abstract void logRuntimeInfo()
-
handlePanic
protected abstract void handlePanic()
-
getClusterManager
public ClusterManager getClusterManager()
-
getEventPublisher
public com.atlassian.event.api.EventPublisher getEventPublisher()
-
getLicenseService
public LicenseService getLicenseService()
-
-