public class SequoiadbDatasource extends Object
构造器和说明 |
---|
SequoiadbDatasource(List<String> urls,
String username,
String password,
ConfigOptions nwOpt,
DatasourceOptions dsOpt)
When offer several addresses for connection pool to use, if
some of them are not available(invalid address, network error, coord shutdown,
catalog replica group is not available), we will put these addresses
into a queue, and check them periodically.
|
SequoiadbDatasource(String url,
String username,
String password,
DatasourceOptions dsOpt) |
限定符和类型 | 方法和说明 |
---|---|
void |
addCoord(String url)
Add coord address.
|
void |
close()
Clean all resources of current connection pool.
|
void |
disableDatasource()
Disable the data source.
|
void |
enableDatasource()
Enable data source.
|
int |
getAbnormalAddrNum()
Get the current abnormal address amount.
|
Sequoiadb |
getConnection()
Get a connection from current connection pool.
|
Sequoiadb |
getConnection(long timeout)
Get a connection from current connection pool.
|
DatasourceOptions |
getDatasourceOptions()
Get a copy of the connection pool options.
|
int |
getIdleConnNum()
Get the current idle connection amount.
|
int |
getLocalAddrNum()
Get the amount of local coord node address.
|
int |
getNormalAddrNum()
Get the current normal address amount.
|
int |
getUsedConnNum()
Get the current used connection amount.
|
void |
releaseConnection(Sequoiadb sdb)
Put the connection back to the connection pool.
|
void |
removeCoord(String url)
Remove coord address.
|
void |
updateDatasourceOptions(DatasourceOptions dsOpt)
Update connection pool options.
|
public SequoiadbDatasource(List<String> urls, String username, String password, ConfigOptions nwOpt, DatasourceOptions dsOpt) throws BaseException
urls
- the addresses of coord nodes, can't be null or empty,
e.g."ubuntu1:11810","ubuntu2:11810",...username
- the user name for logging sequoiadbpassword
- the password for logging sequoiadbnwOpt
- the options for connectiondsOpt
- the options for connection poolBaseException
- If error happens.ConfigOptions
,
DatasourceOptions
public SequoiadbDatasource(String url, String username, String password, DatasourceOptions dsOpt) throws BaseException
url
- the address of coord, can't be empty or null, e.g."ubuntu1:11810"username
- the user name for logging sequoiadbpassword
- the password for logging sequoiadbdsOpt
- the options for connection poolBaseException
- If error happens.public void addCoord(String url) throws BaseException
url
- The address in format "192.168.20.168:11810"BaseException
- If error happens.public void close()
public void disableDatasource()
BaseException
- If error happens.public void enableDatasource()
BaseException
- If error happens.public int getAbnormalAddrNum()
public Sequoiadb getConnection() throws BaseException, InterruptedException
BaseException
- If error happens.InterruptedException
- Actually, nothing happen. Throw this for compatibility reason.public Sequoiadb getConnection(long timeout) throws BaseException, InterruptedException
timeout
- the time for waiting for connection in millisecond. 0 for waiting until a connection is available.BaseException
- when connection pool run out, throws BaseException with the type of "SDB_DRIVER_DS_RUNOUT"InterruptedException
- Actually, nothing happen. Throw this for compatibility reason.public DatasourceOptions getDatasourceOptions() throws BaseException
BaseException
- If error happens.public int getIdleConnNum()
public int getLocalAddrNum()
BaseException
- If error happens.public int getNormalAddrNum()
public int getUsedConnNum()
public void releaseConnection(Sequoiadb sdb) throws BaseException
sdb
- the connection to come back, can't be nullBaseException
- If error happens.public void removeCoord(String url) throws BaseException
BaseException
public void updateDatasourceOptions(DatasourceOptions dsOpt) throws BaseException
BaseException
- If error happens.Copyright © 2018. All rights reserved.