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 Details

  • Constructor Details

  • Method Details

    • init

      public void init()
      Description copied from interface: DataSourceSelector
      Init the DataSourceSelector before use it.
      Specified by:
      init in interface DataSourceSelector
    • destroy

      public void destroy()
      Interrupt Threads if needed.
      Specified by:
      destroy in interface DataSourceSelector
    • getName

      public String getName()
      Description copied from interface: DataSourceSelector
      Return the name of this DataSourceSelector. e.g. byName
      Specified by:
      getName in interface DataSourceSelector
    • get

      public DataSource get()
      Description copied from interface: DataSourceSelector
      Return a DataSource according to the implemention.
      Specified by:
      get in interface DataSourceSelector
    • setTarget

      public void setTarget(String name)
      Description copied from interface: DataSourceSelector
      Set the target DataSource name to return. Wether to use this or not, it's decided by the implemention.
      Specified by:
      setTarget in interface DataSourceSelector
    • 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)