SequoiaDB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | List of all members
sdbclient::sdbConnectionPool Class Reference

The sdb connection pool. More...

#include <sdbConnectionPool.hpp>

Public Member Functions

 sdbConnectionPool ()
 The constructor of sdbConnectionPool.
 
 ~sdbConnectionPool ()
 The destructor of sdbConnectionPool.
 
INT32 init (const std::string &address, const sdbConnectionPoolConf &conf)
 Initialize connection pool.
 
INT32 init (const std::vector< std::string > &addrs, const sdbConnectionPoolConf &conf)
 Initialize connection pool.
 
INT32 getIdleConnNum () const
 Get idle connection number or -1 for connection pool has not been initialized yet.
 
INT32 getUsedConnNum () const
 Get used connection number or -1 for connection pool has not been initialized yet.
 
INT32 getNormalAddrNum () const
 Get the number of reachable address or -1 for connection pool has not been initialized yet.
 
INT32 getAbnormalAddrNum () const
 Get the number of unreachable address or -1 for connection pool has not been initialized yet.
 
INT32 getLocalAddrNum () const
 Get the number of local address or -1 for connection pool has not been initialized yet.
 
INT32 getConnection (sdb *&conn, INT64 timeoutms=5000)
 Get a connection form connection pool.
 
void releaseConnection (sdb *&conn)
 Give back a connection to connection pool. If the connection pool had been closed, do nothing.
 
INT32 close ()
 Close connection pool.
 
void updateAuthInfo (const string &username, const string &passwd)
 update authentication information
 
void updateAuthInfo (const string &username, const string &cipherFile, const string &token)
 update authentication information
 
INT32 updateAddress (const std::vector< std::string > &addrs)
 update the addresses of the connection pool, the new address list will replace the old address list, and idle connections whose addresses are not in the new address list will be cleared.
 

Detailed Description

The sdb connection pool.

Member Function Documentation

void sdbclient::sdbConnectionPool::close ( )

Close connection pool.

Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbConnectionPool::getAbnormalAddrNum ( ) const

Get the number of unreachable address or -1 for connection pool has not been initialized yet.

Return values
Thenumber of unreachable coord nodes
INT32 sdbclient::sdbConnectionPool::getConnection ( sdb *&  conn,
INT64  timeoutsec = 5000 
)

Get a connection form connection pool.

Parameters
[out]connA connection
[in]timeoutmsThe time to wait when connection number reach to max connection number,default:5000ms. when timeoutms is set to 0, means waiting until a connection is available. when timeoutms is less than 0, set it to be 0.
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbConnectionPool::getIdleConnNum ( ) const

Get idle connection number or -1 for connection pool has not been initialized yet.

Return values
Thenumber of idle connection
INT32 sdbclient::sdbConnectionPool::getLocalAddrNum ( ) const

Get the number of local address or -1 for connection pool has not been initialized yet.

Return values
Thenumber of local coord nodes
INT32 sdbclient::sdbConnectionPool::getNormalAddrNum ( ) const

Get the number of reachable address or -1 for connection pool has not been initialized yet.

Return values
Thenumber of reachable coord nodes
INT32 sdbclient::sdbConnectionPool::getUsedConnNum ( ) const

Get used connection number or -1 for connection pool has not been initialized yet.

Return values
Thenumber of used connection
INT32 sdbclient::sdbConnectionPool::init ( const std::string &  address,
const sdbConnectionPoolConf conf 
)

Initialize connection pool.

Parameters
[in]addressA coord node("ubuntu-xxx:11810")
[in]confThe sdbConnectionPoolConf
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbConnectionPool::init ( const std::vector< std::string > &  addrs,
const sdbConnectionPoolConf conf 
)

Initialize connection pool.

Parameters
[in]addrsA list of coord node("ubuntu-xxx:11810")
[in]confThe sdbConnectionPoolConf
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbConnectionPool::releaseConnection ( sdb *&  conn)

Give back a connection to connection pool. If the connection pool had been closed, do nothing.

Parameters
[in]connA connection
Return values
SDB_OKOperation Success
OthersOperation Fail
INT32 sdbclient::sdbConnectionPool::updateAddress ( const std::vector< std::string > &  addrs)

update the addresses of the connection pool, the new address list will replace the old address list, and idle connections whose addresses are not in the new address list will be cleared.

Parameters
[in]coordAddrsA list of coord node
Return values
SDB_OKOperation Success
OthersOperation Fail
void sdbclient::sdbConnectionPool::updateAuthInfo ( const string &  username,
const string &  passwd 
)

update authentication information

Parameters
[in]usernameThe new user name
[in]passwdThe new password
void sdbclient::sdbConnectionPool::updateAuthInfo ( const string &  username,
const string &  cipherFile,
const string &  token 
)

update authentication information

Parameters
[in]usernameThe new user name
[in]cipherFileThe new cipherfile location
[in]tokenThe new password encryption token

The documentation for this class was generated from the following file: