1.one operation/txn gives better performance than 100/txn in case of durability-...
[csql.git] / include / Config.h
blob7bfd76b5e15287436b34c346b5eea64e3ff869d5
1 /***************************************************************************
2 * *
3 * Copyright (C) Lakshya Solutions Ltd. All rights reserved. *
4 * *
5 ***************************************************************************/
7 #ifndef CONFIG_H
8 #define CONFIG_H
9 #include<os.h>
10 #include<Util.h>
12 enum CacheMode {
13 SYNC_MODE=0,
14 ASYNC_MODE=1,
15 OFFLINE_MODE=2,
16 UNKNOWN=100
18 enum TDBInfo
20 mysql=0,
21 postgres
24 class ConfigValues
26 public:
27 //All the members of the configuration file
28 char logFile[MAX_FILE_PATH_LEN];
29 char dbFile[MAX_FILE_PATH_LEN];
30 char tableConfigFile[MAX_FILE_PATH_LEN];
31 char dsConfigFile[MAX_FILE_PATH_LEN];// DSN Config file
32 char stderrFile[MAX_FILE_PATH_LEN];
33 char conflResoFile[MAX_FILE_PATH_LEN];
35 bool isDurable;
36 bool mmap;
37 bool isCsqlSqlServer;
38 bool isCache;
39 bool isTwoWay;
41 int siteID;
42 int sysDbKey;
43 int userDbKey;
44 long maxSysSize;
45 long maxDbSize;
46 int pageSize;
47 int maxProcs;
49 long mapAddr;
51 int mutexSecs;
52 int mutexUSecs;
53 int mutexRetries;
54 int lockSecs;
55 int lockUSecs;
56 int lockRetries;
57 int logLevel;
59 int durableMode;
60 char dsn[IDENTIFIER_LENGTH];
61 CacheMode mode;
62 long offlineLogFileSize;
63 int cacheWaitSecs;
65 int port;
66 int nwResponseTimeout;
67 int nwConnectTimeout;
69 int msgKey;
70 int asyncMsgMax;
71 int shmKeyForId;
72 long maxQueueLogs;
73 int noOfProcessors;
74 int stmtCacheSize;
75 bool isCacheNoParam;
76 bool isMonitor;
77 int chkptSecs;
78 int chkptRedoLimit;
82 ConfigValues()
84 strcpy(logFile, "/tmp/log/log.out");
85 strcpy(dbFile, "/tmp/csql/db");
86 strcpy(tableConfigFile, "/tmp/csql/csqltable.conf");
87 strcpy(dsConfigFile,"/tmp/csql/csqlds.conf"); // DSN Config file
88 strcpy(stderrFile, "stderr");
89 strcpy(conflResoFile, "/tmp/csql/ConflResoFile.txt");
91 isDurable = false;
92 mmap = false;
93 isCsqlSqlServer = false;
94 isCache = false;
95 isTwoWay=false;
97 siteID=1;
98 sysDbKey = 2222;
99 userDbKey = 5555;
100 maxSysSize = 10485760;
101 maxDbSize = 104857600;
102 pageSize = 8192;
103 maxProcs = 20;
105 mapAddr=400000000;
107 mutexSecs=0;
108 mutexUSecs=10;
109 mutexRetries = 10;
110 lockSecs =0;
111 lockUSecs = 10;
112 lockRetries = 10;
113 logLevel = 0;
115 durableMode=1;
116 strcpy(dsn,"myodbc3");
117 mode = SYNC_MODE;
118 offlineLogFileSize = 1048576;
119 cacheWaitSecs =10;
121 port = 5678;
122 nwResponseTimeout=3;
123 nwConnectTimeout=5;
124 msgKey=-1;
125 asyncMsgMax = 8192; //default for linux
126 shmKeyForId = -1;
127 maxQueueLogs = 100;
128 noOfProcessors = 1;
129 stmtCacheSize = 10;
130 isCacheNoParam = false;
131 isMonitor = false;
132 chkptSecs = 600;
133 chkptRedoLimit = 10485760;
138 class Config
140 ConfigValues cVal;
141 bool isLoaded;
142 int readLine(FILE *fp, char * buffer);
143 int storeKeyVal(char *key, char *val);
144 int validateValues();
146 public:
147 Config() { isLoaded = false; }
148 int readAllValues(char *filename);
149 void print();
150 void logConfig();
151 inline int getPageSize() { return cVal.pageSize; }
152 inline int getMaxProcs() { return cVal.maxProcs; }
153 inline long getMaxSysDbSize() { return cVal.maxSysSize; }
154 inline long getMaxDbSize() { return cVal.maxDbSize; }
155 inline int getSysDbKey() { return cVal.sysDbKey; }
156 inline int getUserDbKey() { return cVal.userDbKey; }
157 inline bool useMmap() { return cVal.mmap; }
158 inline char* getLogFile() { return cVal.logFile; }
159 inline char* getDbFile() { return cVal.dbFile; }
160 inline long getMapAddress() { return cVal.mapAddr; }
161 inline int getMutexSecs() { return cVal.mutexSecs; }
162 inline int getMutexUSecs() { return cVal.mutexUSecs; }
163 inline int getMutexRetries() { return cVal.mutexRetries; }
164 inline int getLockSecs() { return cVal.lockSecs; }
165 inline int getLockUSecs() { return cVal.lockUSecs; }
166 inline int getLockRetries() { return cVal.lockRetries; }
167 inline int getSiteID(){ return cVal.siteID;}
168 inline bool useCache() { return cVal.isCache; }
169 inline int getCacheMode() { return (int) cVal.mode; }
170 inline long getOfflineLogFileSize() { return cVal.offlineLogFileSize; }
171 inline char* getDSN() { return cVal.dsn; }
172 inline char* getDsConfigFile() { return cVal.dsConfigFile; }
173 inline char* getTableConfigFile() { return cVal.tableConfigFile; }
174 inline char* getStderrFile() { return cVal.stderrFile; }
175 inline bool useDurability() { return cVal.isDurable; }
176 inline int getDurableMode() { return cVal.durableMode; }
177 inline bool useCsqlSqlServer() { return cVal.isCsqlSqlServer; }
178 inline int getPort() { return cVal.port; }
179 inline char* getConflResoFile() { return cVal.conflResoFile; }
180 inline long getMaxQueueLogs() { return cVal.maxQueueLogs; }
181 inline int getMsgKey() { return cVal.msgKey; }
182 inline int getAsyncMsgMax() { return cVal.asyncMsgMax; }
183 inline int getShmIDKey() { return cVal.shmKeyForId; }
184 inline int getNetworkResponseTimeout() { return cVal.nwResponseTimeout; }
185 inline int getNetworkConnectTimeout() { return cVal.nwConnectTimeout; }
186 inline bool useTwoWayCache() { return cVal.isTwoWay; }
187 inline int getCacheWaitSecs() { return cVal.cacheWaitSecs; }
188 inline int getLogLevel() { return cVal.logLevel; }
189 inline int getNoOfProcessors() { return cVal.noOfProcessors; }
190 inline int getStmtCacheSize() { return cVal.stmtCacheSize; }
191 inline bool useCacheNoParam() { return cVal.isCacheNoParam; }
192 inline bool useMonitorServers() { return cVal.isMonitor; }
193 inline int getChkptSecs() { return cVal.chkptSecs; }
194 inline int getChkptRedoLimit() { return cVal.chkptRedoLimit; }
198 class Conf
200 public:
201 static Config config;
202 static Logger logger;
205 #endif