SequoiaDB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sdbConnectionPoolComm.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 = sdbConnectionPoolComm.hpp
19 
20  Descriptive Name = SDB Connection Pool Common 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 
41 #ifndef SDB_CONNECTIONPOOL_COMM_HPP_
42 #define SDB_CONNECTIONPOOL_COMM_HPP_
43 
44 #include "ossTypes.h"
45 #include <string>
46 #include "client.hpp"
47 
48 using std::string;
52 namespace sdbclient
53 {
55  #define SDB_CONNPOOL_TOPRECREATE_THRESHOLD 2
56 
57  #define SDB_CONNPOOL_CHECKUNNORMALCOORD_INTERVAL (60 * 1000)
58 
59  #define SDB_CONNPOOL_CREATECONN_RETRYTIME 3
60 
62  {
67  } ;
68 
72  class DLLEXPORT sdbConnectionPoolConf
73  {
74  public:
79  :_userName(),
80  _passwd(),
81  _initConnCount(10),
82  _deltaIncCount(10),
83  _maxIdleCount(20),
84  _maxCount(500),
85  _checkInterval(60 * 1000),
86  _keepAliveTimeout(0 * 1000),
87  _syncCoordInterval(0 * 1000),
88  _validateConnection(FALSE),
89  _connectStrategy(SDB_CONN_STY_SERIAL),
90  _useSSL(FALSE) {}
91 
92  private:
93  // user info
94  string _userName ;
95  string _passwd ;
96  string _cipherFile ;
97  string _token ;
98  // connection number info
99  INT32 _initConnCount ;
100  INT32 _deltaIncCount ;
101  INT32 _maxIdleCount ;
102  INT32 _maxCount ;
103  // check idle connection interval
104  INT32 _checkInterval ;
105  INT32 _keepAliveTimeout ;
106  // sync coord interval
107  INT32 _syncCoordInterval ;
108  // whether check validation when a connection out
109  BOOLEAN _validateConnection ;
110  // strategy to create connections
111  SDB_CONN_STRATEGY _connectStrategy ;
112 
113  // if configure is valid
114  BOOLEAN _useSSL ;
115 
116  public:
123  void setAuthInfo(
124  const string &username,
125  const string &passwd ) ;
126 
136  void setAuthInfo( const string &username,
137  const string &cipherFile,
138  const string &token ) ;
139 
144  string getUserName() const { return _userName ; }
145 
150  string getPasswd() const { return _passwd ; }
151 
156  string getCipherFile() const { return _cipherFile ; }
157 
162  string getToken() const { return _token ; }
163 
175  void setConnCntInfo(
176  INT32 initCnt,
177  INT32 deltaIncCnt,
178  INT32 maxIdleCnt,
179  INT32 maxCnt ) ;
180 
185  INT32 getInitConnCount() const { return _initConnCount ; }
186 
191  INT32 getDeltaIncCount() const { return _deltaIncCount ; }
192 
197  INT32 getMaxIdleCount() const { return _maxIdleCount ; }
198 
203  INT32 getMaxCount() const { return _maxCount ; }
204 
221  void setCheckIntervalInfo( INT32 interval, INT32 aliveTime = 0 ) ;
222 
227  INT32 getCheckInterval() const { return _checkInterval ; }
228 
233  INT32 getKeepAliveTimeout() const { return _keepAliveTimeout ; }
234 
240  void setSyncCoordInterval ( INT32 interval )
241  {
242  _syncCoordInterval = interval ;
243  }
248  INT32 getSyncCoordInterval() const { return _syncCoordInterval ; }
249 
256  void setValidateConnection( BOOLEAN bCheck )
257  {
258  _validateConnection = bCheck ;
259  }
260 
267  BOOLEAN getValidateConnection() const { return _validateConnection ; }
268 
274  void setConnectStrategy( SDB_CONN_STRATEGY strategy )
275  {
276  _connectStrategy = strategy ;
277  }
282  SDB_CONN_STRATEGY getConnectStrategy() const
283  {
284  return _connectStrategy ;
285  }
286 
291  void setUseSSL( BOOLEAN useSSL )
292  {
293  _useSSL = useSSL ;
294  }
299  BOOLEAN getUseSSL() const { return _useSSL ; }
300 
301 
306  BOOLEAN isValid() ;
307 
308  } ;
309 }
310 #endif /* SDB_CONNECTIONPOOL_COMM_HPP_ */