SequoiaDB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
sdbDataSourceComm.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 = sdbDataSourceComm.hpp
19 
20  Descriptive Name = SDB Data Source Common Include Header
21 
22  When/how to use: this program may be used on sequoiadb data source 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_DATA_SOURCE_COMM_HPP_
42 #define SDB_DATA_SOURCE_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_DS_TOPRECREATE_THRESHOLD 2
56 
57  #define SDB_DS_CHECKUNNORMALCOORD_INTERVAL (60 * 1000)
58 
59  #define SDB_DS_CREATECONN_RETRYTIME 3
60 
62  {
67  } ;
68 
72  class DLLEXPORT sdbDataSourceConf
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(DS_STY_BALANCE),
90  _useSSL(FALSE) {}
91 
92  private:
93  // user info
94  string _userName ;
95  string _passwd ;
96  // connection number info
97  INT32 _initConnCount ;
98  INT32 _deltaIncCount ;
99  INT32 _maxIdleCount ;
100  INT32 _maxCount ;
101  // check idle connection interval
102  INT32 _checkInterval ;
103  INT32 _keepAliveTimeout ;
104  // sync coord interval
105  INT32 _syncCoordInterval ;
106  // whether check validation when a connection out
107  BOOLEAN _validateConnection ;
108  // strategy to create connections
109  DATASOURCE_STRATEGY _connectStrategy ;
110 
111  // if configure is valid
112  BOOLEAN _useSSL ;
113 
114  public:
121  void setUserInfo(
122  const string &username,
123  const string &passwd ) ;
128  string getUserName() const { return _userName ; }
133  string getPasswd() const { return _passwd ; }
134 
145  void setConnCntInfo(
146  INT32 initCnt,
147  INT32 deltaIncCnt,
148  INT32 maxIdleCnt,
149  INT32 maxCnt ) ;
150 
155  INT32 getInitConnCount() const { return _initConnCount ; }
156 
161  INT32 getDeltaIncCount() const { return _deltaIncCount ; }
162 
167  INT32 getMaxIdleCount() const { return _maxIdleCount ; }
168 
173  INT32 getMaxCount() const { return _maxCount ; }
174 
191  void setCheckIntervalInfo( INT32 interval, INT32 aliveTime = 0 ) ;
192 
197  INT32 getCheckInterval() const { return _checkInterval ; }
198 
203  INT32 getKeepAliveTimeout() const { return _keepAliveTimeout ; }
204 
210  void setSyncCoordInterval ( INT32 interval )
211  {
212  _syncCoordInterval = interval ;
213  }
218  INT32 getSyncCoordInterval() const { return _syncCoordInterval ; }
219 
226  void setValidateConnection( BOOLEAN bCheck )
227  {
228  _validateConnection = bCheck ;
229  }
230 
237  BOOLEAN getValidateConnection() const { return _validateConnection ; }
238 
244  void setConnectStrategy( DATASOURCE_STRATEGY strategy )
245  {
246  _connectStrategy = strategy ;
247  }
252  DATASOURCE_STRATEGY getConnectStrategy() const
253  {
254  return _connectStrategy ;
255  }
256 
261  void setUseSSL( BOOLEAN useSSL )
262  {
263  _useSSL = useSSL ;
264  }
269  BOOLEAN getUseSSL() const { return _useSSL ; }
270 
271 
276  BOOLEAN isValid() ;
277 
278  } ;
279 }
280 #endif