SequoiaDB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sdbConnectionPool.hpp
Go to the documentation of this file.
1 /*******************************************************************************
2 
3 
4  Copyright (C) 2011-2018 SequoiaDB Ltd.
5 
6  Licensed under the Apache License, Version 2.0 (the "License");
7  you may not use this file except in compliance with the License.
8  You may obtain a copy of the License at
9 
10  http://www.apache.org/licenses/LICENSE-2.0
11 
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  See the License for the specific language governing permissions and
16  limitations under the License.
17 
18  Source File Name = sdbConnectionPool.hpp
19 
20  Descriptive Name = SDB Connection Pool Include Header
21 
22  When/how to use: this program may be used on sequoiadb connection pool function.
23 
24  Dependencies: N/A
25 
26  Restrictions: N/A
27 
28  Change Activity:
29  defect Date Who Description
30  ====== =========== === ==============================================
31  06/30/2016 LXJ Initial Draft
32 
33  Last Changed =
34 
35 *******************************************************************************/
36 
42 #ifndef SDB_CONNECTIONPOOL_HPP_
43 #define SDB_CONNECTIONPOOL_HPP_
44 
46 
47 #ifndef SDB_CLIENT
48 #define SDB_CLIENT
49 #endif
50 
55 namespace sdbclient
56 {
57  class sdbConnectionPoolImpl ;
58 
62  class DLLEXPORT sdbConnectionPool
63  {
64  public:
69 
74 
75  private:
76  sdbConnectionPool( const sdbConnectionPool &connPool ) ;
77  sdbConnectionPool& operator=( const sdbConnectionPool &connPool ) ;
78 
79  public:
88  INT32 init( const std::string &address, const sdbConnectionPoolConf &conf ) ;
89 
98  INT32 init(
99  const std::vector<std::string> &addrs,
100  const sdbConnectionPoolConf &conf ) ;
101 
107  INT32 getIdleConnNum() const ;
108 
114  INT32 getUsedConnNum() const ;
115 
121  INT32 getNormalAddrNum() const ;
122 
128  INT32 getAbnormalAddrNum() const ;
129 
135  INT32 getLocalAddrNum() const ;
136 
147  INT32 getConnection( sdb*& conn, INT64 timeoutms = 5000 ) ;
148 
156  void releaseConnection( sdb*& conn ) ;
157 
163  INT32 close() ;
164 
170  void updateAuthInfo( const string &username, const string &passwd ) ;
171 
180  void updateAuthInfo( const string &username, const string &cipherFile,
181  const string &token ) ;
182 
191  INT32 updateAddress( const std::vector<std::string> &addrs ) ;
192 
193  private:
194  sdbConnectionPoolImpl *_pImpl ;
195  } ;
196 }
197 
198 #endif /* SDB_CONNECTIONPOOL_HPP_ */