[-]
[+]
|
Changed |
cego.changes
|
|
[-]
[+]
|
Changed |
cego.spec
^
|
|
[-]
[+]
|
Deleted |
cego-2.10.11.tar.bz2/src/#CegoMain.cc#
^
|
@@ -1,1611 +0,0 @@
-///////////////////////////////////////////////////////////////////////////////
-//
-// CegoMain.cc
-// -----------
-// Cego main module
-//
-// Design and Implementation by Bjoern Lemke
-//
-// (C)opyright 2000-2010 Bjoern Lemke
-//
-// 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, 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; see the file COPYING. If not, write to
-// the Free Software Foundation, 59 Temple Place - Suite 330,
-// Boston, MA 02111-1307, USA.
-//
-// IMPLEMENTATION MODULE
-//
-// Class: Main
-//
-// Description: Main module for the cego database program. The program can be invoked in different modes.
-//
-// Status: QG-2.6
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#include <locale.h>
-#include <stdlib.h>
-
-#include <lfc/Sleeper.h>
-#include <lfc/Process.h>
-#include <lfc/GetLongOpt.h>
-#include <lfc/File.h>
-#include <lfc/Timer.h>
-#include <lfc/Tokenizer.h>
-#include <lfc/Exception.h>
-#include <lfc/Host.h>
-#include <lfc/AESCrypt.h>
-#include <lfc/SigHandler.h>
-
-#include <lfc/XMLSuite.h>
-
-#include "CegoDbThreadPool.h"
-#include "CegoLogThreadPool.h"
-#include "CegoAdminThreadPool.h"
-
-#include "CegoDatabaseManager.h"
-#include "CegoDistManager.h"
-#include "CegoAction.h"
-#include "CegoXMLdef.h"
-#include "CegoBeatThread.h"
-#include "CegoMediatorThread.h"
-#include "CegoBeatConnection.h"
-#include "CegoXPorter.h"
-#include "CegoXMLdef.h"
-#include "CegoModule.h"
-#include "CegoCheckpoint.h"
-
-#define USAGE "Usage:\n\n\
- Info: cego [ --version ] [ --help ]\n\
- Adm pwd setup: cego --mode=setadminuser --user=<user>/<password> --dbxml=<db xml>\n\
- Usr pwd setup: cego --mode=setdbuser --user=<user>/<password> --tableset=<tableset> --dbxml=<db xml> [ --role=<role> ]\n\
- Define Mode: cego --mode=define --tsdef=<db attr string> --tableset=<tableset> --dbxml=<db xml>\n\
- Creation Mode: cego --mode=create --tableset=<tableset> --dbxml=<db xml>\n\
- Export Mode: cego --mode=<xmlexport|binexport|plainexport> --expfile=<exportfile> --tableset=<tableset> --dbxml=<db xml>\n\
-\n\
- Import Mode: cego --mode=<xmlimport|binimport|plainimport> --impfile=<importfile> --tableset=<tableset> --dbxml=<db xml> [ --noLogging ]\n\
-\n\
- Batch Mode: cego --mode=batch --batchfile=<batchfile> --tableset=<tableset> --dbxml=<db xml> [ --poolsize=<poolsize> ] [ --ignore ]\n\
- Daemon Mode: cego --mode=daemon --dbxml=<db xml> [--tableset=<tableset>,<tableset>,... ] [ --cleanup ] [ --forceload ] [ --nolockstat ] [ --numdbthread=<numdb> ] [ --numadminthread=<numadm> ] [ --numlogthread=<numlog> ] [ --poolsize=<poolsize> ] [ --pidfile=<pidfile> ] [ --mediator=<host:port:user:passwd,...> ]\n\
-\n\
- General Options : [ --logfile=<logfile> ] [ --lockfile=<lockfile> ]\n"
-
-// DEFINES
-#define DEFAULTLOGFILE "cego.log"
-#define DEFAULTLOCKFILE "/tmp/cego.lock"
-#define DEFAULTPOOLSIZE 1000
-#define DEFAULTDBTHREADNUM 10
-#define DEFAULTADMINTHREADNUM 5
-#define DEFAULTLOGTHREADNUM 3
-#define DEFAULTBEATPORT 2000
-#define DEFAULTBEATUSER "cgadm"
-#define DEFAULTBEATPWD "cgadm"
-#define DEFAULTROLE XML_ROLE_ALL_VALUE
-#define DEFAULTTMPSIZE 100
-#define DEFAULTSYSSIZE 100
-#define DEFAULTLOGNUM 3
-#define DEFAULTLOGSIZE 1000000
-#define DEFAULTORDERSIZE 10000000
-#define DEFAULTTSROOT "./"
-#define DEFAULTPRIMARY "localhost"
-#define DEFAULTSECONDARY "localhost"
-#define DEFAULTTSTICKET "tsticket.xml"
-#define DEFAULTAPPFILENAME "./data01.dbf"
-#define DEFAULTAPPFILESIZE 1000
-
-#define MAXCMDLEN 10000
-
-#define LANGUAGE_ENV "LANG"
-#define LOCALE_CATEGORY LC_TIME
-
-extern char __lfcVersionString[];
-extern char __lfcxmlVersionString[];
-extern char __caseSensitiveFlag;
-extern char __quoteEscapeFlag;
-extern Chain __dateFormatString;
-extern bool __lockStatOn;
-
-enum XPortFormat { BINARY, XML, PLAIN };
-
-int setAdminUser(GetLongOpt& longOpt);
-int setDbUser(GetLongOpt& longOpt);
-int defineTableSet(GetLongOpt& longOpt);
-int createTableSet(GetLongOpt& longOpt);
-int importTableSet(GetLongOpt& longOpt, XPortFormat format);
-int exportTableSet(GetLongOpt& longOpt, XPortFormat format);
-int runBatch(GetLongOpt& longOpt);
-int runDaemon(GetLongOpt& longOpt);
-bool processBatchFile(CegoDatabaseManager *pDBMng, CegoAction *pAction, const Chain& batchFileName, bool ignoreError, bool consoleOut, Chain& errorMsg);
-
-int main(int argc, char **argv)
-{
-
- GetLongOpt longOpt(argc, argv);
-
- longOpt.addOpt("version");
- longOpt.addOpt("help");
- longOpt.addOpt("mode");
- longOpt.addOpt("user");
- longOpt.addOpt("dbxml");
- longOpt.addOpt("tableset");
- longOpt.addOpt("cleanup");
- longOpt.addOpt("forceload");
- longOpt.addOpt("nolockstat");
- longOpt.addOpt("role", DEFAULTROLE);
- longOpt.addOpt("tsdef");
- longOpt.addOpt("nologging");
- longOpt.addOpt("expfile");
- longOpt.addOpt("impfile");
- longOpt.addOpt("batchfile");
- longOpt.addOpt("poolsize", Chain(DEFAULTPOOLSIZE));
- longOpt.addOpt("ignore");
- longOpt.addOpt("daemon");
- longOpt.addOpt("numdbthread", Chain(DEFAULTDBTHREADNUM));
- longOpt.addOpt("numadminthread", Chain(DEFAULTADMINTHREADNUM));
- longOpt.addOpt("numlogthread", Chain(DEFAULTLOGTHREADNUM));
- longOpt.addOpt("mediator");
- longOpt.addOpt("logfile", DEFAULTLOGFILE);
- longOpt.addOpt("lockfile", DEFAULTLOCKFILE);
- longOpt.addOpt("pidfile");
-
- try
- {
- longOpt.parseOpt();
- }
- catch ( Exception e )
- {
- Chain msg;
- e.pop(msg);
- cerr << msg << endl;
- cerr << USAGE << endl;
- exit(1);
- }
-
- // set localization
- char* lang = 0;
- if ( ( lang = getenv(LANGUAGE_ENV) ) != 0)
- {
- if ( setlocale(LOCALE_CATEGORY, lang) == 0)
- {
- Chain msg = Chain("Cannot set locale ") + Chain(lang);
- cerr << msg << endl;
- exit(1);
- }
- }
- // for random generation in CegoFunction
- int seed = 5 * (time(NULL) % 100000);
- srand( seed );
-
- if ( longOpt.isSet( Chain("help") ) )
- {
- cerr << USAGE << endl;
- exit(0);
- }
-
- if ( longOpt.isSet( Chain("version") ) )
- {
- cout << CEGO_PRODUCT << " (" << sizeof(long) * 8 << " bit), Version " << CEGO_VERSION
- << " [ lfc : " << __lfcVersionString
- << ", lfcxml : " << __lfcxmlVersionString << " ]" << endl;
- cout << CEGO_COPYRIGHT << endl;
- exit(0);
- }
-
- if ( longOpt.isSet("nolockstat") )
- __lockStatOn = false;
-
- Chain mode = longOpt.getOptValue("mode");
-
- int exitCode = 0;
-
- if ( mode == Chain("setadminuser") )
- {
- exitCode = setAdminUser(longOpt);
- }
- else if ( mode == Chain("setdbuser") )
- {
- exitCode = setDbUser(longOpt);
- }
- else if ( mode == Chain("define") )
- {
- exitCode = defineTableSet(longOpt);
- }
- else if ( mode == Chain("create") )
- {
- exitCode = createTableSet(longOpt);
- }
- else if ( mode == Chain("xmlimport") )
- {
- exitCode = importTableSet(longOpt, XML);
- }
- else if ( mode == Chain("binimport") )
- {
- exitCode = importTableSet(longOpt, BINARY);
- }
- else if ( mode == Chain("plainimport") )
- {
- exitCode = importTableSet(longOpt, PLAIN);
- }
- else if ( mode == Chain("xmlexport") )
- {
- exitCode = exportTableSet(longOpt, XML);
- }
- else if ( mode == Chain("binexport") )
- {
- exitCode = exportTableSet(longOpt, BINARY);
- }
- else if ( mode == Chain("plainexport") )
- {
- exitCode = exportTableSet(longOpt, PLAIN);
- }
- else if ( mode == Chain("batch") )
- {
- exitCode = runBatch(longOpt);
- }
- else if ( mode == Chain("daemon") )
- {
- exitCode = runDaemon(longOpt);
- }
- else
- {
- cerr << USAGE << endl;
- exit(0);
- }
-
- exit(exitCode);
-}
-
-int setAdminUser(GetLongOpt& longOpt)
-{
-
- int exitCode = 0;
-
- CegoDatabaseManager* pDBMng = 0;
-
- try {
-
- Chain logFile = longOpt.getOptValue("logfile");
- Chain lockFile = longOpt.getOptValue("lockfile");
- Chain dbXML = longOpt.getOptValue("dbxml");
- Chain admString = longOpt.getOptValue("user");
-
- Tokenizer admTok(admString, Chain("/"));
-
- Chain user;
- Chain password;
-
- admTok.nextToken(user);
- admTok.nextToken(password);
-
- if ( dbXML.length() == 0 || dbXML == Chain("") )
- {
- throw Exception(EXLOC, "No dbxml set");
- }
- if ( user.length() == 0 || user == Chain("") )
- {
- throw Exception(EXLOC, "No user set");
- }
- if ( password.length() == 0 || password == Chain("") )
- {
- throw Exception(EXLOC, "No password set");
- }
-
- pDBMng = new CegoDatabaseManager(dbXML, lockFile, logFile);
-
- pDBMng->xml2Doc();
- pDBMng->configureLogger();
-
- // Crypt c(password, CEGOSALT);
- // pDBMng->setAdminUser(user, c.getEncryption());
-
- AESCrypt aescrypt(CEGOAESKEY, CEGOAESKEYLEN);
- pDBMng->setAdminUser(user, aescrypt.encrypt(password));
-
- pDBMng->doc2Xml();
-
- delete pDBMng;
- }
- catch ( Exception e)
- {
-
- if ( pDBMng )
- delete pDBMng;
-
- Chain msg;
- e.pop(msg);
- cerr << msg << endl;
- exitCode = 1;
- }
- return exitCode;
-}
-
-int setDbUser(GetLongOpt& longOpt)
-{
- int exitCode = 0;
-
- CegoDatabaseManager* pDBMng = 0;
-
- try {
-
- Chain logFile = longOpt.getOptValue("logfile");
- Chain lockFile = longOpt.getOptValue("lockfile");
- Chain dbXML = longOpt.getOptValue("dbxml");
- Chain userRole = longOpt.getOptValue("role");
- Chain tableSet = longOpt.getOptValue("tableset");
-
- Chain userString = longOpt.getOptValue("user");
-
- Tokenizer userTok(userString, Chain("/"));
-
- Chain user;
- Chain password;
-
- userTok.nextToken(user);
- userTok.nextToken(password);
-
- if ( dbXML.length() == 0 || dbXML == Chain("") )
- {
- throw Exception(EXLOC, "No dbxml set");
- }
- if ( user.length() == 0 || user == Chain("") )
- {
- throw Exception(EXLOC, "No user set");
- }
- if ( password.length() == 0 || password == Chain("") )
- {
- throw Exception(EXLOC, "No password set");
- }
- if ( tableSet.length() == 1 || tableSet == Chain("") )
- {
- throw Exception(EXLOC, "No tableset set");
- }
-
- pDBMng = new CegoDatabaseManager(dbXML, lockFile, logFile);
-
- pDBMng->xml2Doc();
- pDBMng->configureLogger();
-
- // Crypt c(password, CEGOSALT);
- // pDBMng->setDbUser(tableSet, user, c.getEncryption());
-
- AESCrypt aescrypt(CEGOAESKEY, CEGOAESKEYLEN);
- pDBMng->setDbUser(tableSet, user, aescrypt.encrypt(password));
-
-
- pDBMng->addUserRole(tableSet, user, userRole);
-
- pDBMng->doc2Xml();
-
- delete pDBMng;
-
- }
- catch ( Exception e)
- {
- if ( pDBMng )
- delete pDBMng;
-
- Chain msg;
- e.pop(msg);
- cerr << msg << endl;
- exitCode = 1;
- }
-
- return exitCode;
-}
-
-int defineTableSet(GetLongOpt& longOpt)
-{
-
- int exitCode = 0;
-
- CegoDatabaseManager* pDBMng = 0;
-
- try {
-
- Chain logFile = longOpt.getOptValue("logfile");
- Chain lockFile = longOpt.getOptValue("lockfile");
- Chain dbXML = longOpt.getOptValue("dbxml");
- Chain tableSet = longOpt.getOptValue("tableset");
- Chain tsDef = longOpt.getOptValue("tsdef");
-
- if ( dbXML.length() == 0 || dbXML == Chain("") )
- {
- throw Exception(EXLOC, "No dbxml set");
- }
- if ( tableSet.length() == 0 || tableSet == Chain("") )
- {
- throw Exception(EXLOC, "No tableSet set");
- }
- if ( tsDef.length() == 0 || tsDef == Chain("") )
- {
- throw Exception(EXLOC, "No tsdef set");
- }
-
- pDBMng = new CegoDatabaseManager(dbXML, lockFile, logFile);
-
- pDBMng->xml2Doc();
- pDBMng->configureLogger();
-
- Chain tsRoot(DEFAULTTSROOT);
- Chain tsTicket(DEFAULTTSTICKET);
-
- int sysSize = DEFAULTSYSSIZE;
- int tmpSize = DEFAULTTMPSIZE;
- int logFileSize = DEFAULTLOGSIZE;
- int logFileNum = DEFAULTLOGNUM;
-
- Chain appFileName = DEFAULTAPPFILENAME;
- int appFileSize = DEFAULTAPPFILESIZE;
- long orderSize = DEFAULTORDERSIZE;
-
- Tokenizer atok(tsDef, Chain(","));
-
- Chain attrTup;
- while ( atok.nextToken(attrTup) )
- {
- Tokenizer vtok(attrTup, Chain(":"));
- Chain attr;
- Chain value;
- vtok.nextToken(attr);
- vtok.nextToken(value);
- if ( attr == Chain("syssize"))
- sysSize = value.asInteger();
- else if ( attr == Chain("tmpsize"))
- tmpSize = value.asInteger();
- else if ( attr == Chain("logfilesize"))
- logFileSize = value.asInteger();
- else if ( attr == Chain("logfilenum"))
- logFileNum = value.asInteger();
- else if ( attr == Chain("tsticket"))
- tsTicket = value;
- else if ( attr == Chain("tsroot"))
- tsRoot = value;
- else if ( attr == Chain("appfile"))
- appFileName = value;
- else if ( attr == Chain("appsize"))
- appFileSize = value.asInteger();
- else if ( attr == Chain("ordersize"))
- orderSize = value.asLong();
-
- }
-
- Host h;
- int sysFid = pDBMng->nextTSID();
- int tmpFid = pDBMng->nextFID();
-
- pDBMng->addTableSetDef(tableSet,
- tsRoot,
- tsTicket,
- h.getName(),
- h.getName(),
- h.getName(),
- sysFid,
- tmpFid,
- sysSize,
- tmpSize,
- logFileSize,
- logFileNum,
- orderSize);
-
-
- int appFid = pDBMng->nextFID();
- pDBMng->addDataFile(tableSet, Chain(XML_APPFILE_VALUE), appFid, appFileName, appFileSize);
-
- pDBMng->doc2Xml();
-
- delete pDBMng;
-
- }
- catch (Exception e)
- {
-
- if ( pDBMng )
- delete pDBMng;
-
- Chain msg;
- e.pop(msg);
- cerr << msg << endl;
- exitCode = 1;
- }
-
- return exitCode;
-}
-
-int createTableSet(GetLongOpt& longOpt)
-{
-
- int exitCode = 0;
-
- CegoDatabaseManager* pDBMng = 0;
-
- try {
-
- Chain logFile = longOpt.getOptValue("logfile");
- Chain lockFile = longOpt.getOptValue("lockfile");
- Chain dbXML = longOpt.getOptValue("dbxml");
- Chain tableSet = longOpt.getOptValue("tableset");
- Chain poolSize = longOpt.getOptValue("poolsize");
-
- if ( dbXML.length() == 0 || dbXML == Chain("") )
- {
- throw Exception(EXLOC, "No dbxml set");
- }
- if ( tableSet.length() == 0 || tableSet == Chain("") )
- {
- throw Exception(EXLOC, "No tableSet set");
- }
-
- pDBMng = new CegoDatabaseManager(dbXML, lockFile, logFile);
-
- pDBMng->initPool(poolSize.asInteger());
- pDBMng->configureLogger();
- unsigned long modId = pDBMng->getModId("CegoMain");
-
- pDBMng->log(modId, Logger::NOTICE, Chain("Creating tableset ") + tableSet + Chain(" ..."));
-
- CegoLockHandler* pLockHandler = new CegoLockHandler(pDBMng);
-
- pLockHandler->initLocks();
-
- CegoTableManager tabMng(pDBMng);
-
- tabMng.createTableSet(tableSet);
-
- pDBMng->log(modId, Logger::NOTICE, Chain("Tableset ") + tableSet + Chain(" created"));
-
- pLockHandler->deleteLocks();
- delete pDBMng;
- delete pLockHandler;
-
- }
- catch (Exception e)
- {
- if ( pDBMng )
- delete pDBMng;
-
- Chain msg;
- e.pop(msg);
- cerr << msg << endl;
- exitCode = 1;
- }
-
- return exitCode;
-}
-
-
-int importTableSet(GetLongOpt& longOpt, XPortFormat format)
-{
-
- Chain errorMsg;
- int exitCode=0;
-
- CegoDatabaseManager* pDBMng = 0;
-
- try
- {
-
- Chain logFile = longOpt.getOptValue("logfile");
- Chain lockFile = longOpt.getOptValue("lockfile");
- Chain dbXML = longOpt.getOptValue("dbxml");
- Chain tableSet = longOpt.getOptValue("tableset");
- Chain poolSize = longOpt.getOptValue("poolsize");
- Chain impFileName = longOpt.getOptValue("impfile");
- bool doLogging = true;
- if ( longOpt.isSet("nologging") )
- doLogging=false;
-
- if ( dbXML.length() == 0 || dbXML == Chain("") )
- {
- throw Exception(EXLOC, "No dbxml set");
- }
- if ( tableSet.length() == 0 || tableSet == Chain("") )
- {
- throw Exception(EXLOC, "No tableSet set");
- }
- if ( impFileName.length() == 0 || impFileName == Chain("") )
- {
- throw Exception(EXLOC, "No impfile set");
- }
-
- pDBMng = new CegoDatabaseManager(dbXML, lockFile, logFile);
-
- pDBMng->initPool(poolSize.asInteger());
- pDBMng->configureLogger();
- unsigned long modId = pDBMng->getModId("CegoMain");
-
- CegoLockHandler* pLockHandler = 0;
- CegoLogThreadPool* pLogPool = 0;
- CegoDistManager* pTabMng = 0;
-
- try
- {
-
- if ( pDBMng->isCaseSensitiveMode() )
- __caseSensitiveFlag = 1;
- else
- __caseSensitiveFlag = 0;
-
- if ( pDBMng->isQuoteEscapeMode() )
- __quoteEscapeFlag = 1;
- else
- __quoteEscapeFlag = 0;
-
-
- Chain dtFormat = pDBMng->getDateFormatString();
-
- if ( dtFormat != Chain("") )
- __dateFormatString=dtFormat;
-
- pLockHandler = new CegoLockHandler(pDBMng);
-
- pLockHandler->initLocks();
-
- if ( pDBMng->isArchiveMode(tableSet) )
- {
- pDBMng->log(modId, Logger::DEBUG, Chain("Creating log threadpool ..."));
- pLogPool = new CegoLogThreadPool(pDBMng);
- pLogPool->start(0);
- }
-
- pTabMng = new CegoDistManager(pDBMng);
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Starting tableset ") + tableSet + Chain(" ..."));
-
-
- Host h;
- pTabMng->startDistTableSet(tableSet, h.getName(), false);
-
- CegoXPorter xp(pTabMng);
-
- if ( format == XML )
- {
- cout << "Starting XML import of file " << impFileName << endl;
- xp.xmlImportTableSet(tableSet, false, impFileName, doLogging);
- }
- else if ( format == BINARY )
- {
- cout << "Starting binary import of file " << impFileName << endl;
- xp.binImportTableSet(tableSet, false, impFileName, doLogging, false);
- }
- else if ( format == PLAIN )
- {
- cout << "Starting plain import of file " << impFileName << endl;
- xp.binImportTableSet(tableSet, false, impFileName, true, true);
- }
-
- pTabMng->stopDistTableSet(tableSet, true);
-
- pDBMng->doc2Xml();
-
- }
- catch ( Exception e )
- {
- Chain msg;
- Chain module;
- int line;
-
- Chain exep;
- while ( e.pop(module, line, msg) )
- {
- exep += Chain("\n\t") + module + Chain("(") + Chain(line) + Chain(") : ") + msg;
- }
- pDBMng->log(modId, Logger::LOGERR, Chain("Import Thread : ") + exep);
- exitCode=1;
- errorMsg=Chain("Import failed, see log for details");
- }
-
- if ( pLogPool )
- delete pLogPool;
-
- if ( pTabMng )
- delete pTabMng;
-
- if ( pLockHandler )
- {
- pLockHandler->deleteLocks();
- delete pLockHandler;
- }
-
- delete pDBMng;
- pDBMng = 0;
- }
- catch ( Exception e )
- {
- if ( pDBMng )
- delete pDBMng;
-
- e.pop(errorMsg);
- exitCode=1;
- }
-
- if ( exitCode == 0 )
- {
- cout << "Import done" << endl;
- }
- else
- {
- cerr << "ERROR: " << errorMsg << endl;
- }
-
- return exitCode;
-}
-
-int exportTableSet(GetLongOpt& longOpt, XPortFormat format)
-{
-
- Chain errorMsg;
- int exitCode=0;
-
- CegoDatabaseManager* pDBMng = 0;
-
- try
- {
-
- Chain logFile = longOpt.getOptValue("logfile");
- Chain lockFile = longOpt.getOptValue("lockfile");
- Chain dbXML = longOpt.getOptValue("dbxml");
- Chain tableSet = longOpt.getOptValue("tableset");
- Chain poolSize = longOpt.getOptValue("poolsize");
- Chain expFileName = longOpt.getOptValue("expfile");
-
- if ( dbXML.length() == 0 || dbXML == Chain("") )
- {
- throw Exception(EXLOC, "No dbxml set");
- }
- if ( tableSet.length() == 0 || tableSet == Chain("") )
- {
- throw Exception(EXLOC, "No tableSet set");
- }
- if ( expFileName.length() == 0 || expFileName == Chain("") )
- {
- throw Exception(EXLOC, "No expfile set");
- }
-
- pDBMng = new CegoDatabaseManager(dbXML, lockFile, logFile);
-
- pDBMng->initPool(poolSize.asInteger());
- pDBMng->configureLogger();
- unsigned long modId = pDBMng->getModId("CegoMain");
-
- CegoLockHandler* pLockHandler = 0;
- CegoLogThreadPool* pLogPool = 0;
- CegoDistManager* pTabMng = 0;
-
- try
- {
-
- if ( pDBMng->isCaseSensitiveMode() )
- __caseSensitiveFlag = 1;
- else
- __caseSensitiveFlag = 0;
-
- if ( pDBMng->isQuoteEscapeMode() )
- __quoteEscapeFlag = 1;
- else
- __quoteEscapeFlag = 0;
-
- Chain dtFormat = pDBMng->getDateFormatString();
-
- if ( dtFormat != Chain("") )
- __dateFormatString=dtFormat;
-
- pLockHandler = new CegoLockHandler(pDBMng);
-
- pLockHandler->initLocks();
-
- if ( pDBMng->isArchiveMode(tableSet) )
- {
- pDBMng->log(modId, Logger::DEBUG, Chain("Creating log threadpool ..."));
- pLogPool = new CegoLogThreadPool(pDBMng);
- pLogPool->start(0);
- }
-
- pTabMng = new CegoDistManager(pDBMng);
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Starting tableset ") + tableSet + Chain(" ..."));
-
- Host h;
- pTabMng->startDistTableSet(tableSet, h.getName(), false);
-
- CegoXPorter xp(pTabMng);
-
- if ( format == XML )
- {
- cout << "Starting XML export of file " << expFileName << endl;
- xp.xmlExportTableSet(tableSet, false, expFileName);
- }
- else if ( format == BINARY )
- {
- cout << "Starting binary export of file " << expFileName << endl;
- xp.binExportTableSet(tableSet, false, expFileName, false);
- }
- else if ( format == PLAIN )
- {
- cout << "Starting plain export of file " << expFileName << endl;
- xp.binExportTableSet(tableSet, false, expFileName, true);
- }
-
-
- pTabMng->stopDistTableSet(tableSet, true);
-
- pDBMng->doc2Xml();
-
- }
- catch ( Exception e )
- {
- Chain msg;
- Chain module;
- int line;
-
- Chain exep;
- while ( e.pop(module, line, msg) )
- {
- exep += Chain("\n\t") + module + Chain("(") + Chain(line) + Chain(") : ") + msg;
- }
- pDBMng->log(modId, Logger::LOGERR, Chain("Import Thread : ") + exep);
- exitCode=1;
- errorMsg=Chain("Import failed, see log for details");
- }
-
- if ( pLogPool )
- delete pLogPool;
-
- if ( pTabMng )
- delete pTabMng;
-
- if ( pLockHandler )
- {
- pLockHandler->deleteLocks();
- delete pLockHandler;
- }
-
- delete pDBMng;
- pDBMng = 0;
- }
- catch ( Exception e )
- {
- if ( pDBMng )
- delete pDBMng;
-
- e.pop(errorMsg);
- exitCode=1;
- }
-
- if ( exitCode == 0 )
- {
- cout << "Export done" << endl;
- }
- else
- {
- cerr << "ERROR: " << errorMsg << endl;
-
- }
-
- return exitCode;
-}
-
-int runBatch(GetLongOpt& longOpt)
-{
-
- Chain errorMsg;
- int exitCode=0;
-
- CegoDatabaseManager* pDBMng = 0;
-
- try
- {
-
- Chain logFile = longOpt.getOptValue("logfile");
- Chain lockFile = longOpt.getOptValue("lockfile");
- Chain dbXML = longOpt.getOptValue("dbxml");
- Chain tableSet = longOpt.getOptValue("tableset");
- Chain poolSize = longOpt.getOptValue("poolsize");
- Chain batchFileName = longOpt.getOptValue("batchfile");
- bool ignoreError = longOpt.isSet("ignore");
-
- if ( dbXML.length() == 0 || dbXML == Chain("") )
- {
- throw Exception(EXLOC, "No dbxml set");
- }
- if ( tableSet.length() == 0 || tableSet == Chain("") )
- {
- throw Exception(EXLOC, "No tableSet set");
- }
-
- pDBMng = new CegoDatabaseManager(dbXML, lockFile, logFile);
-
- pDBMng->initPool(poolSize.asInteger());
- pDBMng->configureLogger();
- unsigned long modId = pDBMng->getModId("CegoMain");
-
- CegoLockHandler* pLockHandler = 0;
- CegoLogThreadPool* pLogPool = 0;
- CegoDistManager* pTabMng = 0;
- CegoAction* pAction = 0;
-
- try {
-
- pLockHandler = new CegoLockHandler(pDBMng);
-
-
- if ( pDBMng->isCaseSensitiveMode() )
- __caseSensitiveFlag = 1;
- else
- __caseSensitiveFlag = 0;
-
- if ( pDBMng->isQuoteEscapeMode() )
- __quoteEscapeFlag = 1;
- else
- __quoteEscapeFlag = 0;
-
- Chain dtFormat = pDBMng->getDateFormatString();
- if ( dtFormat != Chain("") )
- __dateFormatString=dtFormat;
-
-
- pLockHandler->initLocks();
-
- if ( pDBMng->isArchiveMode(tableSet) )
- {
- pDBMng->log(modId, Logger::DEBUG, Chain("Creating log threadpool ..."));
- pLogPool = new CegoLogThreadPool(pDBMng);
- pLogPool->start(0);
- }
-
-
- pTabMng = new CegoDistManager(pDBMng);
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Starting tableset ") + tableSet + Chain(" ..."));
-
- Host h;
- pTabMng->startDistTableSet(tableSet, h.getName(), false);
-
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Tableset ") + tableSet + Chain(" completed"));
-
- pAction = new CegoAction( pTabMng);
-
- pAction->setTableSet(tableSet);
- pAction->addRole(CegoAction::ALL);
-
- int tabSetId = pDBMng->getTabSetId(tableSet);
-
- /* since objects are loaded dynamically now,
- object load at startup is no more required
-
- // loading objects
- ListT<Chain> procList;
- pTabMng->getObjectList(tabSetId, CegoObject::PROCEDURE, procList);
-
- Chain *pProcName = procList.First();
- while ( pProcName )
- {
- pDBMng->log(modId, Logger::DEBUG, Chain("Compiling procedure ") + *pProcName + Chain(" ..."));
-
- CegoProcObject po;
- pTabMng->getObject(tabSetId, *pProcName, CegoObject::PROCEDURE, po);
-
- // cout << "ProcText=" << endl;
- // cout << "--------------" << endl;
- // cout << po.getProcText() << endl;;
-
- Chain loadString = Chain("load ") + po.getProcText();
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Loading <<<") + loadString + Chain(">>>"));
-
- pAction->setCommandChain(loadString);
- pAction->parse();
- CegoProcedure* pProc = pAction->getProcedure();
-
- pTabMng->addCompProcedure(tabSetId, pProc);
-
- pProcName = procList.Next();
- }
-
- ListT<Chain> viewList;
- pTabMng->getObjectList(tabSetId, CegoObject::VIEW, viewList);
-
- Chain *pViewName = viewList.First();
- while ( pViewName )
- {
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Compiling view ") + *pViewName + Chain(" ..."));
-
- CegoViewObject vo;
- pTabMng->getObject(tabSetId, *pViewName, CegoObject::VIEW, vo);
-
- Chain loadString = Chain("load ") + vo.getViewStmt();
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Loading <<<") + loadString + Chain(">>>"));
-
- pAction->setCommandChain(loadString);
- pAction->parse();
- CegoSelect* pSelect = pAction->getSelect();
-
- CegoView *pView = new CegoView(*pViewName, pSelect);
-
- pTabMng->addCompView(tabSetId, pView);
-
- pViewName = viewList.Next();
- }
- */
-
- if ( processBatchFile(pDBMng, pAction, batchFileName, ignoreError, true, errorMsg) == false )
- exitCode = 1;
-
- pTabMng->stopDistTableSet(tableSet, false);
-
- pDBMng->doc2Xml();
-
- }
- catch ( Exception e)
- {
- exitCode = 1;
- e.pop(errorMsg);
- }
-
- if ( pAction )
- delete pAction;
-
- if ( pLogPool )
- delete pLogPool;
-
- if ( pTabMng )
- delete pTabMng;
-
- if ( pLockHandler )
- {
- pLockHandler->deleteLocks();
- delete pLockHandler;
- }
-
- delete pDBMng;
-
- }
- catch ( Exception e )
- {
- if ( pDBMng )
- delete pDBMng;
-
- e.pop(errorMsg);
- exitCode=1;
- }
-
- if ( exitCode == 0 )
- {
- cout << "Batch done" << endl;
- }
-
- return exitCode;
-
-}
-
-int runDaemon(GetLongOpt& longOpt)
-{
-
- int exitCode = 0;
-
- CegoDatabaseManager* pDBMng = 0;
- unsigned long modId = 0;
-
- try {
-
- Chain logFile = longOpt.getOptValue("logfile");
- Chain lockFile = longOpt.getOptValue("lockfile");
- Chain pidFile = longOpt.getOptValue("pidfile");
- Chain dbXML = longOpt.getOptValue("dbxml");
- Chain tableSetArray = longOpt.getOptValue("tableset");
-
- Chain poolSize = longOpt.getOptValue("poolsize");
- Chain numDbThread = longOpt.getOptValue("numdbthread");
- Chain numAdminThread = longOpt.getOptValue("numadminthread");
- Chain numLogThread = longOpt.getOptValue("numlogthread");
- Chain mediator = longOpt.getOptValue("mediator");
- bool cleanIt = longOpt.isSet("cleanup");
- bool forceload = longOpt.isSet("forceload");
-
- bool connectToHost = false;
-
- CegoMediatorThread *pMedThread = 0;
- CegoBeatConnection beat;
-
- if ( dbXML.length() == 0 || dbXML == Chain("") )
- {
- throw Exception(EXLOC, "No dbxml set");
- }
-
- pDBMng = new CegoDatabaseManager(dbXML, lockFile, logFile);
- pMedThread = new CegoMediatorThread(pDBMng);
-
- modId = pDBMng->getModId("CegoMain");
-
- if ( mediator.length() == 0 || mediator == Chain("") )
- {
- connectToHost = false;
- }
- else
- {
- connectToHost = true;
- Tokenizer tok(mediator, Chain(":"));
-
- Chain host;
- Chain port;
- Chain user;
- Chain passwd;
-
- tok.nextToken(host);
- tok.nextToken(port);
- tok.nextToken(user);
- tok.nextToken(passwd);
-
- AESCrypt aescrypt(CEGOAESKEY, CEGOAESKEYLEN);
- beat = CegoBeatConnection(host, port.asInteger(), user, aescrypt.encrypt(passwd), pDBMng);
-
- }
-
- if ( connectToHost == true )
- {
- pDBMng->configureLogger(Logger::DEBUG);
- pMedThread->getDbSpec(dbXML, beat.getHostName(), beat.getPortNo(), beat.getUser(), beat.getPasswd());
- pDBMng->setXmlDef(dbXML);
- }
-
- pDBMng->initPool(poolSize.asInteger());
- pDBMng->configureLogger();
-
- bool startTableSet = true;
- if ( tableSetArray.length() == 0 || tableSetArray == Chain("") )
- {
- startTableSet = false;
- }
-
- pDBMng->log(modId, Logger::DEBUG, "Initializing page and record locks ...");
-
- CegoLockHandler* pLockHandler = new CegoLockHandler(pDBMng);
-
- if ( pDBMng->isCaseSensitiveMode() )
- __caseSensitiveFlag = 1;
- else
- __caseSensitiveFlag = 0;
-
- if ( pDBMng->isQuoteEscapeMode() )
- __quoteEscapeFlag = 1;
- else
- __quoteEscapeFlag = 0;
-
- Chain dtFormat = pDBMng->getDateFormatString();
- if ( dtFormat != Chain("") )
- __dateFormatString=dtFormat;
-
- pLockHandler->initLocks();
-
- pDBMng->log(modId, Logger::DEBUG, "Creating db threadpool ...");
- CegoDbThreadPool* pDbPool = new CegoDbThreadPool(numDbThread.asInteger(), pDBMng);
- pDBMng->log(modId, Logger::DEBUG, "Sync db pool to ready ...");
- pDbPool->syncToReady();
- pDBMng->log(modId, Logger::DEBUG, "DB Pool is ready");
-
- pDBMng->log(modId, Logger::DEBUG, "Creating log threadpool ...");
- CegoLogThreadPool* pLogPool = new CegoLogThreadPool(numLogThread.asInteger(), pDBMng);
-
- pDBMng->log(modId, Logger::DEBUG, "Creating admin threadpool ...");
- CegoAdminThreadPool *pAdminPool = new CegoAdminThreadPool(numAdminThread.asInteger(), pDBMng, pDbPool, pLogPool);
-
- pDBMng->setThreadInfo(numDbThread.asInteger(), numAdminThread.asInteger(), numLogThread.asInteger());
-
- CegoBeatThread *pBeatThread = new CegoBeatThread(pDBMng);
-
- pMedThread->start(0);
-
- pDbPool->start(0);
- pLogPool->start(0);
- pAdminPool->start(0);
-
- // write pidfile
-
- // is pidfile set in command line ?
- if ( pidFile.length() == 0 || pidFile == Chain("") )
- {
-
- // if not, get pid file from xml
- pDBMng->getPidFile(pidFile);
-
-
- }
-
- if ( pidFile != Chain("") )
- {
- File pf(pidFile);
- pf.open(File::WRITE);
- Process p;
- int pid = p.getPid();
- pf.writeChain(Chain(pid));
- pf.close();
- }
- else
- {
- throw Exception(EXLOC, "No pidfilename set");
- }
-
- Host h;
-
- // correct online entries
- ListT<Chain> corList;
- pDBMng->getActiveTableSet(h.getName(), corList);
-
- if ( corList.Size() > 0 )
- {
- CegoDistManager tabMng(pDBMng);
- Chain *pCor = corList.First();
- while ( pCor )
- {
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Correcting tableset ") + *pCor + Chain(" runstate"));
- pDBMng->setTableSetRunState(*pCor, XML_OFFLINE_VALUE);
- pCor = corList.Next();
- }
-
- }
-
- if ( startTableSet )
- {
-
- Tokenizer tok(tableSetArray, Chain(","));
-
- CegoDistManager* pTabMng = new CegoDistManager(pDBMng);
-
- Chain tableSet;
-
- try
- {
-
- while ( tok.nextToken(tableSet) )
- {
-
- Chain secondary = pDBMng->getSecondary(tableSet);
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Starting tableset ") + tableSet);
-
- Chain runState = pDBMng->getTableSetRunState(tableSet);
- if ( runState == Chain(XML_DEFINED_VALUE) )
- {
- Chain msg = Chain("Cannot start tableset ") + tableSet + Chain(", not yet created");
- throw Exception(EXLOC, msg);
- }
-
- pTabMng->startDistTableSet(tableSet, secondary, cleanIt);
-
- if ( forceload )
- {
- pDBMng->log(modId, Logger::DEBUG, Chain("Forced loading object for ") + tableSet + Chain("..."));
- int tabSetId = pDBMng->getTabSetId(tableSet);
- pDbPool->loadObjects(tabSetId);
- pDBMng->log(modId, Logger::DEBUG, Chain("Objects for ") + tableSet + Chain(" loaded"));
- }
-
-
-
- Chain batchFileName = pDBMng->getTSInitFile(tableSet);
-
- File batchFile(batchFileName);
-
- if ( batchFile.exists() )
- {
-
- CegoAction* pAction = new CegoAction(pTabMng);
-
- try
- {
- pAction->setTableSet(tableSet);
- pAction->addRole(CegoAction::ALL);
-
- Chain errorMsg;
- if ( processBatchFile(pDBMng, pAction, batchFileName, false, false, errorMsg) == false )
- throw Exception(EXLOC, errorMsg);
-
- }
- catch ( Exception e )
- {
- delete pAction;
- throw Exception(EXLOC, Chain("Execution of init file ") + batchFileName + Chain(" failed"), e);
- }
-
- delete pAction;
- }
- }
- }
- catch ( Exception e )
- {
- delete pTabMng;
- throw Exception(EXLOC, Chain("Cannot start tableset ") + tableSet, e);
- }
- delete pTabMng;
- }
-
- cout << "Cego daemon up and running ..." << endl;
-
- CegoCheckpoint cpc;
-
- while ( ! pBeatThread->isTerminated()
- && ! pDbPool->isTerminated()
- && ! pLogPool->isTerminated()
- && ! pAdminPool->isTerminated() )
- {
-
-
- pBeatThread->beat();
-
- ListT<Chain> actList;
- pDBMng->getActiveTableSet(h.getName(), actList);
-
- if ( actList.Size() > 0 )
- {
-
- Chain *pAct = actList.First();
- while ( pAct )
- {
- pDBMng->log(modId, Logger::DEBUG, Chain("Cleaning tableset ") + *pAct + Chain(" ..."));
- CegoDistManager tabMng(pDBMng);
-
- try
- {
- tabMng.cleanTableSet(*pAct);
- int cpi = pDBMng->getCheckpointInterval(*pAct);
- if ( cpc.checkpointReached(*pAct, cpi) )
- {
- pDBMng->log(modId, Logger::NOTICE, Chain("Checkpoint reached for tableset ") + *pAct);
- tabMng.writeCheckPoint(*pAct, true, true);
- }
- }
- catch ( Exception e )
- {
- Chain msg;
- Chain module;
- int line;
-
- Chain exep;
- while ( e.pop(module, line, msg) )
- {
- exep += Chain("\n\t") + module + Chain("(") + Chain(line) + Chain(") : ") + msg;
- }
-
- pDBMng->log(modId, Logger::LOGERR, Chain("Main Thread : ") + exep);
- }
- pDBMng->log(modId, Logger::DEBUG, Chain("Tableset ") + *pAct + Chain(" cleaned"));
-
- pAct = actList.Next();
- }
-
- }
-
- pDBMng->beat();
-
- Sleeper s;
- s.secSleep(NETMNG_BEATDELAY);
- }
-
- cout << "Terminating ..." << endl;
-
- pDBMng->log(modId, Logger::NOTICE, Chain("Shutting database down .."));
-
- ListT<Chain> atsList;
-
- pDBMng->getActiveTableSet(h.getName(), atsList);
-
- if ( atsList.Size() > 0 )
- {
- CegoDistManager tabMng(pDBMng);
- Chain *pATS = atsList.First();
- while ( pATS )
- {
-
- pDBMng->log(modId, Logger::NOTICE, Chain("Syncing active tableset ") + *pATS + Chain("..."));
-
- tabMng.writeCheckPoint(*pATS, true, true);
- pDBMng->setTableSetRunState(*pATS, XML_OFFLINE_VALUE);
- pATS = atsList.Next();
- }
- }
-
- // anyway sync the xml file
- pDBMng->doc2Xml();
-
- // because admin threads are using dbthreadpool and logthread pool, we hove to terminate admin thread pool first
- pDBMng->log(modId, Logger::DEBUG, Chain("Deleting admin threadpool ..."));
- delete pAdminPool;
- pDBMng->log(modId, Logger::DEBUG, Chain("Deleting log threadpool ..."));
- delete pLogPool;
- pDBMng->log(modId, Logger::DEBUG, Chain("Deleting db threadpool ..."));
- delete pDbPool;
- pDBMng->log(modId, Logger::DEBUG, Chain("Deleting beat thread ..."));
- delete pBeatThread;
- pDBMng->log(modId, Logger::DEBUG, Chain("Deleting med thread ..."));
- delete pMedThread;
-
- pLockHandler->deleteLocks();
- delete pLockHandler;
- }
- catch ( Exception e)
- {
-
- Chain msg;
- Chain module;
- int line;
-
- bool log2Console=true;
-
- if ( pDBMng )
- {
- if ( pDBMng->isLoggerConfigured() )
- {
- Chain exep;
- while ( e.pop(module, line, msg) )
- {
- exep += Chain("\n\t") + module + Chain("(") + Chain(line) + Chain(") : ") + msg;
- }
- pDBMng->log(modId, Logger::LOGERR, Chain("Main Thread : ") + exep);
-
- cerr << "Cego daemon failed, see log for detailed information" << endl;
- log2Console=false;
- }
- }
-
- if ( log2Console )
- {
- cerr << "Cego daemon failed :";
- Chain exep;
- while ( e.pop(module, line, msg) )
- {
- exep += Chain("\n\t") + module + Chain("(") + Chain(line) + Chain(") : ") + msg;
- }
- cerr << exep << endl;
- }
- exitCode = 1;
- }
-
- if ( pDBMng )
- {
- pDBMng->log(modId, Logger::NOTICE, Chain("Shutdown finished"));
- delete pDBMng;
- }
-
- if ( exitCode == 0 )
- {
- cout << "Cego daemon is terminated." << endl;
- }
-
- return exitCode;
-}
-
-
-bool processBatchFile(CegoDatabaseManager *pDBMng, CegoAction *pAction, const Chain& batchFileName, bool ignoreError, bool consoleOut, Chain& errorMsg)
-{
- File batchFile(batchFileName);
- batchFile.open(File::READ);
-
- int lineNo=0;
-
- Chain cmd;
- Chain line;
-
- bool disableDelimiter=false;
-
- unsigned long modId = pDBMng->getModId("CegoMain");
-
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Processing batchfile ") + batchFileName);
-
- while (batchFile.readLine(line, MAXCMDLEN))
- {
- lineNo++;
- line = line.cutTrailing(" \t");
-
- bool isCommentLine = false;
-
- if ( line.length() >= 2 )
- {
- if (line.cutTrailing(" \t").subChain(1, 2) == Chain("--"))
- {
- isCommentLine = true;
- }
- }
-
- if ( ! isCommentLine )
- {
- if ( line == Chain("@") )
- {
- if ( disableDelimiter == false )
- disableDelimiter=true;
- else
- disableDelimiter=false;
- }
- else
- {
- cmd = cmd + Chain(" ") + line;
- cmd = cmd.cutTrailing(" \t");
- }
-
- if ( cmd.length() > 0 )
- {
-
- if (cmd.subChain(cmd.length()-1, cmd.length()) == Chain(";")
- && disableDelimiter==false)
- {
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Processing command <<<") + cmd + Chain(">>>"));
-
- pAction->cleanUp();
- pAction->setCommandChain(cmd);
-
- try {
-
- pAction->parse();
- if ( consoleOut )
- cout << "ok" << endl;
- }
- catch ( Exception e)
- {
-
-
- Chain msg;
- Chain module;
- int line;
-
- Chain exep;
- while ( e.pop(module, line, msg) )
- {
- exep += Chain("\n\t") + module + Chain("(") + Chain(line) + Chain(") : ") + msg;
- }
-
- pDBMng->log(modId, Logger::LOGERR, Chain("Batch Thread : ") + exep);
-
- errorMsg=e.getBaseMsg();
-
- if ( ignoreError )
- {
-
- if ( consoleOut )
- {
- cerr << Chain("Error ignored at line number ") + Chain(lineNo) + " : ";
- cerr << errorMsg << endl;
- }
- }
- else
- {
- if ( consoleOut )
- {
- cerr << Chain("Line Number ") + Chain(lineNo) + Chain(" : ");
- cerr << errorMsg << endl;
- }
-
- return false;
-
- }
- }
-
- cmd = Chain();
-
- }
- }
- }
- }
- if ( cmd.length() > 1 && consoleOut)
- {
- cout << "incomplete command ..<" << cmd << ">" << endl;
- }
-
- batchFile.close();
-
- return true;
-
-}
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/README
^
|
@@ -4,7 +4,7 @@
----
A relational and transactional database system
- Version 2.10.11
+ Version 2.10.13
(C)opyright 2006,2007,2008,2009,2010,2011 by Bjoern Lemke
@@ -14,7 +14,7 @@
-----------
To build Cego, you need the following library packages available from www.lemke-it.com:
- lfc-1.1.40.tar.gz
+ lfc-1.1.41.tar.gz
lfcxml-1.0.25.tar.gz
Furthermore, you need the GNU readline library available via http://tiswww.case.edu/php/chet/readline/rltop.html
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/TODO
^
|
@@ -6,3 +6,4 @@
Idea : With session request append mode is set up
- read performance can be improved by replacing XML protocol by native encoding model
+
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/samples/chkdb/check026.sql
^
|
@@ -1,11 +1,18 @@
--
-- ### Check advanced aggregation
--
-
+drop if exists table t1;
+drop if exists table t2;
create table t1 ( a datetime );
+create table t2 ( a int, b int, c int );
insert into t1 values ( sysdate );
-
select sum( date2int(a) ) from t1;
-drop table t1;
+insert into t2 values ( 1, 2, 3 );
+insert into t2 values ( 100, 20, 77 );
+
+select sum(a) + sum(b) + sum(c), sum(a) - sum(b), avg(a), avg(b) from t2;
+select count(a) + sum(b), avg(a) - sum(b) - sum(a) from t2;
+
+
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/samples/chkdb/check027.sql
^
|
@@ -6,7 +6,7 @@
drop if exists table t2;
create table t1 ( primary a int not null, b string(20));
-create table t2 ( primary a int not null, b string(20));
+create table t2 ( a int, b string(20));
delete from t1 where a in ( select a from t2 where b = 'XXX');
@@ -16,6 +16,8 @@
insert into t1 values ( 4, 'zzz');
insert into t2 values ( 1000, 'XXX');
+insert into t2 values ( 2000, 'YYY');
+insert into t2 values ( 3000, 'ZZZ');
select * from t1;
@@ -27,4 +29,9 @@
select * from t1;
+select * from t2;
+
+update t2 set a = ( select a from t2 where b = 'ZZZ' ) where a = 1000;
+
+select * from t2;
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/samples/chkdb/chkup
^
|
@@ -6,5 +6,5 @@
exit 1
fi
-../../src/cego --mode=daemon --forceload --numdbthread=300 --nolockstat --dbxml=chkdb.xml --poolsize=3000 --tableset=$1
+../../src/cego --mode=daemon --forceload --numdbthread=30 --nolockstat --dbxml=chkdb.xml --poolsize=3000 --tableset=$1
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoAction.cc
^
|
@@ -1499,7 +1499,7 @@
if ( doCompile )
{
- _pTabMng->getDBMng()->useObject(tabSetId, viewName, CegoObject::VIEW, CegoDatabaseManager::EXCLUSIVE);
+ _pTabMng->getDBMng()->useObject(tabSetId, viewName, CegoObject::VIEW, CegoDatabaseManager::EXCLUSIVE, _pTabMng->getThreadId());
try
{
@@ -1574,7 +1574,7 @@
int tabSetId = _pTabMng->getDBMng()->getTabSetId(tableSet);
- _pTabMng->getDBMng()->useObject(tabSetId, viewName, CegoObject::VIEW, CegoDatabaseManager::EXCLUSIVE);
+ _pTabMng->getDBMng()->useObject(tabSetId, viewName, CegoObject::VIEW, CegoDatabaseManager::EXCLUSIVE, _pTabMng->getThreadId());
try
{
@@ -1633,7 +1633,7 @@
_pTabMng->createDistProc(_procTableSet, _pProc->getName(), procEscText);
- _pTabMng->getDBMng()->useObject(tabSetId, procName, CegoObject::PROCEDURE, CegoDatabaseManager::EXCLUSIVE);
+ _pTabMng->getDBMng()->useObject(tabSetId, procName, CegoObject::PROCEDURE, CegoDatabaseManager::EXCLUSIVE, _pTabMng->getThreadId());
try
{
@@ -1697,7 +1697,7 @@
int tabSetId = _pTabMng->getDBMng()->getTabSetId(tableSet);
- _pTabMng->getDBMng()->useObject(tabSetId, procName, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED);
+ _pTabMng->getDBMng()->useObject(tabSetId, procName, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED, _pTabMng->getThreadId());
try
{
@@ -1803,7 +1803,7 @@
throw Exception(EXLOC, "No return variable specified");
}
- _pTabMng->getDBMng()->useObject(tabSetId, functionName, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED);
+ _pTabMng->getDBMng()->useObject(tabSetId, functionName, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED, _pTabMng->getThreadId());
try
{
@@ -1884,7 +1884,7 @@
pExpr = exprList.Next();
}
exprList.Empty();
- _pTabMng->getDBMng()->unuseObject(tabSetId, functionName, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED);
+ _pTabMng->getDBMng()->unuseObject(tabSetId, functionName, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED);
throw Exception(EXLOC, "Cannot execute function", e);
}
_pTabMng->getDBMng()->unuseObject(tabSetId, functionName, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED);
@@ -2121,7 +2121,7 @@
{
int tabSetId = _pTabMng->getDBMng()->getTabSetId(tableSet);
- _pTabMng->getDBMng()->useObject(tabSetId, procName, CegoObject::PROCEDURE, CegoDatabaseManager::EXCLUSIVE);
+ _pTabMng->getDBMng()->useObject(tabSetId, procName, CegoObject::PROCEDURE, CegoDatabaseManager::EXCLUSIVE, _pTabMng->getThreadId());
try
{
@@ -3742,7 +3742,7 @@
try
{
- _pTabMng->getDBMng()->useObject(tabSetId, tableName, CegoObject::VIEW, CegoDatabaseManager::SHARED);
+ _pTabMng->getDBMng()->useObject(tabSetId, tableName, CegoObject::VIEW, CegoDatabaseManager::SHARED, _pTabMng->getThreadId());
CegoView* pView = _pTabMng->getView(tabSetId, tableName);
}
catch ( Exception e )
@@ -3822,7 +3822,7 @@
try
{
- _pTabMng->getDBMng()->useObject(tabSetId, tableName, CegoObject::VIEW, CegoDatabaseManager::SHARED);
+ _pTabMng->getDBMng()->useObject(tabSetId, tableName, CegoObject::VIEW, CegoDatabaseManager::SHARED, _pTabMng->getThreadId());
CegoView* pView = _pTabMng->getView(tabSetId, tableName);
}
catch ( Exception e )
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoAdminThread.cc
^
|
@@ -84,7 +84,8 @@
_idx = *(long*)arg;
_pPool->setTid(_idx, getTid());
-
+ _pTabMng->setThreadId(getTid());
+
while ( ! _pPool->isTerminated() )
{
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoAttrComp.cc
^
|
@@ -42,12 +42,14 @@
CegoAttrComp::CegoAttrComp()
{
_compMode = UNDEF;
+ _pMatcher = 0;
}
CegoAttrComp::CegoAttrComp(const Chain& attrName)
{
_attrName = attrName;
_compMode = UNDEF;
+ _pMatcher = 0;
}
CegoAttrComp::CegoAttrComp(const Chain& attrName, CegoComparison comp, const CegoFieldValue& fv)
@@ -57,6 +59,7 @@
_fv = fv;
_compMode = VAL;
_isSetup = false;
+ _pMatcher = 0;
}
CegoAttrComp::CegoAttrComp(const Chain& attrName, CegoComparison comp, const CegoAttrDesc& attrDesc)
@@ -65,6 +68,7 @@
_comp = comp;
_attrDesc = attrDesc;
_compMode = ATTR;
+ _pMatcher = 0;
}
CegoAttrComp::CegoAttrComp(const Chain& attrName, const CegoFieldValue& fv, const CegoFieldValue& fv2)
@@ -73,11 +77,25 @@
_fv = fv;
_fv2 = fv2;
_compMode = BTWN;
+ _pMatcher = 0;
}
+CegoAttrComp::CegoAttrComp(const Chain& attrName, const Chain& pattern, bool isNot)
+{
+ _attrName = attrName;
+ _pattern = pattern;
+
+ if ( isNot )
+ _compMode = ISNOTLIKE;
+ else
+ _compMode = ISLIKE;
+ _pMatcher = 0;
+}
CegoAttrComp::~CegoAttrComp()
{
+ if ( _pMatcher )
+ delete _pMatcher;
}
CegoAttrComp::CompMode CegoAttrComp::getCompMode() const
@@ -120,6 +138,24 @@
return _isSetup;
}
+const Chain& CegoAttrComp::getPattern() const
+{
+ return _pattern;
+}
+
+Matcher* CegoAttrComp::getMatcher()
+{
+ if ( _pMatcher == 0)
+ {
+ Chain sqlPattern = Chain("^") + _pattern + Chain("$");
+ sqlPattern.replaceAll(Chain("%"), Chain(".*"), sqlPattern);
+ sqlPattern.replaceAll(Chain("_"), Chain("."), sqlPattern);
+ _pMatcher = new Matcher(sqlPattern);
+ _pMatcher->prepare();
+
+ }
+ return _pMatcher;
+}
bool CegoAttrComp::setup(const ListT<CegoField>& fl)
{
_isSetup=false;
@@ -170,20 +206,23 @@
_attrDesc = ac._attrDesc;
_compMode = ac._compMode;
_isSetup = ac._isSetup;
+ _pattern = ac._pattern;
+ _pMatcher = 0;
return (*this);
}
bool CegoAttrComp::operator == ( const CegoAttrComp& ac) const
{
if ( _compMode != ac._compMode )
- return false;
-
+ return false;
if ( _compMode == ATTR )
return (_attrName == ac._attrName && _comp == ac._comp );
if ( _compMode == VAL )
return (_attrName == ac._attrName && _comp == ac._comp && _fv == ac._fv );
if ( _compMode == BTWN )
return (_attrName == ac._attrName && _fv == ac._fv && _fv2 == ac._fv2 );
+ if ( _compMode == ISLIKE || _compMode == ISNOTLIKE )
+ return (_attrName == ac._attrName && _pattern == ac._pattern );
return false;
}
@@ -198,6 +237,14 @@
{
s += Chain(" between ") + _fv.toChain() + Chain(" and ") + _fv2.toChain();
}
+ else if ( _compMode == ISLIKE )
+ {
+ s += Chain(" like '") + _pattern + Chain("'");
+ }
+ else if ( _compMode == ISNOTLIKE )
+ {
+ s += Chain(" not like '") + _pattern + Chain("'");
+ }
else
{
switch ( _comp )
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoAttrComp.h
^
|
@@ -37,6 +37,7 @@
#include <lfc/Chain.h>
#include <lfc/ListT.h>
+#include <lfc/Matcher.h>
#include "CegoField.h"
#include "CegoFieldValue.h"
@@ -47,13 +48,14 @@
public:
- enum CompMode { UNDEF, VAL, ATTR, BTWN };
+ enum CompMode { UNDEF, VAL, ATTR, BTWN, ISLIKE, ISNOTLIKE };
CegoAttrComp();
CegoAttrComp(const Chain& attrName);
CegoAttrComp(const Chain& attrName, CegoComparison comp, const CegoFieldValue& fv);
CegoAttrComp(const Chain& attrName, CegoComparison comp, const CegoAttrDesc& attrDesc);
CegoAttrComp(const Chain& attrName, const CegoFieldValue& fv, const CegoFieldValue& fv2);
+ CegoAttrComp(const Chain& attrName, const Chain& pattern, bool isNot);
~CegoAttrComp();
CompMode getCompMode() const;
@@ -71,6 +73,9 @@
bool isSetup();
+ const Chain& getPattern() const;
+ Matcher* getMatcher();
+
CegoAttrComp& operator = ( const CegoAttrComp& ac);
bool operator == ( const CegoAttrComp& ac) const;
@@ -85,6 +90,8 @@
CegoFieldValue _fv2;
CegoAttrDesc _attrDesc;
CompMode _compMode;
+ Chain _pattern;
+ Matcher* _pMatcher;
bool _isSetup;
};
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoAttrCond.cc
^
|
@@ -168,6 +168,20 @@
new CegoExpr(new CegoTerm(new CegoFactor( pAC->getFieldValue()))),
new CegoExpr(new CegoTerm(new CegoFactor( pAC->getFieldValue2()))));
}
+ else if ( pAC->getCompMode() == CegoAttrComp::ISLIKE )
+ {
+ pP = new CegoPredDesc(pExpr,
+ pAC->getPattern(),
+ false);
+ }
+ else if ( pAC->getCompMode() == CegoAttrComp::ISNOTLIKE )
+ {
+ pP = new CegoPredDesc(pExpr,
+ pAC->getPattern(),
+ true);
+ }
+
+
conjunctionList.Insert(pP);
@@ -197,8 +211,11 @@
{
CegoAttrComp *pComp = _attrCompSet.First();
while ( pComp )
- {
- if ( pComp->getAttrName() == pF->getAttrName() )
+ {
+ if ( pComp->getAttrName() == pF->getAttrName()
+ && ( pComp->getCompMode() == CegoAttrComp::VAL
+ || pComp->getCompMode() == CegoAttrComp::ATTR
+ || pComp->getCompMode() == CegoAttrComp::BTWN ) )
numFound++;
else
isLeak=true;
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoClient.cc
^
|
@@ -72,6 +72,7 @@
[ --tableset=<tableset> ]\n\
[ --batchfile=<batchfile> ]\n\
[ --dumpfile=<dumpfile> ]\n\
+ [ --structure ]\n\
[ --cmd=<command> ]\n\
[ --logfile=<logfile> ]\n\
[ --raw ]\n\
@@ -169,9 +170,9 @@
bool dispatchCmd(CegoDbHandler* pNetHandle, AbortHandler* pAH, Chain cmd, bool outMode, int & exitCode);
void loadProfile(const Chain& rcFileName, ListT<ProfileEntry>& pfeList);
-void dumpTableSet(CegoNet *pCegoNet, const Chain& dumpFileName);
+void dumpTableSet(CegoNet *pCegoNet, const Chain& dumpFileName, bool isStructure);
void dumpCounter(CegoNet *pCegoNet, File *pDF);
-void dumpTable(CegoNet *pCegoNet, File *pDF);
+void dumpTable(CegoNet *pCegoNet, File *pDF, bool isStructure);
void dumpIndex(CegoNet *pCegoNet, File *pDF);
void dumpKey(CegoNet *pCegoNet, File *pDF);
void dumpCheck(CegoNet *pCegoNet, File *pDF);
@@ -191,6 +192,7 @@
longOpt.addOpt("cmd");
longOpt.addOpt("batchfile");
longOpt.addOpt("dumpfile");
+ longOpt.addOpt("structure");
longOpt.addOpt("qescmode");
longOpt.addOpt("debug");
longOpt.addOpt("raw");
@@ -243,7 +245,10 @@
if ( longOpt.isSet("ignore") )
ignoreError=true;
-
+ bool isStructure = false;
+ if ( longOpt.isSet("structure") )
+ isStructure=true;
+
if ( longOpt.isSet( Chain("help") ) )
{
cerr << USAGE << endl;
@@ -262,7 +267,17 @@
ListT<ProfileEntry> pfeList;
- loadProfile(homeDir + "/" + Chain(CGPROFILE), pfeList);
+ try
+ {
+ loadProfile(homeDir + "/" + Chain(CGPROFILE), pfeList);
+ }
+ catch ( Exception e )
+ {
+ Chain msg;
+ e.pop(msg);
+ cerr << msg << endl;
+ exit(1);
+ }
Chain logFile = longOpt.getOptValue("logfile");
@@ -386,9 +401,17 @@
Net n ( NETMNG_MSG_BUFLEN, NETMNG_SIZEBUFLEN );
NetHandler* pN;
-
- pN = n.connect(serverName, portNo);
-
+
+ try
+ {
+ pN = n.connect(serverName, portNo);
+ }
+ catch ( Exception e )
+ {
+ cerr << "Cannot connect to database" << endl;
+ exit(1);
+ }
+
CegoDbHandler* pSH = new CegoDbHandler(pN, pModule);
CegoDbHandler::ResultType res = pSH->requestSession(tableSet, user, password);
@@ -396,7 +419,9 @@
{
Chain msg;
pSH->getMsg(msg);
- throw Exception(EXLOC, msg);
+ delete pSH;
+ cerr << msg << endl;
+ exit(1);
}
dispatchCmd(pSH, 0, command, rawMode, exitCode);
@@ -415,24 +440,35 @@
int lineNo=0;
+
+ Net n ( NETMNG_MSG_BUFLEN, NETMNG_SIZEBUFLEN );
+ NetHandler* pN;
+
+ try
+ {
+ pN = n.connect(serverName, portNo);
+ }
+ catch ( Exception e )
+ {
+ cerr << "Cannot connect to database" << endl;
+ exit(1);
+ }
+
+ CegoDbHandler* pSH = new CegoDbHandler(pN, pModule);
+
+ CegoDbHandler::ResultType res = pSH->requestSession(tableSet, user, password);
+ if ( res != CegoDbHandler::DB_OK )
+ {
+ Chain msg;
+ pSH->getMsg(msg);
+ delete pSH;
+ cerr << msg << endl;
+ exit(1);
+ }
+
try
{
- Net n ( NETMNG_MSG_BUFLEN, NETMNG_SIZEBUFLEN );
- NetHandler* pN;
-
- pN = n.connect(serverName, portNo);
-
- CegoDbHandler* pSH = new CegoDbHandler(pN, pModule);
-
- CegoDbHandler::ResultType res = pSH->requestSession(tableSet, user, password);
- if ( res != CegoDbHandler::DB_OK )
- {
- Chain msg;
- pSH->getMsg(msg);
- throw Exception(EXLOC, msg);
- }
-
File cmdFile(batchFileName);
cmdFile.open(File::READ);
@@ -487,7 +523,7 @@
if ( exitCode != 0 && ignoreError )
goOn = true;
-
+
cout << "ok" << endl;
cmd = Chain("");
@@ -525,38 +561,60 @@
logMode=Chain("debug");
CegoNet *pCegoNet = new CegoNet( logFile, logMode );
- pCegoNet->connect(serverName, portNo, tableSet, user, password);
- dumpTableSet(pCegoNet, dumpFileName);
+ try
+ {
+ pCegoNet->connect(serverName, portNo, tableSet, user, password);
+ }
+ catch ( Exception e )
+ {
+ cerr << "Cannot connect to database" << endl;
+ delete pCegoNet;
+ exit(1);
+ }
+
+ dumpTableSet(pCegoNet, dumpFileName, isStructure);
delete pCegoNet;
break;
}
case INTERACTIVE:
{
- try
- {
- Net n ( NETMNG_MSG_BUFLEN, NETMNG_SIZEBUFLEN );
- NetHandler* pN;
-
+ Net n ( NETMNG_MSG_BUFLEN, NETMNG_SIZEBUFLEN );
+ NetHandler* pN;
+
+ try
+ {
pN = n.connect(serverName, portNo);
+ }
+ catch ( Exception e )
+ {
+ cerr << "Cannot connect to database" << endl;
+ exit(1);
+ }
- CegoDbHandler* pSH = new CegoDbHandler(pN, pModule);
-
- pModule->log(modId, Logger::DEBUG, Chain("Requesting session ..."));
+ CegoDbHandler* pSH = new CegoDbHandler(pN, pModule);
+
+ pModule->log(modId, Logger::DEBUG, Chain("Requesting session ..."));
+
+ CegoDbHandler::ResultType res = pSH->requestSession(tableSet, user, password);
+ if ( res != CegoDbHandler::DB_OK )
+ {
+ Chain msg;
+ pSH->getMsg(msg);
+ delete pSH;
+ cerr << msg << endl;
+ exit(1);
+ }
- CegoDbHandler::ResultType res = pSH->requestSession(tableSet, user, password);
- if ( res != CegoDbHandler::DB_OK )
- {
- Chain msg;
- pSH->getMsg(msg);
- throw Exception(EXLOC, msg);
- }
+
+ try
+ {
long tid = pSH->getTid();
-
+
AbortHandler *pAH = new AbortHandler(serverName, portNo, tableSet, user, password, tid, pModule);
pModule->log(modId, Logger::DEBUG, Chain("Got session ..."));
@@ -823,7 +881,7 @@
return true;
}
-void dumpTableSet(CegoNet *pCegoNet, const Chain& dumpFileName)
+void dumpTableSet(CegoNet *pCegoNet, const Chain& dumpFileName, bool isStructure)
{
File* pDF = new File(dumpFileName);
@@ -832,7 +890,7 @@
try
{
dumpCounter(pCegoNet, pDF);
- dumpTable(pCegoNet, pDF);
+ dumpTable(pCegoNet, pDF, isStructure);
dumpIndex(pCegoNet, pDF);
dumpKey(pCegoNet, pDF);
dumpCheck(pCegoNet, pDF);
@@ -882,7 +940,7 @@
}
}
-void dumpTable(CegoNet *pCegoNet, File *pDF)
+void dumpTable(CegoNet *pCegoNet, File *pDF, bool isStructure)
{
long res;
@@ -951,32 +1009,34 @@
pDF->writeChain(cmd);
- // dump table content
- res = pCegoNet->doQuery(Chain("select * from ") + *pTable + Chain(";"));
-
- schema.Empty();
- fvl.Empty();
-
- pCegoNet->getSchema(schema);
-
- while ( pCegoNet->fetchData(schema, fvl) )
+ if ( isStructure == false )
{
-
- Chain cmd=Chain("insert into ") + *pTable + Chain(" values (");
-
- CegoField *pF = fvl.First();
- while ( pF )
- {
- Chain val = pF->getValue().toChain();
- cmd += val;
- pF = fvl.Next();
+ // dump table content
+ res = pCegoNet->doQuery(Chain("select * from ") + *pTable + Chain(";"));
+
+ schema.Empty();
+ fvl.Empty();
+
+ pCegoNet->getSchema(schema);
+
+ while ( pCegoNet->fetchData(schema, fvl) )
+ {
+ Chain cmd=Chain("insert into ") + *pTable + Chain(" values (");
- if ( pF )
- cmd += Chain(", ");
+ CegoField *pF = fvl.First();
+ while ( pF )
+ {
+ Chain val = pF->getValue().toChain();
+ cmd += val;
+ pF = fvl.Next();
+
+ if ( pF )
+ cmd += Chain(", ");
+ }
+ cmd += Chain(");\n");
+ pDF->writeChain(cmd);
+ fvl.Empty();
}
- cmd += Chain(");\n");
- pDF->writeChain(cmd);
- fvl.Empty();
}
pTable = tableList.Next();
@@ -1318,41 +1378,47 @@
Chain rcLine;
while ( rcFile.readLine(rcLine) )
{
- Tokenizer rc1(rcLine, Chain(":"));
+ Tokenizer tok(rcLine, Chain(":"));
+
Chain pid;
- Chain rcEntry;
- rc1.nextToken(pid);
- rc1.nextToken(rcEntry);
-
- Tokenizer rc2(rcEntry, Chain(","));
-
Chain serverName;
- int portNo;
+ Chain portNo;
Chain tableSet;
- Chain auth;
Chain prompt;
+ Chain user;
+ Chain pwd;
- Chain rcField;
- while ( rc2.nextToken(rcField) )
+ if ( tok.nextToken(pid) == false)
+ {
+ throw Exception(EXLOC, Chain("Incomplete profile entry <") + rcLine + Chain(">"));
+ }
+ if ( tok.nextToken(serverName) == false)
+ {
+ throw Exception(EXLOC, Chain("Incomplete profile entry <") + rcLine + Chain(">"));
+ }
+ if ( tok.nextToken(portNo) == false)
+ {
+ throw Exception(EXLOC, Chain("Incomplete profile entry <") + rcLine + Chain(">"));
+ }
+ if ( tok.nextToken(tableSet) == false)
+ {
+ throw Exception(EXLOC, Chain("Incomplete profile entry <") + rcLine + Chain(">"));
+ }
+ if ( tok.nextToken(prompt) == false)
+ {
+ throw Exception(EXLOC, Chain("Incomplete profile entry <") + rcLine + Chain(">"));
+ }
+ if ( tok.nextToken(user) == false)
+ {
+ throw Exception(EXLOC, Chain("Incomplete profile entry <") + rcLine + Chain(">"));
+ }
+ if ( tok.nextToken(pwd) == false)
{
- Tokenizer rc3(rcField, Chain("="));
- Chain attr;
- Chain val;
- rc3.nextToken(attr);
- rc3.nextToken(val);
- if ( attr == Chain("server") )
- serverName = val;
- else if ( attr == Chain("port") )
- portNo = val.asInteger();
- else if ( attr == Chain("tableset") )
- tableSet = val;
- else if ( attr == Chain("auth") )
- auth = val;
- else if ( attr == Chain("prompt") )
- prompt = val;
+ throw Exception(EXLOC, Chain("Incomplete profile entry <") + rcLine + Chain(">"));
}
- ProfileEntry pfe(pid, serverName, portNo, tableSet, auth, prompt);
+ Chain auth = user + Chain("/") + pwd;
+ ProfileEntry pfe(pid, serverName, portNo.asInteger(), tableSet, auth, prompt);
pfeList.Insert(pfe);
}
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoDatabaseManager.cc
^
|
@@ -76,6 +76,7 @@
_tabSetId = tabSetId;
_numUsed = 0;
_mode = SHARED;
+ _tid = 0;
}
CegoDatabaseManager::ObjectRecord::~ObjectRecord()
@@ -103,16 +104,25 @@
return _numUsed;
}
+void CegoDatabaseManager::ObjectRecord::setMode(ObjectUseMode mode)
+{
+ _mode = mode;
+}
+
CegoDatabaseManager::ObjectUseMode CegoDatabaseManager::ObjectRecord::getMode() const
{
return _mode;
}
-void CegoDatabaseManager::ObjectRecord::setMode(ObjectUseMode mode)
+void CegoDatabaseManager::ObjectRecord::setTid(long tid)
{
- _mode = mode;
+ _tid = tid;
}
+long CegoDatabaseManager::ObjectRecord::getTid() const
+{
+ return _tid;
+}
CegoDatabaseManager::ObjectRecord& CegoDatabaseManager::ObjectRecord::operator = ( const CegoDatabaseManager::ObjectRecord& t)
{
@@ -122,6 +132,7 @@
_type = t._type;
_numUsed = t._numUsed;
_mode = t._mode;
+ _tid = t._tid;
return (*this);
@@ -500,20 +511,13 @@
return pCopyInfo;
}
-void CegoDatabaseManager::useObject(int tabSetId, const Chain& objName, CegoObject::ObjectType type, ObjectUseMode mode)
+void CegoDatabaseManager::useObject(int tabSetId, const Chain& objName, CegoObject::ObjectType type, ObjectUseMode mode, long tid)
{
if ( mode == SHARED )
{
// cout << "Using object " << objName << " " << type << " shared" << endl;
PW();
ObjectRecord *pOR = _objList.Find(ObjectRecord(tabSetId, objName, type));
- while ( pOR && ( pOR->getMode() == EXCLUSIVE || pOR->getMode() == EXCLUSIVE_WRITE ) )
- {
- V();
- PW();
- pOR = _objList.Find(ObjectRecord(tabSetId, objName, type));
- }
-
if ( pOR == 0 )
{
V();
@@ -521,8 +525,30 @@
throw Exception(EXLOC, msg);
}
- pOR->incUsed();
- V();
+ if ( pOR->getTid() != 0 && pOR->getTid() == tid )
+ {
+ pOR->incUsed();
+ V();
+ }
+ else
+ {
+ while ( pOR && ( pOR->getMode() == EXCLUSIVE || pOR->getMode() == EXCLUSIVE_WRITE ) )
+ {
+ V();
+ PW();
+ pOR = _objList.Find(ObjectRecord(tabSetId, objName, type));
+ }
+ if ( pOR == 0 )
+ {
+ V();
+ Chain msg = Chain("Cannot access object ") + objName;
+ throw Exception(EXLOC, msg);
+ }
+
+
+ pOR->incUsed();
+ V();
+ }
}
else if ( mode == EXCLUSIVE )
{
@@ -538,6 +564,7 @@
}
pOR->setMode(mode);
+ pOR->setTid(tid);
while ( pOR && pOR->numUsed() != 0 )
{
@@ -575,6 +602,7 @@
if ( pOR->getMode() == SHARED )
{
pOR->setMode(mode);
+ pOR->setTid(tid);
}
else
{
@@ -628,7 +656,10 @@
pOR->decUsed();
if ( mode != SHARED )
+ {
pOR->setMode(SHARED);
+ pOR->setTid(0);
+ }
V();
}
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoDatabaseManager.h
^
|
@@ -74,7 +74,7 @@
void setCopyStatus(int id, const Chain& msg);
void addObject(int tabSetId, const Chain& objName, CegoObject::ObjectType type);
- void useObject(int tabSetId, const Chain& objName, CegoObject::ObjectType type, ObjectUseMode mode);
+ void useObject(int tabSetId, const Chain& objName, CegoObject::ObjectType type, ObjectUseMode mode, long tid = 0 );
void unuseObject(int tabSetId, const Chain& objName, CegoObject::ObjectType type, ObjectUseMode mode);
void removeObject(int tabSetId, const Chain& objName, CegoObject::ObjectType type);
@@ -136,9 +136,13 @@
void incUsed();
void decUsed();
int numUsed() const;
- ObjectUseMode getMode() const;
+
void setMode(ObjectUseMode mode);
-
+ ObjectUseMode getMode() const;
+
+ void setTid(long tid);
+ long getTid() const;
+
ObjectRecord& operator = ( const ObjectRecord& t);
bool operator == ( const ObjectRecord& t);
@@ -155,6 +159,7 @@
int _tabSetId;
int _numUsed;
ObjectUseMode _mode;
+ long _tid;
};
class CopyRecord {
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoDbThread.cc
^
|
@@ -121,6 +121,7 @@
_pPA = new CegoAction(_pTabMng, _pPool);
_pTabMng->setPoolSyncInfo(_pPool, _idx);
+ _pTabMng->setThreadId(getTid());
_pPool->setTid(_idx, getTid());
_pPool->setThreadState(_idx, CegoDbThreadPool::READY);
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoDefs.h
^
|
@@ -40,7 +40,7 @@
#endif
#define CEGO_PRODUCT "Cego"
-#define CEGO_VERSION "2.10.11"
+#define CEGO_VERSION "2.10.13"
#define CEGO_COPYRIGHT "Copyright (C) 2000-2011 by Bjoern Lemke. All rights reserved"
/*******************************/
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoDistCursor.cc
^
|
@@ -142,7 +142,7 @@
{
_pDBMng->log(_modId, Logger::DEBUG, Chain("View ") + _tableName + Chain(" detected as the cursor source"));
- _pDBMng->useObject(_tabSetId, _tableName, CegoObject::VIEW, CegoDatabaseManager::SHARED);
+ _pDBMng->useObject(_tabSetId, _tableName, CegoObject::VIEW, CegoDatabaseManager::SHARED, _pGTM->getThreadId());
CegoView *pView;
@@ -174,7 +174,7 @@
_pDBMng->log(_modId, Logger::DEBUG, Chain("Native Table ") + _tableName + Chain(" detected as the cursor source"));
_pTC = new CegoTableCursor(_pGTM, _tabSetId, _tableName, false);
- _pDBMng->useObject(_tabSetId, _tableName, CegoObject::TABLE, CegoDatabaseManager::SHARED);
+ _pDBMng->useObject(_tabSetId, _tableName, CegoObject::TABLE, CegoDatabaseManager::SHARED, _pGTM->getThreadId());
_isLocal = true;
}
else
@@ -213,13 +213,13 @@
_pTCLeft->checkType();
if ( pCOLeft->getType() == CegoObject::VIEW || pCOLeft->getType() == CegoObject::TABLE )
- _pDBMng->useObject(pCOLeft->getTabSetId(), pCOLeft->getTabName(), pCOLeft->getType(), CegoDatabaseManager::SHARED);
+ _pDBMng->useObject(pCOLeft->getTabSetId(), pCOLeft->getTabName(), pCOLeft->getType(), CegoDatabaseManager::SHARED, _pGTM->getThreadId());
_pTCRight = new CegoDistCursor(_pGTM, pCORight);
_pTCRight->checkType();
if ( pCORight->getType() == CegoObject::VIEW || pCORight->getType() == CegoObject::TABLE )
- _pDBMng->useObject(pCORight->getTabSetId(), pCORight->getTabName(), pCORight->getType(), CegoDatabaseManager::SHARED);
+ _pDBMng->useObject(pCORight->getTabSetId(), pCORight->getTabName(), pCORight->getType(), CegoDatabaseManager::SHARED, _pGTM->getThreadId());
}
}
@@ -363,6 +363,19 @@
return false;
}
+ if ( pAC->getCompMode() == CegoAttrComp::ISLIKE )
+ {
+ if ( pAC->getMatcher()->match(pF->getValue().valAsChain()))
+ return true;
+ return false;
+ }
+ if ( pAC->getCompMode() == CegoAttrComp::ISNOTLIKE )
+ {
+ if ( pAC->getMatcher()->match(pF->getValue().valAsChain()))
+ return false;
+ return true;
+
+ }
else
{
switch ( pAC->getComparison() )
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoDistManager.cc
^
|
@@ -453,7 +453,7 @@
if ( useIt )
{
- _pDBMng->useObject(tabSetId, tableName, useType, CegoDatabaseManager::EXCLUSIVE);
+ _pDBMng->useObject(tabSetId, tableName, useType, CegoDatabaseManager::EXCLUSIVE, _threadId);
}
ListT<CegoTableObject> idxList;
@@ -619,7 +619,7 @@
void CegoDistManager::createLocalIndexTable(int tabSetId, const Chain& indexName, const Chain& tableName, CegoObject::ObjectType type, ListT<CegoField>& idxList)
{
- _pDBMng->useObject(tabSetId, tableName, CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE_WRITE);
+ _pDBMng->useObject(tabSetId, tableName, CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE_WRITE, _threadId);
try {
createIndexTable(tabSetId, indexName, tableName, idxList, type);
@@ -713,7 +713,7 @@
if ( hostName.toUpper() == h.getName().toUpper() )
{
- _pDBMng->useObject(tabSetId, objName, type, CegoDatabaseManager::EXCLUSIVE_WRITE);
+ _pDBMng->useObject(tabSetId, objName, type, CegoDatabaseManager::EXCLUSIVE_WRITE, _threadId);
try {
@@ -819,7 +819,7 @@
while ( pTable )
{
- _pDBMng->useObject(tabSetId, *pTable, CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE);
+ _pDBMng->useObject(tabSetId, *pTable, CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE, _threadId);
pTable = tableList.Next();
}
@@ -902,7 +902,7 @@
while ( pTable )
{
- _pDBMng->useObject(tabSetId, *pTable, CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE);
+ _pDBMng->useObject(tabSetId, *pTable, CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE, _threadId);
pTable = tableList.Next();
}
@@ -1017,6 +1017,16 @@
return getTID(tabSetId);
}
+void CegoDistManager::setThreadId(long tid)
+{
+ _threadId = tid;
+}
+
+long CegoDistManager::getThreadId() const
+{
+ return _threadId;
+}
+
void CegoDistManager::insertDistDataTable(CegoTableObject& oe, ListT<CegoField>& fvl)
{
@@ -1062,7 +1072,7 @@
void CegoDistManager::insertLocalDataTable(CegoTableObject& oe, ListT<CegoField>& fvl)
{
- _pDBMng->useObject(oe.getTabSetId(), oe.getName(), oe.getType(), CegoDatabaseManager::EXCLUSIVE_WRITE);
+ _pDBMng->useObject(oe.getTabSetId(), oe.getName(), oe.getType(), CegoDatabaseManager::EXCLUSIVE_WRITE, _threadId);
try {
@@ -1113,7 +1123,7 @@
{
long delCount = 0;
- _pDBMng->useObject(oe.getTabSetId(), oe.getName(), oe.getType(), CegoDatabaseManager::EXCLUSIVE_WRITE);
+ _pDBMng->useObject(oe.getTabSetId(), oe.getName(), oe.getType(), CegoDatabaseManager::EXCLUSIVE_WRITE, _threadId);
try {
@@ -1176,7 +1186,7 @@
beginTransaction(oe.getTabSetId());
}
- _pDBMng->useObject(oe.getTabSetId(), oe.getTabName(), CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE_WRITE);
+ _pDBMng->useObject(oe.getTabSetId(), oe.getTabName(), CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE_WRITE, _threadId);
try {
@@ -1202,7 +1212,7 @@
if ( forceTransaction )
{
- _pDBMng->useObject(oe.getTabSetId(), oe.getTabName(), CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE_WRITE);
+ _pDBMng->useObject(oe.getTabSetId(), oe.getTabName(), CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE_WRITE, _threadId);
try
{
@@ -1224,7 +1234,7 @@
if ( forceTransaction )
{
- _pDBMng->useObject(oe.getTabSetId(), oe.getTabName(), CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE);
+ _pDBMng->useObject(oe.getTabSetId(), oe.getTabName(), CegoObject::TABLE, CegoDatabaseManager::EXCLUSIVE, _threadId);
try
{
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoDistManager.h
^
|
@@ -119,6 +119,10 @@
int getDistTid( const Chain& tableSet);
int getLocalTid(int tabSetId);
+
+ void setThreadId(long tid);
+ long getThreadId() const;
+
void syncDistTableSet(const Chain& tableSet, const Chain& escCmd, int timeout);
void syncLocalTableSet(const Chain& tableSet, const Chain& escCmd, int timeout);
@@ -173,7 +177,10 @@
ListT<ActiveTSUser> _userList;
+ long _threadId;
+
unsigned long _modId;
+
};
#endif
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoExpr.cc
^
|
@@ -265,7 +265,7 @@
{
switch ( _expType )
{
- case ADD:
+ case ADD:
return ( _pExpr->evalFieldValue() + _pTerm->evalFieldValue() );
case SUB:
return ( _pExpr->evalFieldValue() - _pTerm->evalFieldValue() );
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoFieldValue.cc
^
|
@@ -1167,7 +1167,6 @@
CegoFieldValue operator + ( const CegoFieldValue& fv1, const CegoFieldValue& fv2 )
{
-
if ( fv1._type == NULL_TYPE )
{
return fv2;
@@ -1384,7 +1383,7 @@
BigDecimal d1 = BigDecimal( Chain((char*)(_pV)) );
BigDecimal d2 = BigDecimal( Chain((char*)(fv2._pV)) );
-
+
BigDecimal d3 = d1.sub(d2);
CegoFieldValue fv3(_type, d3.toChain());
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoFunction.cc
^
|
@@ -910,7 +910,7 @@
try
{
- _pTabMng->getDBMng()->useObject(_tabSetId, _funcName, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED);
+ _pTabMng->getDBMng()->useObject(_tabSetId, _funcName, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED, _pTabMng->getThreadId());
CegoProcedure* pProc = _pTabMng->getProcedure(_tabSetId, _funcName);
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoMain.cc
^
|
@@ -964,7 +964,8 @@
pTabMng = new CegoDistManager(pDBMng);
-
+ pTabMng->setThreadId(1);
+
pDBMng->log(modId, Logger::DEBUG, Chain("Starting tableset ") + tableSet + Chain(" ..."));
Host h;
@@ -979,66 +980,6 @@
pAction->addRole(CegoAction::ALL);
int tabSetId = pDBMng->getTabSetId(tableSet);
-
- /* since objects are loaded dynamically now,
- object load at startup is no more required
-
- // loading objects
- ListT<Chain> procList;
- pTabMng->getObjectList(tabSetId, CegoObject::PROCEDURE, procList);
-
- Chain *pProcName = procList.First();
- while ( pProcName )
- {
- pDBMng->log(modId, Logger::DEBUG, Chain("Compiling procedure ") + *pProcName + Chain(" ..."));
-
- CegoProcObject po;
- pTabMng->getObject(tabSetId, *pProcName, CegoObject::PROCEDURE, po);
-
- // cout << "ProcText=" << endl;
- // cout << "--------------" << endl;
- // cout << po.getProcText() << endl;;
-
- Chain loadString = Chain("load ") + po.getProcText();
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Loading <<<") + loadString + Chain(">>>"));
-
- pAction->setCommandChain(loadString);
- pAction->parse();
- CegoProcedure* pProc = pAction->getProcedure();
-
- pTabMng->addCompProcedure(tabSetId, pProc);
-
- pProcName = procList.Next();
- }
-
- ListT<Chain> viewList;
- pTabMng->getObjectList(tabSetId, CegoObject::VIEW, viewList);
-
- Chain *pViewName = viewList.First();
- while ( pViewName )
- {
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Compiling view ") + *pViewName + Chain(" ..."));
-
- CegoViewObject vo;
- pTabMng->getObject(tabSetId, *pViewName, CegoObject::VIEW, vo);
-
- Chain loadString = Chain("load ") + vo.getViewStmt();
-
- pDBMng->log(modId, Logger::DEBUG, Chain("Loading <<<") + loadString + Chain(">>>"));
-
- pAction->setCommandChain(loadString);
- pAction->parse();
- CegoSelect* pSelect = pAction->getSelect();
-
- CegoView *pView = new CegoView(*pViewName, pSelect);
-
- pTabMng->addCompView(tabSetId, pView);
-
- pViewName = viewList.Next();
- }
- */
if ( processBatchFile(pDBMng, pAction, batchFileName, ignoreError, true, errorMsg) == false )
exitCode = 1;
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoPredDesc.cc
^
|
@@ -457,6 +457,11 @@
return _isChecked;
}
+const Chain& CegoPredDesc::getPattern() const
+{
+ return _pattern;
+}
+
bool CegoPredDesc::match(const CegoFieldValue& val) const
{
if ( _pMatcher )
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoPredDesc.h
^
|
@@ -105,6 +105,7 @@
void cleanUp();
+ const Chain& getPattern() const;
bool match(const CegoFieldValue& val) const;
CegoPredDesc& operator = ( const CegoPredDesc& p);
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoQueryHelper.cc
^
|
@@ -471,10 +471,29 @@
}
else
{
- cout << "FALASE " << endl;
return false;
}
}
+ else if (pP->getMode() == CegoPredDesc::ISLIKE)
+ {
+ CegoAttrDesc* pAttrDesc;
+ pAttrDesc = pP->getExpr1()->checkAttr();
+ if ( pAttrDesc )
+ {
+ ac.add(CegoAttrComp(pAttrDesc->getAttrName(), pP->getPattern(), false));
+ }
+ return true;
+ }
+ else if (pP->getMode() == CegoPredDesc::ISNOTLIKE)
+ {
+ CegoAttrDesc* pAttrDesc;
+ pAttrDesc = pP->getExpr1()->checkAttr();
+ if ( pAttrDesc )
+ {
+ ac.add(CegoAttrComp(pAttrDesc->getAttrName(), pP->getPattern(), true));
+ }
+ return true;
+ }
else
{
return false;
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoSelect.cc
^
|
@@ -776,6 +776,7 @@
}
evalAggregation(jfl);
+
_aggDone=true;
return true;
}
@@ -1707,18 +1708,19 @@
}
else
{
+
idxMatch = _pGTM->distIndexExists( _joinList[i]->getTabSetId(),
_joinList[i]->getTabName(),
ac );
if ( idxMatch == CegoAttrCond::INAPP )
{
- useAttrCond = false;
- predChecked = false;
+ useAttrCond = true;
+ predChecked = true;
}
else if ( idxMatch == CegoAttrCond::PART )
{
useAttrCond = true;
- predChecked = false;
+ predChecked = true;
}
else if ( idxMatch == CegoAttrCond::FULL )
{
@@ -3354,6 +3356,7 @@
while ( pAgg )
{
+
if ( (*pAgg)->getType() == CegoAggregation::AVG )
{
CegoFieldValue avg;
@@ -3363,15 +3366,14 @@
avg = (CegoFieldValue)(*pAgg)->getFieldValue() / fv ;
}
(*pAgg)->setFieldValue(avg);
- resultList.Insert( (*pExpr)->evalFieldValue() );
- }
- else
- {
- resultList.Insert( (*pExpr)->evalFieldValue() );
+
}
pAgg = aggList.Next();
}
+
+ resultList.Insert( CegoField((*pExpr)->evalFieldValue()) );
+
pExpr = _exprList.Next();
}
}
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/src/CegoXPorter.cc
^
|
@@ -304,7 +304,7 @@
// to ensure, the view is compiled, we load it in any case
- _pDBMng->useObject(tabSetId, *pView, CegoObject::VIEW, CegoDatabaseManager::SHARED);
+ _pDBMng->useObject(tabSetId, *pView, CegoObject::VIEW, CegoDatabaseManager::SHARED, _pGTM->getThreadId());
try
{
_pGTM->getView(tabSetId, *pView);
@@ -360,7 +360,7 @@
_pDBMng->log(_modId, Logger::NOTICE, Chain("Exporting procedure ") + *pProc + Chain("..."));
// to ensure, the view is compiled, we load it in any case
- _pDBMng->useObject(tabSetId, *pProc, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED);
+ _pDBMng->useObject(tabSetId, *pProc, CegoObject::PROCEDURE, CegoDatabaseManager::SHARED, _pGTM->getThreadId());
try
{
_pGTM->getProcedure(tabSetId, *pProc);
|
[-]
[+]
|
Changed |
cego-2.10.13.tar.bz2/tools/cgmkdb
^
|
@@ -15,24 +15,54 @@
printUsage()
{
- echo "Usage : $0 <dbname> [ <root path> ]"
+ echo "Usage : $0 [ -r <root path>] [ -t <tableset> ] <dbname>"
}
-if [ $# -lt 1 ] || [ $# -gt 2 ]
+args=`getopt r:t: $*`
+
+if [ $? != 0 ]
then
printUsage
exit 1
fi
+set -- $args
+
+for i
+do
+ case "$i"
+ in
+ -r)
+ CEGOROOT=$2; shift;
+ shift;;
+ -t)
+ CEGOTABLESET=$2;shift;
+ shift;;
+ -h)
+ printUsage
+ exit 0;;
+ --)
+ DBNAME=$2
+ shift; break;;
+ esac
+done
+
+if [ -z "$DBNAME" ]
+then
+ echo "No dbname specified"
+ printUsage
+ exit 1
+fi
+
+
# path to the database root path, where the database should be created
-DBNAME=$1
-CEGOROOT=$2
if [ -z "$CEGOROOT" ]
then
CEGOROOT=$DEFCEGOROOT
fi
+
if [ ! -d $CEGOROOT ]
then
echo "Root directory $CEGOROOT must exist"
@@ -48,6 +78,13 @@
exit 1
fi
+if [ -z "$CEGOTABLESET" ]
+then
+ TS=${DBNAME}
+else
+ TS=${CEGOTABLESET}
+fi
+
echo "Creating database in directory $DBROOT ..."
# path to the cego executable
@@ -68,7 +105,6 @@
DEBUGLEVEL=NOTICE
# tableset defs
-TS=tsdef
TSROOT=${DBROOT}/data
TSTICKET=${TSROOT}/tsticket.xml
SYSSIZE=100
@@ -77,9 +113,9 @@
LOGFILENUM=3
SORTAREASIZE=10000000
APPFILE=${TSROOT}/${TS}data01.dbf
-APPSIZE=5000
-DBUSER=cego
-DBPWD=cego
+APPSIZE=3000
+DBUSER=${DBNAME}
+DBPWD=${DBNAME}
##########################
### end of customizing ###
@@ -88,7 +124,18 @@
# rm -rf ${TSROOT}
mkdir ${DBROOT}
+if [ $? != 0 ]
+then
+ echo "Cannot create database root directory"
+ exit 1
+fi
+
mkdir ${TSROOT}
+if [ $? != 0 ]
+then
+ echo "Cannot create tableset root directory"
+ exit 1
+fi
echo "Creating xml ..."
cat > $DBXML <<EOF
@@ -105,6 +152,13 @@
</DATABASE>
EOF
+if [ $? != 0 ]
+then
+ echo "Cannot create database xml file"
+ exit 1
+fi
+
+
# <MODULE NAME="CegoTableManager" LEVEL="NOTICE"></MODULE>
# <MODULE NAME="CegoAdminThreadPool" LEVEL="NOTICE"></MODULE>
# <MODULE NAME="CegoSelect" LEVEL="NOTICE"></MODULE>
@@ -149,3 +203,9 @@
exit 1
fi
+/bin/echo "Creating database start script ..."
+/bin/echo "nohup cego --mode=daemon --dbxml=${DBXML} --tableset=${TS} &" > ${DBROOT}/startdb
+chmod 755 ${DBROOT}/startdb
+/bin/echo "Creating database stop script ..."
+/bin/echo "kill -INT \`cat ${DBROOT}/pid\`" > ${DBROOT}/stopdb
+chmod 755 ${DBROOT}/stopdb
\ No newline at end of file
|
[-]
[+]
|
Added |
cego-2.10.13.tar.bz2/tools/cgmkdb~
^
|
@@ -0,0 +1,176 @@
+#!/bin/bash
+#
+# mkcgdb
+# ------
+# Utility script to build up a cego database with one tableset
+#
+# (C)opyright 2010 by Bjoern Lemke
+#
+# The database and tableset parameters defined below
+# should be edited and customized to appropriate values
+#
+#
+
+DEFCEGOROOT=/usr/local/cego
+
+printUsage()
+{
+ echo "Usage : $0 [ -r <root path>] [ -t <tableset> ] <dbname>"
+}
+
+args=`getopt r:t: $*`
+
+if [ $? != 0 ]
+then
+ printUsage
+ exit 2
+fi
+
+set -- $args
+
+for i
+do
+ case "$i"
+ in
+ -r)
+ CEGOROOT=$2; shift;
+ shift;;
+ -t)
+ CEGOTABLESET=$2;shift;
+ shift;;
+ --)
+ DBNAME=$2
+ shift; break;;
+ esac
+done
+
+# path to the database root path, where the database should be created
+
+if [ -z "$CEGOROOT" ]
+then
+ CEGOROOT=$DEFCEGOROOT
+fi
+
+
+if [ ! -d $CEGOROOT ]
+then
+ echo "Root directory $CEGOROOT must exist"
+ exit 1
+fi
+
+DBROOT=$CEGOROOT/$DBNAME
+
+if [ -d $DBROOT ]
+then
+ echo "Root directory $DBROOT/$DBNAME already exists"
+ echo "Must be removed manually to create database"
+ exit 1
+fi
+
+if [ -z "$CEGOTABLESET" ]
+then
+ TS=${DBNAME}
+else
+ TS=${CEGOTABLESET}
+fi
+
+echo "Creating database in directory $DBROOT ..."
+
+# path to the cego executable
+CEGO=cego
+# name of the database xml file
+DBXML=${DBROOT}/${DBNAME}.xml
+# several database parameters
+PAGESIZE=16384
+ADMPORT=2000
+DBPORT=2200
+LOGPORT=3000
+PIDFILE=${DBROOT}/pid
+ADMINUSER=cgadm
+ADMINPWD=cgadm
+LOGFILE=${DBROOT}/cego.log
+
+# DEBUGLEVEL=DEBUG
+DEBUGLEVEL=NOTICE
+
+# tableset defs
+TSROOT=${DBROOT}/data
+TSTICKET=${TSROOT}/tsticket.xml
+SYSSIZE=100
+TMPSIZE=3000
+LOGFILESIZE=1000000
+LOGFILENUM=3
+SORTAREASIZE=10000000
+APPFILE=${TSROOT}/${TS}data01.dbf
+APPSIZE=3000
+DBUSER=${DBNAME}
+DBPWD=${DBNAME}
+
+##########################
+### end of customizing ###
+##########################
+
+# rm -rf ${TSROOT}
+
+mkdir ${DBROOT}
+mkdir ${TSROOT}
+
+echo "Creating xml ..."
+cat > $DBXML <<EOF
+<?xml version="1.0" ?>
+<!DOCTYPE CEGO_DB_SPEC>
+<DATABASE NAME="$DBNAME" PAGESIZE="$PAGESIZE"
+ADMINPORT="$ADMPORT" LOGPORT="$LOGPORT" DATAPORT="$DBPORT"
+PIDFILE="$PIDFILE" MAXFID="1" MAXTSID="1"
+NUMRECSEMA="1000" NUMSYSPAGESEMA="43" NUMDATAPAGESEMA="43"
+NUMIDXPAGESEMA="43" NUMRBPAGESEMA="43" NUMDATAFILESEMA="11"
+NUMBUFFERPOOLSEMA="11" MAXFIXTRIES="30"
+CSMODE="ON" QESCMODE="ON" LOGMNGPROG="./cglogmng">
+<MODULE NAME="ALL" LEVEL="$DEBUGLEVEL"></MODULE>
+</DATABASE>
+EOF
+
+# <MODULE NAME="CegoTableManager" LEVEL="NOTICE"></MODULE>
+# <MODULE NAME="CegoAdminThreadPool" LEVEL="NOTICE"></MODULE>
+# <MODULE NAME="CegoSelect" LEVEL="NOTICE"></MODULE>
+
+/bin/echo -n "Creating admin user ..."
+${CEGO} --mode=setadminuser --dbxml=${DBXML} --user=${ADMINUSER}/${ADMINPWD} --logfile=${LOGFILE}
+if [ $? -eq 0 ]
+then
+ echo "... operation ok"
+else
+ echo "... operation failed"
+ exit 1
+fi
+
+/bin/echo -n "Defining tableset $TS1..."
+${CEGO} --mode=define --tableset=${TS} -dbxml=${DBXML} --tsdef=tsroot:${TSROOT},tsticket:${TSTICKET},syssize:${SYSSIZE},tmpsize:${TMPSIZE},logfilesize:${LOGFILESIZE},logfilenum:${LOGFILENUM},appfile:${APPFILE},appsize:${APPSIZE},sortareasize=${SORTAREASIZE} --logfile=${LOGFILE}
+if [ $? -eq 0 ]
+then
+ echo "... operation ok"
+else
+ echo "... operation failed"
+ exit 1
+fi
+
+/bin/echo -n "Creating database user for $TS1 ..."
+${CEGO} --mode=setdbuser --tableset=${TS} --dbxml=${DBXML} --user=${DBUSER}/${DBPWD} --role=ALL --logfile=${LOGFILE}
+if [ $? -eq 0 ]
+then
+ echo "... operation ok"
+else
+ echo "... operation failed"
+ exit 1
+fi
+
+/bin/echo -n "Creating tableset $TS1..."
+${CEGO} --mode=create --dbxml=${DBXML} --tableset=${TS} --logfile=${LOGFILE}
+if [ $? -eq 0 ]
+then
+ echo "... operation ok"
+else
+ echo "... operation failed"
+ exit 1
+fi
+
|