com.alibaba.druid.pool.ha
Class MultiDataSource

java.lang.Object
  extended by com.alibaba.druid.pool.WrapperAdapter
      extended by com.alibaba.druid.pool.DataSourceAdapter
          extended by com.alibaba.druid.pool.ha.MultiDataSource
All Implemented Interfaces:
MultiDataSourceMBean, DataSourceProxy, Wrapper, CommonDataSource, DataSource
Direct Known Subclasses:
CobarDataSource, HADataSource

public class MultiDataSource
extends DataSourceAdapter
implements MultiDataSourceMBean, DataSourceProxy


Constructor Summary
MultiDataSource()
           
 
Method Summary
 void addDataSource(String name, DataSourceHolder dataSourceHolder)
           
 void afterDataSourceChanged(Object event)
           
 void close()
           
 long createConnectionId()
           
 long createResultSetId()
           
 long createStatementId()
           
 long createTransactionId()
           
 void failureDetect()
           
 long getActiveCount()
           
 long getBusySkipCount()
           
 long getConfigLoadCount()
           
 ConfigLoader getConfigLoader()
           
 long getConfigLoadPeriodMillis()
           
 Connection getConnection()
           
 Properties getConnectProperties()
           
 DataSourceHolder getDataSourceHolder(String name)
           
 String[] getDataSourceNames()
           
 Map<String,DataSourceHolder> getDataSources()
           
 JdbcDataSourceStat getDataSourceStat()
           
 String getDbType()
           
 int getEnabledDataSourceCount()
           
 long getFailureDetectCount()
           
 DataSourceFailureDetecter getFailureDetector()
           
 long getFailureDetectPeriodMillis()
           
 Lock getLock()
           
 int getMaxPoolSize()
           
 long getMaxWait()
           
 long getMaxWaitMillis()
           
 String getName()
           
 String getNameInternal()
           
 Condition getNotFail()
           
 ObjectName getObjectName()
           
 Properties getProperties()
           
 List<Filter> getProxyFilters()
           
 Driver getRawDriver()
           
 String getRawJdbcUrl()
           
 MultiConnectionHolder getRealConnection(MultiDataSourceConnection multiConn, String sql)
           
 long getRetryGetConnectionCount()
           
 String getUrl()
           
 void handleNotAwailableDatasource(DataSourceHolder dataSourceHolder)
           
 void incrementBusySkipCount()
           
 void incrementRetryGetConnectionCount()
           
 void init()
           
 boolean isEnable()
           
 boolean isIntited()
           
 void notFailSignal()
           
 void resetStat()
           
 boolean restartDataSource(String name)
           
 void setConfigLoader(ConfigLoader configLoader)
           
 void setConfigLoadPeriodMillis(long configLoadPeriodMillis)
           
 void setEnable(boolean enable)
           
 void setFailureDetector(DataSourceFailureDetecter failureDetector)
           
 void setFailureDetectPeriodMillis(long failureDetectPeriodMillis)
           
 void setMaxPoolSize(int maxPoolSize)
           
 void setMaxWait(long seconds)
           
 void setMaxWaitMillis(long maxWaitMillis)
           
 void setName(String name)
           
 void setObjectName(ObjectName objectName)
           
 boolean startConfigLoadScheduleTask()
           
 boolean startFailureDetectScheduleTask()
           
 boolean stopConfigLoadScheduleTask()
           
 boolean stopFailureDetectScheduleTask()
           
 
Methods inherited from class com.alibaba.druid.pool.DataSourceAdapter
getConnection, getLoginTimeout, getLogWriter, getParentLogger, setLoginTimeout, setLogWriter
 
Methods inherited from class com.alibaba.druid.pool.WrapperAdapter
isWrapperFor, unwrap
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.sql.Wrapper
isWrapperFor, unwrap
 

Constructor Detail

MultiDataSource

public MultiDataSource()
Method Detail

getMaxWaitMillis

public long getMaxWaitMillis()

setMaxWaitMillis

public void setMaxWaitMillis(long maxWaitMillis)

setMaxWait

public void setMaxWait(long seconds)

getMaxWait

public long getMaxWait()

getMaxPoolSize

public int getMaxPoolSize()
Specified by:
getMaxPoolSize in interface MultiDataSourceMBean

setMaxPoolSize

public void setMaxPoolSize(int maxPoolSize)
                    throws SQLException
Throws:
SQLException

getConfigLoader

public ConfigLoader getConfigLoader()

setConfigLoader

public void setConfigLoader(ConfigLoader configLoader)

getName

public String getName()
Specified by:
getName in interface DataSourceProxy

getNameInternal

public String getNameInternal()

setName

public void setName(String name)

isIntited

public boolean isIntited()

isEnable

public boolean isEnable()

setEnable

public void setEnable(boolean enable)

getObjectName

public ObjectName getObjectName()

setObjectName

public void setObjectName(ObjectName objectName)

init

public void init()
          throws SQLException
Throws:
SQLException

startConfigLoadScheduleTask

public boolean startConfigLoadScheduleTask()
Specified by:
startConfigLoadScheduleTask in interface MultiDataSourceMBean

stopConfigLoadScheduleTask

public boolean stopConfigLoadScheduleTask()
Specified by:
stopConfigLoadScheduleTask in interface MultiDataSourceMBean

startFailureDetectScheduleTask

public boolean startFailureDetectScheduleTask()
Specified by:
startFailureDetectScheduleTask in interface MultiDataSourceMBean

stopFailureDetectScheduleTask

public boolean stopFailureDetectScheduleTask()
Specified by:
stopFailureDetectScheduleTask in interface MultiDataSourceMBean

resetStat

public void resetStat()

close

public void close()

failureDetect

public void failureDetect()
Specified by:
failureDetect in interface MultiDataSourceMBean

setFailureDetectPeriodMillis

public void setFailureDetectPeriodMillis(long failureDetectPeriodMillis)

setConfigLoadPeriodMillis

public void setConfigLoadPeriodMillis(long configLoadPeriodMillis)

getFailureDetector

public DataSourceFailureDetecter getFailureDetector()

setFailureDetector

public void setFailureDetector(DataSourceFailureDetecter failureDetector)

createConnectionId

public long createConnectionId()
Specified by:
createConnectionId in interface DataSourceProxy

createStatementId

public long createStatementId()
Specified by:
createStatementId in interface DataSourceProxy

getDataSources

public Map<String,DataSourceHolder> getDataSources()

getDataSourceHolder

public DataSourceHolder getDataSourceHolder(String name)

addDataSource

public void addDataSource(String name,
                          DataSourceHolder dataSourceHolder)

getProperties

public Properties getProperties()

getActiveCount

public long getActiveCount()
Specified by:
getActiveCount in interface MultiDataSourceMBean

notFailSignal

public void notFailSignal()

afterDataSourceChanged

public void afterDataSourceChanged(Object event)

getConnection

public Connection getConnection()
                         throws SQLException
Specified by:
getConnection in interface DataSource
Overrides:
getConnection in class DataSourceAdapter
Throws:
SQLException

getRealConnection

public MultiConnectionHolder getRealConnection(MultiDataSourceConnection multiConn,
                                               String sql)
                                        throws SQLException
Throws:
SQLException

getEnabledDataSourceCount

public int getEnabledDataSourceCount()

handleNotAwailableDatasource

public void handleNotAwailableDatasource(DataSourceHolder dataSourceHolder)

getRetryGetConnectionCount

public long getRetryGetConnectionCount()
Specified by:
getRetryGetConnectionCount in interface MultiDataSourceMBean

incrementRetryGetConnectionCount

public void incrementRetryGetConnectionCount()

getLock

public Lock getLock()

getNotFail

public Condition getNotFail()

getBusySkipCount

public long getBusySkipCount()
Specified by:
getBusySkipCount in interface MultiDataSourceMBean

incrementBusySkipCount

public void incrementBusySkipCount()

getDataSourceNames

public String[] getDataSourceNames()
Specified by:
getDataSourceNames in interface MultiDataSourceMBean

getDbType

public String getDbType()
Specified by:
getDbType in interface DataSourceProxy

getRawDriver

public Driver getRawDriver()
Specified by:
getRawDriver in interface DataSourceProxy

getUrl

public String getUrl()
Specified by:
getUrl in interface DataSourceProxy

getRawJdbcUrl

public String getRawJdbcUrl()
Specified by:
getRawJdbcUrl in interface DataSourceProxy

getProxyFilters

public List<Filter> getProxyFilters()
Specified by:
getProxyFilters in interface DataSourceProxy

createResultSetId

public long createResultSetId()
Specified by:
createResultSetId in interface DataSourceProxy

createTransactionId

public long createTransactionId()
Specified by:
createTransactionId in interface DataSourceProxy

restartDataSource

public boolean restartDataSource(String name)
Specified by:
restartDataSource in interface MultiDataSourceMBean

getConfigLoadCount

public long getConfigLoadCount()
Specified by:
getConfigLoadCount in interface MultiDataSourceMBean

getFailureDetectCount

public long getFailureDetectCount()
Specified by:
getFailureDetectCount in interface MultiDataSourceMBean

getFailureDetectPeriodMillis

public long getFailureDetectPeriodMillis()
Specified by:
getFailureDetectPeriodMillis in interface MultiDataSourceMBean

getConfigLoadPeriodMillis

public long getConfigLoadPeriodMillis()
Specified by:
getConfigLoadPeriodMillis in interface MultiDataSourceMBean

getDataSourceStat

public JdbcDataSourceStat getDataSourceStat()
Specified by:
getDataSourceStat in interface DataSourceProxy

getConnectProperties

public Properties getConnectProperties()
Specified by:
getConnectProperties in interface DataSourceProxy


Copyright © 2012 Alibaba Group. All Rights Reserved.