checkpoint server changes
[csql.git] / include / Config.h
blobbaafc46562f1743549577df637d4d0b26c98d68b
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 UNKNOWN=100
17 enum TDBInfo
19 mysql=0,
20 postgres
23 class ConfigValues
25 public:
26 //All the members of the configuration file
27 char logFile[MAX_FILE_PATH_LEN];
28 char dbFile[MAX_FILE_PATH_LEN];
29 char tableConfigFile[MAX_FILE_PATH_LEN];
30 char dsConfigFile[MAX_FILE_PATH_LEN];// DSN Config file
31 char stderrFile[MAX_FILE_PATH_LEN];
32 char conflResoFile[MAX_FILE_PATH_LEN];
34 bool isDurable;
35 bool mmap;
36 bool isCsqlSqlServer;
37 bool isCache;
38 bool isTwoWay;
40 int siteID;
41 int sysDbKey;
42 int userDbKey;
43 long maxSysSize;
44 long maxDbSize;
45 int pageSize;
46 int maxProcs;
48 long mapAddr;
50 int mutexSecs;
51 int mutexUSecs;
52 int mutexRetries;
53 int lockSecs;
54 int lockUSecs;
55 int lockRetries;
56 int logLevel;
58 int durableMode;
59 char dsn[IDENTIFIER_LENGTH];
60 CacheMode mode;
61 int cacheWaitSecs;
63 int port;
64 int nwResponseTimeout;
65 int nwConnectTimeout;
67 int msgKey;
68 int asyncMsgMax;
69 int shmKeyForId;
70 long maxQueueLogs;
71 int noOfProcessors;
72 int stmtCacheSize;
73 bool isCacheNoParam;
74 bool isMonitor;
75 int chkptSecs;
76 int chkptRedoLimit;
80 ConfigValues()
82 strcpy(logFile, "/tmp/log/log.out");
83 strcpy(dbFile, "/tmp/csql/db");
84 strcpy(tableConfigFile, "/tmp/csql/csqltable.conf");
85 strcpy(dsConfigFile,"/tmp/csql/csqlds.conf"); // DSN Config file
86 strcpy(stderrFile, "stderr");
87 strcpy(conflResoFile, "/tmp/csql/ConflResoFile.txt");
89 isDurable = false;
90 mmap = false;
91 isCsqlSqlServer = false;
92 isCache = false;
93 isTwoWay=false;
95 siteID=1;
96 sysDbKey = 2222;
97 userDbKey = 5555;
98 maxSysSize = 10485760;
99 maxDbSize = 104857600;
100 pageSize = 8192;
101 maxProcs = 20;
103 mapAddr=400000000;
105 mutexSecs=0;
106 mutexUSecs=10;
107 mutexRetries = 10;
108 lockSecs =0;
109 lockUSecs = 10;
110 lockRetries = 10;
111 logLevel = 0;
113 durableMode=1;
114 strcpy(dsn,"myodbc3");
115 mode = SYNC_MODE;
116 cacheWaitSecs =10;
118 port = 5678;
119 nwResponseTimeout=3;
120 nwConnectTimeout=5;
121 msgKey=-1;
122 asyncMsgMax = 8192; //default for linux
123 shmKeyForId = -1;
124 maxQueueLogs = 100;
125 noOfProcessors = 1;
126 stmtCacheSize = 10;
127 isCacheNoParam = false;
128 isMonitor = false;
129 chkptSecs = 600;
130 chkptRedoLimit = 10485760;
135 class Config
137 ConfigValues cVal;
138 bool isLoaded;
139 int readLine(FILE *fp, char * buffer);
140 int storeKeyVal(char *key, char *val);
141 int validateValues();
143 public:
144 Config() { isLoaded = false; }
145 int readAllValues(char *filename);
146 void print();
147 void logConfig();
148 inline int getPageSize() { return cVal.pageSize; }
149 inline int getMaxProcs() { return cVal.maxProcs; }
150 inline long getMaxSysDbSize() { return cVal.maxSysSize; }
151 inline long getMaxDbSize() { return cVal.maxDbSize; }
152 inline int getSysDbKey() { return cVal.sysDbKey; }
153 inline int getUserDbKey() { return cVal.userDbKey; }
154 inline bool useMmap() { return cVal.mmap; }
155 inline char* getLogFile() { return cVal.logFile; }
156 inline char* getDbFile() { return cVal.dbFile; }
157 inline long getMapAddress() { return cVal.mapAddr; }
158 inline int getMutexSecs() { return cVal.mutexSecs; }
159 inline int getMutexUSecs() { return cVal.mutexUSecs; }
160 inline int getMutexRetries() { return cVal.mutexRetries; }
161 inline int getLockSecs() { return cVal.lockSecs; }
162 inline int getLockUSecs() { return cVal.lockUSecs; }
163 inline int getLockRetries() { return cVal.lockRetries; }
164 inline int getSiteID(){ return cVal.siteID;}
165 inline bool useCache() { return cVal.isCache; }
166 inline int getCacheMode() { return (int) cVal.mode; }
167 inline char* getDSN() { return cVal.dsn; }
168 inline char* getDsConfigFile() { return cVal.dsConfigFile; }
169 inline char* getTableConfigFile() { return cVal.tableConfigFile; }
170 inline char* getStderrFile() { return cVal.stderrFile; }
171 inline bool useDurability() { return cVal.isDurable; }
172 inline int getDurableMode() { return cVal.durableMode; }
173 inline bool useCsqlSqlServer() { return cVal.isCsqlSqlServer; }
174 inline int getPort() { return cVal.port; }
175 inline char* getConflResoFile() { return cVal.conflResoFile; }
176 inline long getMaxQueueLogs() { return cVal.maxQueueLogs; }
177 inline int getMsgKey() { return cVal.msgKey; }
178 inline int getAsyncMsgMax() { return cVal.asyncMsgMax; }
179 inline int getShmIDKey() { return cVal.shmKeyForId; }
180 inline int getNetworkResponseTimeout() { return cVal.nwResponseTimeout; }
181 inline int getNetworkConnectTimeout() { return cVal.nwConnectTimeout; }
182 inline bool useTwoWayCache() { return cVal.isTwoWay; }
183 inline int getCacheWaitSecs() { return cVal.cacheWaitSecs; }
184 inline int getLogLevel() { return cVal.logLevel; }
185 inline int getNoOfProcessors() { return cVal.noOfProcessors; }
186 inline int getStmtCacheSize() { return cVal.stmtCacheSize; }
187 inline bool useCacheNoParam() { return cVal.isCacheNoParam; }
188 inline bool useMonitorServers() { return cVal.isMonitor; }
189 inline int getChkptSecs() { return cVal.chkptSecs; }
190 inline int getChkptRedoLimit() { return cVal.chkptRedoLimit; }
194 class Conf
196 public:
197 static Config config;
198 static Logger logger;
201 #endif