Class RandomDataSourceSelector
- java.lang.Object
-
- com.alibaba.druid.pool.ha.selector.RandomDataSourceSelector
-
- All Implemented Interfaces:
DataSourceSelector
- Direct Known Subclasses:
StickyRandomDataSourceSelector
public class RandomDataSourceSelector extends Object implements DataSourceSelector
A selector which uses java.util.Random to choose DataSource.- Author:
- DigitalSonic
-
-
Field Summary
Fields Modifier and Type Field Description static StringPROP_BLACKLIST_THRESHOLDstatic StringPROP_CHECKING_INTERVALstatic StringPROP_RECOVERY_INTERVALstatic StringPROP_VALIDATION_SLEEP
-
Constructor Summary
Constructors Constructor Description RandomDataSourceSelector(HighAvailableDataSource highAvailableDataSource)
-
Method Summary
-
-
-
Field Detail
-
PROP_CHECKING_INTERVAL
public static final String PROP_CHECKING_INTERVAL
- See Also:
- Constant Field Values
-
PROP_RECOVERY_INTERVAL
public static final String PROP_RECOVERY_INTERVAL
- See Also:
- Constant Field Values
-
PROP_VALIDATION_SLEEP
public static final String PROP_VALIDATION_SLEEP
- See Also:
- Constant Field Values
-
PROP_BLACKLIST_THRESHOLD
public static final String PROP_BLACKLIST_THRESHOLD
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RandomDataSourceSelector
public RandomDataSourceSelector(HighAvailableDataSource highAvailableDataSource)
-
-
Method Detail
-
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
public String getName()
Description copied from interface:DataSourceSelectorReturn the name of this DataSourceSelector. e.g. byName- Specified by:
getNamein interfaceDataSourceSelector
-
get
public DataSource get()
Description copied from interface:DataSourceSelectorReturn a DataSource according to the implemention.- Specified by:
getin interfaceDataSourceSelector
-
setTarget
public void setTarget(String name)
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
public Map<String,DataSource> getFullDataSourceMap()
-
getDataSourceMap
public Map<String,DataSource> getDataSourceMap()
-
getBlacklist
public List<DataSource> getBlacklist()
-
containInBlacklist
public boolean containInBlacklist(DataSource dataSource)
-
addBlacklist
public void addBlacklist(DataSource dataSource)
-
removeBlacklist
public void removeBlacklist(DataSource dataSource)
-
getHighAvailableDataSource
public HighAvailableDataSource getHighAvailableDataSource()
-
getValidateThread
public RandomDataSourceValidateThread getValidateThread()
-
setValidateThread
public void setValidateThread(RandomDataSourceValidateThread validateThread)
-
getRecoverThread
public RandomDataSourceRecoverThread getRecoverThread()
-
setRecoverThread
public void setRecoverThread(RandomDataSourceRecoverThread recoverThread)
-
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)
-
-