From 57df5b44d9ef5a99092db7da053f2da0d1753be2 Mon Sep 17 00:00:00 2001 From: prabatuty Date: Tue, 3 Apr 2007 16:48:41 +0000 Subject: [PATCH] Feature Request ID: 1669025 Abstract:Configuration file reader Description:All the parameters for database system will be set in the configuration file with key, value pair. This needs to be read by the system during startup and used appropriately. --- csql.conf | 35 +++++++++++++++ csql.kdevelop.pcs | Bin 325852 -> 325340 bytes csql.kdevses | 12 ++++- include/CSql.h | 2 +- include/Config.h | 79 ++++++++++++++++++++++++++++++++ include/Makefile.am | 2 +- include/Makefile.in | 2 +- include/README | 15 ------- include/SessionImpl.h | 1 + include/os.h | 20 +++------ src/server/Chunk.c | 1 + src/server/ChunkIterator.c | 1 + src/server/Config.c | 94 +++++++++++++++++++++++++++++++++++++++ src/server/Connection.c | 3 +- src/server/Database.c | 1 + src/server/DatabaseManagerImpl.c | 25 ++++++----- src/server/HashIndex.cpp | 19 -------- src/server/LockManager.c | 9 ++-- src/server/Makefile.am | 2 +- src/server/Makefile.in | 5 ++- src/server/PageInfo.c | 1 + src/server/Server.c | 8 +++- src/server/SessionImpl.c | 46 ++++++++++++++++++- src/server/TableImpl.c | 6 ++- src/server/TransactionManager.c | 3 +- src/server/os.c | 6 +++ 26 files changed, 321 insertions(+), 77 deletions(-) create mode 100644 csql.conf create mode 100644 include/Config.h delete mode 100644 include/README create mode 100644 src/server/Config.c delete mode 100644 src/server/HashIndex.cpp diff --git a/csql.conf b/csql.conf new file mode 100644 index 00000000..b4df911c --- /dev/null +++ b/csql.conf @@ -0,0 +1,35 @@ +# CSQL System Configuration File + +# Page size. Each database is logically divided into pages and allocation happens +# in this unit of pages. Increasing this value will reduce frequent allocation of pages. +PAGE_SIZE= 8192 + +#Total number of active transactions that can run concurrently in the system +MAX_TRANS = 100 + +#Total number of client process/threads which can connect and work with the +# database concurrently +MAX_PROCS = 100 + +# Maximum size of the system database. +MAX_SYS_DB_SIZE=104857600 + +#Maximum size of the user database file. +MAX_DB_SIZE=104857600 + +#Shared memory key to be used by the system to create and locate system database. +SYS_DB_KEY=2222 + +#Shared memory key to be used by the system to create and locate user database. +USER_DB_KEY=5555 + +#Give full path for the log file where important system actions are stored. +LOG_FILE=/tmp/log.out + +#The virtual memory start address at which the shared memory segment +# will be created and attached. +MAP_ADDRESS=400000000 + +#Lock timeout interval seconds +MUTEX_TIMEOUT_SECS=0 +MUTEX_TIMEOUT_USECS=10 diff --git a/csql.kdevelop.pcs b/csql.kdevelop.pcs index 6637338cdef3a72fe297f128340f806ca9c22b6d..f60b5912571085756c6619d1f70be0e0851079e2 100644 GIT binary patch delta 9164 zcwVhJ2~btXvUhq0xhM!k#D(pmpdun9MvWQ;)xnuY-vWFw}tl%)=5#Fy^4nT}*3J4f&o#mv9(pK>em; zc;$D1&3 z3h%33tXl`hzmKtt`Cxpwh}Sb{7dR@^7z0{331idv1Or+sFz)~#VnDk(tGRyY{4w`1 zPzOigrFhW?tB&x72I|lnj6GJ(@5m)B)9HnfC*Q^pe_=qP=}|0+5{U-XC2hS+AM_a} zjI)cF-iq}o0~-52<|R}^@pad`7*dIM>Z_B#tc`VTieu-BMh1G$Ladl8Vht$i2fAL0 z#@|3J0JWX-s_N~QUL-;LXu&TvFc2&2V#r!yXhN*|Krz77Ey7E*=^8rrdpKatFYvfm~KGlqcuyz7n@u1PVI0Fg;*Yc--=PIFyqAEM=G~;g*|!U$k9q|$%~FI7 z^Pt6Wz{dr=hxW+J1>^I1vx36`6K$xdf*EZFDDo!gvk=S$Gob*apmOE1Kij)!Y#)*Rd7c zT<|%T7BY7{?@vpg?O;QsoyN`?Vmu20CwdzqST@|if*Cg-wBig;aF?Ug**Q=&O)zv5 z+r>>?P1yZYWMQj}gb&Dg1p9cSffQ=qAS&vkHb$J4iJ#C)iP}+5sJ8pOegq z9`y-V`=G?F!46#o@P_<`B~Nl6HA#rM%*XvrN4?-<+0D$ zw`9&};Usg;vjnE*J!HoV%!AX3UC_5oynzokvzIXY63bDu_0Z=B))eP`!On1VPP)>` zTexR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#z7KzV6nS$SY z@Jtz5BHjm*|7r4(7jMV#X_;7}Wo`I?oQK46;VAShZvRQ)0?$!+)t|>{YA=UYiUExK zP8o|;{(PGLjIW*%+fgJ6JyS}{j!*=rKm4wFLUtWS9BYLt|UG-T-dm9WKu<7uhTyCMPy+z>4&aMF^C%{R$f65bLEYRIoqF40&9 z)rgzSU?{y~RMdKk{W0!|;a`c(qWjb&1rrl^6_(u= - + + + + + + + + + + + diff --git a/include/CSql.h b/include/CSql.h index f34bc768..be831ac6 100644 --- a/include/CSql.h +++ b/include/CSql.h @@ -22,6 +22,6 @@ #include #include #include - +#include #endif diff --git a/include/Config.h b/include/Config.h new file mode 100644 index 00000000..10de6524 --- /dev/null +++ b/include/Config.h @@ -0,0 +1,79 @@ +/*************************************************************************** + * Copyright (C) 2007 by www.databasecache.com * + * Contact: praba_tuty@databasecache.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + ***************************************************************************/ +#ifndef CONFIG_H +#define CONFIG_H +#include +class ConfigValues +{ + public: + //All the members of the configuration file + int pageSize; + int maxTrans; + int maxProcs; + long maxSysSize; + long maxDbSize; + int sysDbKey; + int userDbKey; + char logFile[256]; + long mapAddr; + int mutexSecs; + int mutexUSecs; + + + ConfigValues() + { + pageSize = 8192; + maxTrans = 20; + maxProcs = 20; + maxSysSize = 104857600; + maxDbSize = 104857600; + sysDbKey = 2222; + userDbKey = 5555; + strcpy(logFile, "/tmp/log.out"); + mapAddr=400000000; + mutexSecs=0; + mutexUSecs=10; + } +}; + +class Config +{ + ConfigValues cVal; + int readLine(FILE *fp, char * buffer); + int storeKeyVal(char *key, char *val); + + public: + int readAllValues(char *filename); + + inline int getPageSize() { return cVal.pageSize; } + inline int getMaxTrans() { return cVal.maxTrans; } + inline int getMaxProcs() { return cVal.maxProcs; } + inline long getMaxSysDbSize() { return cVal.maxSysSize; } + inline long getMaxDbSize() { return cVal.maxDbSize; } + inline int getSysDbKey() { return cVal.sysDbKey; } + inline int getUserDbKey() { return cVal.userDbKey; } + inline char* getLogFile() { return cVal.logFile; } + inline long getMapAddress() { return cVal.mapAddr; } + inline int getMutexSecs() { return cVal.mutexSecs; } + inline int getMutexUSecs() { return cVal.mutexUSecs; } +}; + + +//Global object +static Config config; + + +#endif diff --git a/include/Makefile.am b/include/Makefile.am index b3046f04..92086e7a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -5,4 +5,4 @@ include_HEADERS = Allocator.h CatalogTables.h CSql.h Database.h \ DatabaseManager.h DatabaseManagerImpl.h DataType.h Debug.h ErrorType.h Field.h Index.h \ Info.h Lock.h Mutex.h NanoTimer.h os.h Predicate.h PredicateImpl.h README \ Session.h SessionImpl.h Table.h TableImpl.h Transaction.h UserManager.h \ - UserManagerImpl.h build.h + UserManagerImpl.h build.h Config.h diff --git a/include/Makefile.in b/include/Makefile.in index 72760755..b69bf4ca 100644 --- a/include/Makefile.in +++ b/include/Makefile.in @@ -173,7 +173,7 @@ include_HEADERS = Allocator.h CatalogTables.h CSql.h Database.h \ DatabaseManager.h DatabaseManagerImpl.h DataType.h Debug.h ErrorType.h Field.h Index.h \ Info.h Lock.h Mutex.h NanoTimer.h os.h Predicate.h PredicateImpl.h README \ Session.h SessionImpl.h Table.h TableImpl.h Transaction.h UserManager.h \ - UserManagerImpl.h build.h + UserManagerImpl.h build.h Config.h all: all-am diff --git a/include/README b/include/README deleted file mode 100644 index 1a11811f..00000000 --- a/include/README +++ /dev/null @@ -1,15 +0,0 @@ -User Exposed Files: ------------------- -CSql.h -DatabaseManager.h -UserManager.h -DataType.h -ErrorType.h -Info.h -Table.h -Predicate.h - -Dependent files for user exposed files: ---------------------------------------- -os.h -Field.h diff --git a/include/SessionImpl.h b/include/SessionImpl.h index badf1d65..0c8b7796 100644 --- a/include/SessionImpl.h +++ b/include/SessionImpl.h @@ -56,6 +56,7 @@ class SessionImpl : public Session DbRetVal commit(); DbRetVal rollback(); + DbRetVal readConfigFile(); }; #endif diff --git a/include/os.h b/include/os.h index 026e566f..fd6f3f87 100644 --- a/include/os.h +++ b/include/os.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -83,27 +84,19 @@ enum MapMode }; #define MAX_FILE_LEN 1024 -#define PAGE_SIZE 8192 #define IDENTIFIER_LENGTH 128 #define DEFAULT_VALUE_BUF_LENGTH 32 -#define MAX_CHUNKS 100 -#define MAX_TRANS 100 -#define MAX_PROCESS 100 #define SYSTEMDB "SYSTEMDB" #define DBAUSER "dba" #define DBAPASS "manager" -#define SYSTEM_DB_SIZE 104857600 -#define USER_DB_SIZE 104857600 -#define SYSTEMDB_KEY 2222 -#define USERDB_KEY 5555 -#define LOGFILE "/tmp/log.out" -#define START_ADDR 400000000 +#define LOCK_BUCKET_SIZE 2048 +#define MAX_CHUNKS 20 +#define PAGE_SIZE config.getPageSize() + + typedef key_t shared_memory_key; typedef int shared_memory_id; -#define LOCK_BUCKET_SIZE 2048 -#define MUTEX_TIMEOUT_SECS 0 -#define MUTEX_TIMEOUT_USECS 10 #endif @@ -139,6 +132,7 @@ class os static struct tm* localtime(long *secs); static int getpid(); static int getthrid(); + static char* getenv(const char *envVarName); }; diff --git a/src/server/Chunk.c b/src/server/Chunk.c index de45b0e0..50e397e1 100644 --- a/src/server/Chunk.c +++ b/src/server/Chunk.c @@ -17,6 +17,7 @@ #include #include #include +#include // sets the size of the Chunk allocator for fixed size // allocator diff --git a/src/server/ChunkIterator.c b/src/server/ChunkIterator.c index 84fcf214..7bac2c49 100644 --- a/src/server/ChunkIterator.c +++ b/src/server/ChunkIterator.c @@ -17,6 +17,7 @@ #include #include #include +#include //No iterators for variable size allocators ChunkIterator Chunk::getIterator() diff --git a/src/server/Config.c b/src/server/Config.c new file mode 100644 index 00000000..982392ad --- /dev/null +++ b/src/server/Config.c @@ -0,0 +1,94 @@ +/*************************************************************************** + * Copyright (C) 2007 by www.databasecache.com * + * Contact: praba_tuty@databasecache.com * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + ***************************************************************************/ +#include +int Config::readLine(FILE *fp, char * buffer) +{ + char c =0; + int count =0; + while ( true) + { + c = fgetc(fp); + if (c == '\n') break; + if (c == EOF) return EOF; + buffer[count++] = c; + } + return count; +} +int Config::storeKeyVal(char *key, char *value) +{ + if (strcasestr(key, "PAGE_SIZE") != NULL ) + { cVal.pageSize = atoi(value); } + else if (strcasestr(key, "MAX_TRANS") != NULL) + { cVal.maxTrans = atoi(value); } + else if (strcasestr(key, "MAX_PROCS") != NULL) + { cVal.maxProcs = atoi(value); } + else if (strcasestr(key, "MAX_SYS_DB_SIZE") != NULL) + { cVal.maxSysSize = atol(value); } + else if (strcasestr(key, "MAX_DB_SIZE") != NULL) + { cVal.maxDbSize = atol(value); } + else if (strcasestr(key, "SYS_DB_KEY") != NULL) + { cVal.sysDbKey = atoi(value); } + else if (strcasestr(key, "USER_DB_KEY") != NULL) + { cVal.userDbKey = atoi(value); } + else if (strcasestr(key, "LOG_FILE") != NULL) + { strcpy(cVal.logFile , value); } + else if (strcasestr(key, "MAP_ADDRESS") != NULL) + { cVal.mapAddr = atol(value); } + else if (strcasestr(key, "MUTEX_TIMEOUT_SECS") != NULL) + { cVal.mutexSecs = atoi(value); } + else if (strcasestr(key, "MUTEX_TIMEOUT_USECS") != NULL) + { cVal.mutexUSecs = atoi(value); } + else return 1; + return 0; +} +int Config::readAllValues(char *fileName) +{ + FILE *fp; + fp = fopen(fileName,"r"); + int hasData = 1; + char buffer[1024]; + char key[1024]; + char value[1024]; + while (hasData) + { + memset(buffer, 0, 1024); + //int ret = fscanf(fp,"%s\r",buffer); + int ret = readLine(fp, buffer); + if (ret == EOF) break; + bool isComment= false; + int posEqual =0; + for (int i = 0; i <1024; i++) + { + if (buffer[i] == '=' ) posEqual=i; + if (buffer[i] == '#' ) { isComment = true; break; } + if (buffer[i] == '\n') { break; } + if (buffer[i] == '\0') { break; } + } + if (isComment) continue; + if (!posEqual) continue; + strncpy(key, buffer, posEqual); + key[posEqual] = '\0'; + posEqual++; + strcpy(value, &buffer[posEqual]); + storeKeyVal(key, value); + } + fclose(fp); + return 0; +} + + + + diff --git a/src/server/Connection.c b/src/server/Connection.c index 200058ed..dc31a054 100644 --- a/src/server/Connection.c +++ b/src/server/Connection.c @@ -17,6 +17,7 @@ #include #include #include +#include Connection::~Connection() { delete session; @@ -26,7 +27,7 @@ Connection::~Connection() DbRetVal Connection::open(const char *username, const char *password) { if (session == NULL) session = new SessionImpl(); - DbRetVal rv = logger.startLogger(LOGFILE); + DbRetVal rv = logger.startLogger(config.getLogFile()); if (rv != OK) { delete session; session = NULL; return rv; } logFinest(logger, "User logged in %s",username); return session->open(username, password); diff --git a/src/server/Database.c b/src/server/Database.c index 6c5b7943..71f372f6 100644 --- a/src/server/Database.c +++ b/src/server/Database.c @@ -19,6 +19,7 @@ #include #include #include +#include const char* Database::getName() { diff --git a/src/server/DatabaseManagerImpl.c b/src/server/DatabaseManagerImpl.c index d12a3aeb..5f6563f6 100644 --- a/src/server/DatabaseManagerImpl.c +++ b/src/server/DatabaseManagerImpl.c @@ -24,6 +24,7 @@ #include #include #include +#include DatabaseManagerImpl::~DatabaseManagerImpl() { @@ -84,17 +85,17 @@ DbRetVal DatabaseManagerImpl::createDatabase(const char *name, size_t size) caddr_t rtnAddr = (caddr_t) NULL; shared_memory_id shm_id = 0; - char *startaddr = (char*)START_ADDR; + char *startaddr = (char*)config.getMapAddress(); shared_memory_key key = 0; if (0 == strcmp(name, SYSTEMDB)) { - key = SYSTEMDB_KEY; + key = config.getSysDbKey(); } else { startaddr = startaddr + size; - key = USERDB_KEY; + key = config.getUserDbKey(); } shm_id = os::shm_create(key, size, 0666); if (-1 == shm_id) @@ -131,8 +132,8 @@ DbRetVal DatabaseManagerImpl::createDatabase(const char *name, size_t size) if (0 == strcmp(name, SYSTEMDB)) { offset = offset + os::alignLong( MAX_CHUNKS * sizeof (Chunk)); - offset = offset + os::alignLong( MAX_TRANS * sizeof(Transaction)); - offset = offset + os::alignLong( MAX_PROCESS * sizeof(int)); + offset = offset + os::alignLong( config.getMaxTrans() * sizeof(Transaction)); + offset = offset + os::alignLong( config.getMaxProcs() * sizeof(int)); } int multiple = os::floor(offset / PAGE_SIZE); char *curPage = (((char*)rtnAddr) + ((multiple + 1) * PAGE_SIZE)); @@ -163,10 +164,10 @@ DbRetVal DatabaseManagerImpl::deleteDatabase(const char *name) shared_memory_id shm_id = 0; if (0 == strcmp(name, SYSTEMDB)) { - shm_id = os::shm_open(SYSTEMDB_KEY, 100, 0666); + shm_id = os::shm_open(config.getSysDbKey(), 100, 0666); os::shmctl(shm_id, IPC_RMID); } else { - shm_id = os::shm_open(USERDB_KEY, 100, 0666); + shm_id = os::shm_open(config.getUserDbKey(), 100, 0666); os::shmctl(shm_id, IPC_RMID); } logFinest(logger, "Deleted database %s" , name); @@ -176,8 +177,8 @@ DbRetVal DatabaseManagerImpl::deleteDatabase(const char *name) DbRetVal DatabaseManagerImpl::openDatabase(const char *name) { - size_t size = SYSTEM_DB_SIZE; - char *startaddr = (char*)START_ADDR; + size_t size = config.getMaxSysDbSize(); + char *startaddr = (char*)config.getMapAddress(); if (0 == strcmp(name , SYSTEMDB)) { if (NULL !=systemDatabase_) @@ -194,7 +195,7 @@ DbRetVal DatabaseManagerImpl::openDatabase(const char *name) printError(ErrNotOpen, "System Database not open"); return ErrNotOpen; } - size = USER_DB_SIZE; + size = config.getMaxDbSize(); startaddr = startaddr + size; } if (NULL != db_) @@ -209,9 +210,9 @@ DbRetVal DatabaseManagerImpl::openDatabase(const char *name) shared_memory_key key = 0; if (0 == strcmp(name, SYSTEMDB)) - key = SYSTEMDB_KEY; + key = config.getSysDbKey(); else - key = USERDB_KEY; + key = config.getUserDbKey(); shm_id = os::shm_open(key, size, 0666); if (shm_id == -1) { diff --git a/src/server/HashIndex.cpp b/src/server/HashIndex.cpp deleted file mode 100644 index 4c214a06..00000000 --- a/src/server/HashIndex.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Prabakaran Thirumalai * - * praba_tuty@yahoo.com * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ diff --git a/src/server/LockManager.c b/src/server/LockManager.c index afee5f47..4305cba9 100644 --- a/src/server/LockManager.c +++ b/src/server/LockManager.c @@ -19,6 +19,7 @@ #include #include #include +#include Bucket* LockManager::getLockBucket(void *tuple) { @@ -169,8 +170,8 @@ DbRetVal LockManager::getSharedLock(void *tuple, Transaction **trans) int tries = 0; int ret = 0; struct timeval timeout; - timeout.tv_sec = MUTEX_TIMEOUT_SECS; - timeout.tv_usec = MUTEX_TIMEOUT_USECS; + timeout.tv_sec = config.getMutexSecs(); + timeout.tv_usec = config.getMutexUSecs(); //printDebug(DM_Lock, "Trying to get mutex: for bucket %x\n", bucket); while (tries < 100) @@ -311,8 +312,8 @@ DbRetVal LockManager::getExclusiveLock(void *tuple, Transaction **trans) int tries = 0; int ret = 0; struct timeval timeout; - timeout.tv_sec = MUTEX_TIMEOUT_SECS; - timeout.tv_usec = MUTEX_TIMEOUT_USECS; + timeout.tv_sec = config.getMutexSecs(); + timeout.tv_usec = config.getMutexUSecs(); while (tries < 100) { diff --git a/src/server/Makefile.am b/src/server/Makefile.am index 4749db5b..3f77ea8c 100644 --- a/src/server/Makefile.am +++ b/src/server/Makefile.am @@ -6,7 +6,7 @@ libcsql_la_SOURCES = BucketIter.c BucketList.c CatalogTables.c Chunk.c \ ChunkIterator.c Condition.c Connection.c Database.c DatabaseManagerImpl.c DataType.c \ Debug.c FieldList.c Index.c LockListIter.c LockManager.c Logger.c Mutex.c os.c \ PageInfo.c PredicateImpl.c SessionImpl.c TableDef.c TableImpl.c Transaction.c \ - TransactionManager.c TupleIterator.c UserManagerImpl.c HashIndex.c + TransactionManager.c TupleIterator.c UserManagerImpl.c HashIndex.c Config.c bin_PROGRAMS = csqlserver csqlserver_SOURCES = Server.c csqlserver_LDADD = $(top_builddir)/src/server/libcsql.la -lrt -lpthread -lcrypt diff --git a/src/server/Makefile.in b/src/server/Makefile.in index b4b78ceb..6df061a9 100644 --- a/src/server/Makefile.in +++ b/src/server/Makefile.in @@ -63,7 +63,7 @@ am_libcsql_la_OBJECTS = BucketIter.lo BucketList.lo CatalogTables.lo \ FieldList.lo Index.lo LockListIter.lo LockManager.lo Logger.lo \ Mutex.lo os.lo PageInfo.lo PredicateImpl.lo SessionImpl.lo \ TableDef.lo TableImpl.lo Transaction.lo TransactionManager.lo \ - TupleIterator.lo UserManagerImpl.lo HashIndex.lo + TupleIterator.lo UserManagerImpl.lo HashIndex.lo Config.lo libcsql_la_OBJECTS = $(am_libcsql_la_OBJECTS) binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) @@ -200,7 +200,7 @@ libcsql_la_SOURCES = BucketIter.c BucketList.c CatalogTables.c Chunk.c \ ChunkIterator.c Condition.c Connection.c Database.c DatabaseManagerImpl.c DataType.c \ Debug.c FieldList.c Index.c LockListIter.c LockManager.c Logger.c Mutex.c os.c \ PageInfo.c PredicateImpl.c SessionImpl.c TableDef.c TableImpl.c Transaction.c \ - TransactionManager.c TupleIterator.c UserManagerImpl.c HashIndex.c + TransactionManager.c TupleIterator.c UserManagerImpl.c HashIndex.c Config.c csqlserver_SOURCES = Server.c csqlserver_LDADD = $(top_builddir)/src/server/libcsql.la -lrt -lpthread -lcrypt @@ -310,6 +310,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Chunk.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChunkIterator.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Condition.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Config.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Connection.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DataType.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Database.Plo@am__quote@ diff --git a/src/server/PageInfo.c b/src/server/PageInfo.c index a15adf51..a86f195c 100644 --- a/src/server/PageInfo.c +++ b/src/server/PageInfo.c @@ -15,6 +15,7 @@ ***************************************************************************/ #include #include +#include void PageInfo::setPageAsUsed(size_t offset) { diff --git a/src/server/Server.c b/src/server/Server.c index 67b44ae2..01582eed 100644 --- a/src/server/Server.c +++ b/src/server/Server.c @@ -27,9 +27,15 @@ static void sigTermHandler(int sig) int main() { SessionImpl session; + DbRetVal rv = session.readConfigFile(); + if (rv != OK) + { + printf("Unable to read the configuration file \n"); + return -1; + } os::signal(SIGINT, sigTermHandler); os::signal(SIGTERM, sigTermHandler); - DbRetVal rv = logger.startLogger(LOGFILE, true); + rv = logger.startLogger(config.getLogFile(), true); if (rv != OK) { printf("Unable to start the logger\n"); diff --git a/src/server/SessionImpl.c b/src/server/SessionImpl.c index 6536217a..1224f3d6 100644 --- a/src/server/SessionImpl.c +++ b/src/server/SessionImpl.c @@ -22,17 +22,40 @@ #include #include #include +#include +//Before calling this method, application is required to call readConfigValues DbRetVal SessionImpl::initSystemDatabase() { DbRetVal rv = OK; + rv = readConfigFile(); + if (rv != OK) + { + printError(ErrSysInit, "Configuration file read failed\n"); + return ErrSysInit; + } + printf("ConfigValues\n"); + printf(" getPageSize %d\n", config.getPageSize()); + printf(" getMaxTrans %d\n", config.getMaxTrans()); + printf(" getMaxProcs %d\n", config.getMaxProcs()); + printf(" getMaxSysDbSize %ld\n", config.getMaxSysDbSize()); + printf(" getMaxDbSize %ld\n", config.getMaxDbSize()); + printf(" getSysDbKey %d\n", config.getSysDbKey()); + printf(" getUserDbKey %d\n", config.getUserDbKey()); + printf(" getLogFile %s\n", config.getLogFile()); + printf(" getMapAddress %ld\n", config.getMapAddress()); + printf(" getMutexSecs %d\n", config.getMutexSecs()); + printf(" getMutexUSecs %d\n", config.getMutexUSecs()); + + dbMgr = new DatabaseManagerImpl(); + //TODO:Size of system database 100 MB ->config parameter //TODO:No of chunks of system database->config parameter //This limits the total number of catalog tables system shall support. - rv = dbMgr->createDatabase(SYSTEMDB, SYSTEM_DB_SIZE); + rv = dbMgr->createDatabase(SYSTEMDB, config.getMaxSysDbSize()); if (OK != rv) return rv; dbMgr->setSysDb(dbMgr->db()); dbMgr->setDb(NULL); @@ -64,7 +87,7 @@ DbRetVal SessionImpl::initSystemDatabase() db->releaseDatabaseMutex(); //create user database - rv = dbMgr->createDatabase("praba", USER_DB_SIZE); + rv = dbMgr->createDatabase("praba", config.getMaxDbSize()); if (OK != rv) return rv; return OK; } @@ -82,6 +105,12 @@ DbRetVal SessionImpl::destroySystemDatabase() DbRetVal SessionImpl::open(const char *username, const char *password) { DbRetVal rv = OK; + rv = readConfigFile(); + if (rv != OK) + { + printError(ErrSysFatal, "Configuration file read failed\n"); + return ErrSysFatal; + } if ( NULL == dbMgr) { dbMgr = new DatabaseManagerImpl(); @@ -227,3 +256,16 @@ DbRetVal SessionImpl::rollback() } return OK; } + +DbRetVal SessionImpl::readConfigFile() +{ + char *confFilename = os::getenv("CSQL_CONFIG_FILE"); + if (confFilename == NULL) + { + printError(ErrSysInit, "CSQL_CONFIG_FILE environment variable should be set."); + return ErrSysInit; + } + int rv = config.readAllValues(confFilename); + if (rv == OK) return OK; else return ErrSysInit; +} + diff --git a/src/server/TableImpl.c b/src/server/TableImpl.c index 7ad5bfcf..f8f53706 100644 --- a/src/server/TableImpl.c +++ b/src/server/TableImpl.c @@ -22,6 +22,7 @@ #include #include #include +#include void TableImpl::bindFld(const char *name, void *val) { @@ -159,8 +160,9 @@ void* TableImpl::fetch() //so release it here itself. int tries = 5; struct timeval timeout; - timeout.tv_sec = MUTEX_TIMEOUT_SECS; - timeout.tv_usec = MUTEX_TIMEOUT_USECS; + timeout.tv_sec = config.getMutexSecs(); + timeout.tv_usec = config.getMutexUSecs(); + bool status = false; while(true) { lockRet = lMgr_->isExclusiveLocked( curTuple_, status); diff --git a/src/server/TransactionManager.c b/src/server/TransactionManager.c index c8340d9d..1bf84e9a 100644 --- a/src/server/TransactionManager.c +++ b/src/server/TransactionManager.c @@ -19,6 +19,7 @@ #include #include #include +#include DbRetVal TransactionManager::startTransaction(IsolationLevel level) { if (NULL != trans) @@ -33,7 +34,7 @@ DbRetVal TransactionManager::startTransaction(IsolationLevel level) } Transaction *iter = firstTrans; //get free slot from transaction table - for (int i =0 ; i < MAX_TRANS; i++) + for (int i =0 ; i < config.getMaxTrans(); i++) { if (iter->status_ == TransNotUsed) break; iter++; diff --git a/src/server/os.c b/src/server/os.c index c4ba086f..2a59d977 100644 --- a/src/server/os.c +++ b/src/server/os.c @@ -161,3 +161,9 @@ int os::select(int nfds, fd_set *readfds, fd_set *writefds, } +char* os::getenv(const char *envVarName) +{ + char *retVal; + retVal = ::getenv(envVarName); + return retVal; +} -- 2.11.4.GIT