public abstract class AbstractClusterSafetyManager extends Object implements ClusterSafetyManager
Modifier and Type | Field and 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 |
Modifier | Constructor and Description |
---|---|
protected |
AbstractClusterSafetyManager(ClusterSafetyDao clusterSafetyDao,
com.atlassian.event.api.EventPublisher eventPublisher,
ClusterManager clusterManager,
LicenseService licenseService) |
Modifier and Type | Method and Description |
---|---|
ClusterManager |
getClusterManager() |
com.atlassian.event.api.EventPublisher |
getEventPublisher() |
LicenseService |
getLicenseService() |
protected abstract org.slf4j.Logger |
getLogger() |
protected int |
getNextValue() |
protected 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(Integer dbSafetyNumber,
int nextValue)
Method is called when safety number is missed in cache.
|
protected void |
onDatabaseNumberIsMissed(String lastCacheModifier,
Integer cacheSafetyNumber,
int nextValue)
Method is called when safety number is missed in database.
|
protected void |
onNumbersAreDifferent(String lastCacheModifier,
Integer dbSafetyNumber,
Integer cacheSafetyNumber,
int nextValue)
Method is called when safety numbers in cache and database are not equal.
|
protected void |
onNumbersAreEqual(String lastCacheModifier,
Integer dbSafetyNumber,
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 database
|
void |
verify(long runInterval)
Ensures cluster is safe.
|
protected static final String NOT_FOUND_STATEMENT
protected static final String NON_CLUSTERED_NODE_NAME
public static final String SAFETY_NUMBER_MODIFIER
public static final String SAFETY_NUMBER
protected final Random random
protected AbstractClusterSafetyManager(ClusterSafetyDao clusterSafetyDao, com.atlassian.event.api.EventPublisher eventPublisher, ClusterManager clusterManager, LicenseService licenseService)
public void verify(long runInterval)
ClusterSafetyManager
verify
in interface ClusterSafetyManager
protected void onDatabaseNumberIsMissed(@Nonnull String lastCacheModifier, @Nonnull Integer cacheSafetyNumber, int nextValue) throws ClusterPanicException
lastCacheModifier
- last cache modifiercacheSafetyNumber
- safety number in cachenextValue
- next safety number to put into the cache and databaseClusterPanicException
- in a case if panic should be triggeredprotected void onCacheNumberIsMissed(@Nonnull Integer dbSafetyNumber, int nextValue) throws ClusterPanicException
dbSafetyNumber
- safety number in databasenextValue
- next safety number to put into the cache and databaseClusterPanicException
- in a case if panic should be triggeredprotected void onNumbersAreEqual(@Nonnull String lastCacheModifier, @Nonnull Integer dbSafetyNumber, @Nonnull Integer cacheSafetyNumber, int nextValue) throws ClusterPanicException
lastCacheModifier
- last cache modifierdbSafetyNumber
- safety number in databasecacheSafetyNumber
- safety number in cachenextValue
- next safety number to put into the cache and databaseClusterPanicException
- in a case if panic should be triggeredprotected void onNumbersAreDifferent(@Nonnull String lastCacheModifier, @Nonnull Integer dbSafetyNumber, @Nonnull Integer cacheSafetyNumber, int nextValue) throws ClusterPanicException
ClusterPanicException
to trigger cluster panic.lastCacheModifier
- last cache modifierdbSafetyNumber
- safety number in databasecacheSafetyNumber
- safety number in cachenextValue
- next safety number to put into the cache and databaseClusterPanicException
- in a case if panic should be triggeredprotected void onNumbersMissed(int nextValue)
nextValue
- next safety number to put into the cache and databaseClusterPanicException
- in a case if panic should be triggeredprotected void updateSafetyNumber(int nextValue)
nextValue
- safety number to be updated in cache and dbpublic boolean isLogEnabled()
protected int getNextValue()
protected abstract org.slf4j.Logger getLogger()
protected abstract void logRuntimeInfo()
protected abstract void handlePanic()
public ClusterManager getClusterManager()
public com.atlassian.event.api.EventPublisher getEventPublisher()
public LicenseService getLicenseService()
Copyright © 2003–2018 Atlassian. All rights reserved.