lock manager and chunk allocation mutex modificationsw
[csql.git] / include / Config.h
blobebe5cf5c3c5428de24f8570f5bd2404ab652ee7c
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 DllExport 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 int nRowsToFetch;
62 CacheMode mode;
63 long offlineLogFileSize;
64 int cacheWaitSecs;
66 int port;
67 int nwResponseTimeout;
68 int nwConnectTimeout;
70 int msgKey;
71 int asyncMsgMax;
72 int shmKeyForId;
73 long maxQueueLogs;
74 int noOfProcessors;
75 int stmtCacheSize;
76 bool isCacheNoParam;
77 bool isMonitor;
78 int chkptSecs;
79 int chkptRedoLimit;
83 ConfigValues()
85 strcpy(logFile, "/tmp/log/log.out");
86 strcpy(dbFile, "/tmp/csql/db");
87 strcpy(tableConfigFile, "/tmp/csql/csqltable.conf");
88 strcpy(dsConfigFile,"/tmp/csql/csqlds.conf"); // DSN Config file
89 strcpy(stderrFile, "stderr");
90 strcpy(conflResoFile, "/tmp/csql/ConflResoFile.txt");
92 isDurable = false;
93 mmap = false;
94 isCsqlSqlServer = false;
95 isCache = false;
96 isTwoWay=false;
98 siteID=1;
99 sysDbKey = 2222;
100 userDbKey = 5555;
101 maxSysSize = 10485760;
102 maxDbSize = 104857600;
103 pageSize = 8192;
104 maxProcs = 20;
106 mapAddr=400000000;
108 mutexSecs=0;
109 mutexUSecs=10;
110 mutexRetries = 10;
111 lockSecs =0;
112 lockUSecs = 10;
113 lockRetries = 10;
114 logLevel = 0;
116 durableMode=1;
117 strcpy(dsn,"myodbc3");
118 nRowsToFetch=100;
119 mode = SYNC_MODE;
120 offlineLogFileSize = 1048576;
121 cacheWaitSecs =10;
123 port = 5678;
124 nwResponseTimeout=3;
125 nwConnectTimeout=5;
126 msgKey=-1;
127 asyncMsgMax = 8192; //default for linux
128 shmKeyForId = -1;
129 maxQueueLogs = 100;
130 noOfProcessors = 1;
131 stmtCacheSize = 10;
132 isCacheNoParam = false;
133 isMonitor = false;
134 chkptSecs = 600;
135 chkptRedoLimit = 10485760;
140 class DllExport Config
142 ConfigValues cVal;
143 bool isLoaded;
144 int readLine(FILE *fp, char * buffer);
145 int storeKeyVal(char *key, char *val);
146 int validateValues();
148 public:
149 Config() { isLoaded = false; }
150 int readAllValues(char *filename);
151 void print();
152 void logConfig();
153 inline int getPageSize() { return cVal.pageSize; }
154 inline int getMaxProcs() { return cVal.maxProcs; }
155 inline long getMaxSysDbSize() { return cVal.maxSysSize; }
156 inline long getMaxDbSize() { return cVal.maxDbSize; }
157 inline int getSysDbKey() { return cVal.sysDbKey; }
158 inline int getUserDbKey() { return cVal.userDbKey; }
159 inline bool useMmap() { return cVal.mmap; }
160 inline char* getLogFile() { return cVal.logFile; }
161 inline char* getDbFile() { return cVal.dbFile; }
162 inline long getMapAddress() { return cVal.mapAddr; }
163 inline int getMutexSecs() { return cVal.mutexSecs; }
164 inline int getMutexUSecs() { return cVal.mutexUSecs; }
165 inline int getMutexRetries() { return cVal.mutexRetries; }
166 inline int getLockSecs() { return cVal.lockSecs; }
167 inline int getLockUSecs() { return cVal.lockUSecs; }
168 inline int getLockRetries() { return cVal.lockRetries; }
169 inline int getSiteID(){ return cVal.siteID;}
170 inline bool useCache() { return cVal.isCache; }
171 inline int getCacheMode() { return (int) cVal.mode; }
172 inline long getOfflineLogFileSize() { return cVal.offlineLogFileSize; }
173 inline char* getDSN() { return cVal.dsn; }
174 inline int getNoOfRowsToFetchFromTDB() { return cVal.nRowsToFetch; }
175 inline char* getDsConfigFile() { return cVal.dsConfigFile; }
176 inline char* getTableConfigFile() { return cVal.tableConfigFile; }
177 inline char* getStderrFile() { return cVal.stderrFile; }
178 inline bool useDurability() { return cVal.isDurable; }
179 inline int getDurableMode() { return cVal.durableMode; }
180 inline bool useCsqlSqlServer() { return cVal.isCsqlSqlServer; }
181 inline int getPort() { return cVal.port; }
182 inline char* getConflResoFile() { return cVal.conflResoFile; }
183 inline long getMaxQueueLogs() { return cVal.maxQueueLogs; }
184 inline int getMsgKey() { return cVal.msgKey; }
185 inline int getAsyncMsgMax() { return cVal.asyncMsgMax; }
186 inline int getShmIDKey() { return cVal.shmKeyForId; }
187 inline int getNetworkResponseTimeout() { return cVal.nwResponseTimeout; }
188 inline int getNetworkConnectTimeout() { return cVal.nwConnectTimeout; }
189 inline bool useTwoWayCache() { return cVal.isTwoWay; }
190 inline int getCacheWaitSecs() { return cVal.cacheWaitSecs; }
191 inline int getLogLevel() { return cVal.logLevel; }
192 inline int getNoOfProcessors() { return cVal.noOfProcessors; }
193 inline int getStmtCacheSize() { return cVal.stmtCacheSize; }
194 inline bool useCacheNoParam() { return cVal.isCacheNoParam; }
195 inline bool useMonitorServers() { return cVal.isMonitor; }
196 inline int getChkptSecs() { return cVal.chkptSecs; }
197 inline int getChkptRedoLimit() { return cVal.chkptRedoLimit; }
201 class DllExport Conf
203 public:
204 static Config config;
205 static Logger logger;
208 #endif