Class RandomDataSourceSelector
java.lang.Object
com.alibaba.druid.pool.ha.selector.RandomDataSourceSelector
- All Implemented Interfaces:
DataSourceSelector
- Direct Known Subclasses:
StickyRandomDataSourceSelector
A selector which uses java.util.Random to choose DataSource.
- Author:
- DigitalSonic
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddBlacklist(DataSource dataSource) booleancontainInBlacklist(DataSource dataSource) voiddestroy()Interrupt Threads if needed.get()Return a DataSource according to the implemention.intintgetName()Return the name of this DataSourceSelector.intintvoidinit()Init the DataSourceSelector before use it.voidremoveBlacklist(DataSource dataSource) voidsetBlacklistThreshold(int blacklistThreshold) voidsetCheckingIntervalSeconds(int checkingIntervalSeconds) voidsetRecoverThread(RandomDataSourceRecoverThread recoverThread) voidsetRecoveryIntervalSeconds(int recoveryIntervalSeconds) voidSet the target DataSource name to return.voidsetValidateThread(RandomDataSourceValidateThread validateThread) voidsetValidationSleepSeconds(int validationSleepSeconds)
-
Field Details
-
PROP_CHECKING_INTERVAL
- See Also:
-
PROP_RECOVERY_INTERVAL
- See Also:
-
PROP_VALIDATION_SLEEP
- See Also:
-
PROP_BLACKLIST_THRESHOLD
- See Also:
-
-
Constructor Details
-
RandomDataSourceSelector
-
-
Method Details
-
init
public void init()Description copied from interface:DataSourceSelectorInit the DataSourceSelector before use it.- Specified by:
initin interfaceDataSourceSelector
-
destroy
public void destroy()Interrupt Threads if needed.- Specified by:
destroyin interfaceDataSourceSelector
-
getName
Description copied from interface:DataSourceSelectorReturn the name of this DataSourceSelector. e.g. byName- Specified by:
getNamein interfaceDataSourceSelector
-
get
Description copied from interface:DataSourceSelectorReturn a DataSource according to the implemention.- Specified by:
getin interfaceDataSourceSelector
-
setTarget
Description copied from interface:DataSourceSelectorSet the target DataSource name to return. Wether to use this or not, it's decided by the implemention.- Specified by:
setTargetin interfaceDataSourceSelector
-
getFullDataSourceMap
-
getDataSourceMap
-
getBlacklist
-
containInBlacklist
-
addBlacklist
-
removeBlacklist
-
getHighAvailableDataSource
-
getValidateThread
-
setValidateThread
-
getRecoverThread
-
setRecoverThread
-
getCheckingIntervalSeconds
public int getCheckingIntervalSeconds() -
setCheckingIntervalSeconds
public void setCheckingIntervalSeconds(int checkingIntervalSeconds) -
getRecoveryIntervalSeconds
public int getRecoveryIntervalSeconds() -
setRecoveryIntervalSeconds
public void setRecoveryIntervalSeconds(int recoveryIntervalSeconds) -
getValidationSleepSeconds
public int getValidationSleepSeconds() -
setValidationSleepSeconds
public void setValidationSleepSeconds(int validationSleepSeconds) -
getBlacklistThreshold
public int getBlacklistThreshold() -
setBlacklistThreshold
public void setBlacklistThreshold(int blacklistThreshold)
-