From 8f27e65bddd7d4b8515ce620fb485fdd78fcdf89 Mon Sep 17 00:00:00 2001 From: Constantin Jucovschi Date: Fri, 24 Apr 2009 07:20:22 -0400 Subject: Initial commit --- servercomm/test/Makefile | 117 +++++++++++++++++++ servercomm/test/template_inst.hh | 138 ++++++++++++++++++++++ servercomm/test/test_dbcontent.cc | 161 ++++++++++++++++++++++++++ servercomm/test/test_oid.cc | 229 +++++++++++++++++++++++++++++++++++++ servercomm/test/test_servercomm.cc | 128 +++++++++++++++++++++ 5 files changed, 773 insertions(+) create mode 100644 servercomm/test/Makefile create mode 100644 servercomm/test/template_inst.hh create mode 100644 servercomm/test/test_dbcontent.cc create mode 100644 servercomm/test/test_oid.cc create mode 100644 servercomm/test/test_servercomm.cc (limited to 'servercomm/test') diff --git a/servercomm/test/Makefile b/servercomm/test/Makefile new file mode 100644 index 0000000..bf035b4 --- /dev/null +++ b/servercomm/test/Makefile @@ -0,0 +1,117 @@ +# -*-Makefile-*- +# +# This file is part of rasdaman community. +# +# Rasdaman community 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 3 of the License, or +# (at your option) any later version. +# +# Rasdaman community 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 rasdaman community. If not, see . +# +# Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +# rasdaman GmbH. +# +# For more information please see +# or contact Peter Baumann via . # Top Level makefile. This points to the various modules that have to be build +# and/or deployed +# +# MAKEFILE FOR: +# test programs of module servercomm +######################### Definitions ############################ + +# standard include with general options +include $(RMANBASE)/Makefile.inc + +# all test programs +SRCCXX = test_servercomm.cc test_dbcontent.cc test_oid.cc +OBJS = ${SRCCXX:%.cc=%.o} +ALLTESTS = ${SRCCXX:%.cc=%} + +# some additional flags for compiling and linking + +CXXFLAGS += -I$(RMANBASE)/servercomm +LDFLAGS := -I$(RMANBASE)/servercomm $(LDFLAGS) + +# add communication flags +CXXFLAGS += $(COMMCXXFLAGS) +LDFLAGS += $(COMMLDFLAGS) + +# add compile and link options for STL +CXXFLAGS += $(STLCXXFLAGS) +LDFLAGS += $(STLLDFLAGS) + +########################### Targets ############################## + +# test target for servercomm +.PHONY : servercomm +servercomm: adminif raslib test_module test_servercomm + +# test target for dbcontent +.PHONY : dbcontent +dbcontent: adminif raslib test_module test_dbcontent + +.PHONY : adminif +adminif: + cd $(RMANBASE)/reladminif; $(MAKE) + +.PHONY : raslib +raslib: + cd $(RMANBASE)/raslib; $(MAKE) + +.PHONY : qlparser +qlparser: + cd $(RMANBASE)/qlparser; $(MAKE) + +.PHONY : test_module +test_module: + cd $(RMANBASE)/servercomm; $(MAKE) + +test_servercomm: test_servercomm.o \ + $(QLPARSER) \ + $(SERVERCOMM) \ + $(CACHETAMGR) \ + $(MDDIF) \ + $(CATALOGIF) \ + $(INDEXIF) \ + $(INDEXMGR) \ + $(BLOBIF) \ + $(ADMINIF) \ + $(PREPROCESSOR) \ + $(STORAGEMGR) \ + $(TILEMGR) \ + $(RASLIB) \ + $(RELINDEX) \ + $(INDEXIF) + $(CXX) $(LDFLAGS) -o $@ $^ $(QLPARSER) $(INDEXMGR) $(CACHETAMGR) $(RELINDEX) $(RELSTORAGEIF) $(RELADMINIF) $(STORAGEMGR) $(CONVERSION) $(INDEXIF) $(RELCATALOGIF) /usr/local/pgsql/lib/libpq.a /usr/local/pgsql/lib/libecpg.a -lssl -lcrypt /usr/local/pgsql/lib/libpgtypes.a -lm -ljpeg -ltiff -lpng -lmfhdf -ldf -lz -ldl -lcrypto + +test_dbcontent: test_dbcontent.o \ + $(QLPARSER) \ + $(SERVERCOMM) \ + $(RASLIB) \ + $(CACHETAMGR) \ + $(MDDIF) \ + $(CATALOGIF) \ + $(INDEXIF) \ + $(INDEXMGR) \ + $(BLOBIF) \ + $(ADMINIF) + $(CXX) $(LDFLAGS) $(O2LDFLAGS) -o $@ $^ $(QLPARSER) $(INDEXMGR) $(CACHETAMGR) -lm + +test_oid: test_oid.o $(RASLIB) $(CACHETAMGR)\ + $(MDDIF) $(CATALOGIF) $(INDEXIF) $(INDEXMGR) $(BLOBIF) $(ADMINIF) + $(PURIFY) $(CXX) $(O2LDFLAGS) $(LDFLAGS) -o $@ $^ \ + $(RASLIB) -lm -L$(SUPPORT_BASE)/lib -lz + + +# general rules +include $(RMANBASE)/Makefile.rel + +# automatically created dependencies +include Makefile.dep diff --git a/servercomm/test/template_inst.hh b/servercomm/test/template_inst.hh new file mode 100644 index 0000000..569c0bf --- /dev/null +++ b/servercomm/test/template_inst.hh @@ -0,0 +1,138 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see . +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see +* or contact Peter Baumann via . +*/ + +//for rb_tree, select1st +#include +#include +#include +#include +#include + +#if(__GNUC__==2 &&__GNUC_MINOR__==95) +using std::rb_tree; +using std::select1st; +#else +using __gnu_cxx::rb_tree; +using __gnu_cxx::select1st; +#endif + +using std::vector; +using std::pair; + +// commented by Constantin Jucovschi (gcc 3.4+ no longer supports __default_alloc_template) +//using std::__default_alloc_template; +using std::fill_n; + +#include "qlparser/symtab.hh" + +#include "raslib/attribute.hh" +#include "raslib/itertype.hh" +#include "raslib/dlist.hh" + +#include "tile.hh" + +#include "indexmgr/keyobject.hh" + +#include "reladminif/dbref.hh" +#include "reladminif/dbobjectiditerator.hh" + +#include "relblobif/blobtile.hh" +#include "relblobif/dbtile.hh" +#include "relblobif/inlinetile.hh" + +#include "relcatalogif/typeiterator.hh" +#include "relcatalogif/settype.hh" +#include "relcatalogif/structtype.hh" +#include "relcatalogif/mddtype.hh" +#include "relcatalogif/inlineminterval.hh" +#include "relcatalogif/dbminterval.hh" + +#include "relindexif/dbtcindex.hh" +#include "relindexif/hierindex.hh" +#include "relindexif/dbrcindexds.hh" + +#include "relmddif/dbmddobj.hh" +#include "relmddif/dbmddset.hh" + +#include "relstorageif/dbudfds.hh" +#include "relstorageif/dbudfpackageds.hh" +#include "relstorageif/dbstoragelayout.hh" + +template class SymbolTable; + +template class r_IterType; + +template class DBRef; +template class DBRef; +template class DBRef; +template class DBRef; +template class DBRef; +template class DBRef; +template class DBRef; +template class DBRef; +template class DBRef; +template class DBRef; +template class DBRef; +//template class DBRef; +// template bool operator< (const DBRef&, const DBRef&); + +//template TypeIterator; +//template TypeIterator; +template class TypeIterator; +template class DBRef; +template class DBRef; + +template class DBObjectIdIterator; +template class DBObjectIterator; +template class DBObjectIterator; +template class DBObjectIterator; +template class DBObjectIterator; +template class DBRef; +template class DBRef; +template class DBRef; + +template std::ostream& operator<< (const vector&, std::ostream&); +template std::ostream& operator<< (std::ostream &, const vector&); +template std::ostream& operator << (std::ostream& os, const std::vector& list); +template std::ostream& operator << (std::ostream& os, const std::vector& list); + +template class rb_tree, select1st >, less >; +template class rb_tree, select1st >, less >; +template class rb_tree >, select1st > >, less >; +template class rb_tree, select1st >, less >; +template class rb_tree, select1st >, less >; +template class rb_tree, select1st >, less >; +template class rb_tree, select1st >, less >; +template class rb_tree, select1st >, less >; +template class rb_tree, select1st >, less >; +template class vector; +template class vector; +template class vector; +template class vector; +template class vector; +template class vector; +template class vector; +template class vector; + +template class Tile ** fill_n(Tile **, unsigned int, Tile * const &); + diff --git a/servercomm/test/test_dbcontent.cc b/servercomm/test/test_dbcontent.cc new file mode 100644 index 0000000..a0bd6da --- /dev/null +++ b/servercomm/test/test_dbcontent.cc @@ -0,0 +1,161 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see . +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see +* or contact Peter Baumann via . +/ +/** + * SOURCE: test_dbcontent.cc + * + * MODULE: test + * + * PURPOSE: + * Reads the contents of the specified collection and prints + * it on the screen. + * + * COMMENTS: + * none + * +*/ + +#include +#include + +#include "o2template_CC.hxx" // declaration of O2 ref and coll classes + +#include "ulongtype.hh" + +#include "cachetamgr/persmddcoll.hh" +#include "cachetamgr/persmddobj.hh" +#include "cachetamgr/perstile.hh" + +#include "cachetamgr/persmddcolliter.hh" + +#include "adminif.hh" +#include "databaseif.hh" +#include "transactionif.hh" + +#include + +extern char* myExecArgv0 = ""; + +static void testAccessing( const char* collName ); + +/************************************************************* + * Function name.: int main( int argc, char** argv) + * + * Arguments.....: + * argc: number of arguments given to program + * argv: array of char* with arguments + * Return value..: exit status + * Description...: none + ************************************************************/ + +void +main( int ac, char** av) +{ + char baseName[255]; + char collName[255]; + + if( ac > 1 ) + strcpy( baseName, av[1] ); + else + strcpy( baseName, "RasDaBase" ); + + if( ac > 2 ) + strcpy( collName, av[2] ); + else + strcpy( collName, "Images" ); + + pid_t cpid; + cout << "Parent process id is " << getpid() << endl; + + cpid = fork(); + + if( !cpid ) + { + cout << "Child process id is " << getpid() << endl; + // sleep(1); + } + + // variables representing O2 database, ta and session + DatabaseIf database; + TransactionIf ta; + + // don't forget to initialize before using AdminIf! + myExecArgv0 = av[0]; + AdminIf* myAdmin = AdminIf::instance(); + + // connect to the database + cout << getpid() << " Connecting to database " << baseName << "..." << endl; + database.open( baseName ); + + // read coll and print contents + cout << getpid() << " Read collection and print contents..." << endl; + ta.begin(); + testAccessing( collName ); + ta.commit(); + + cout << getpid() << " closing db ... "; cout.flush(); + database.close(); + cout << getpid() << " OK" << endl; + + cout << getpid() << " Ending O2 session..." << endl; + delete myAdmin; + cout << getpid() << " OK" << endl; + + return; +} + + + +/************************************************************* + * Function......: testAccessing() + * + * Arguments.....: none + * Return value..: none + * Description...: reads DirTilesIx's and shows contents + ************************************************************/ + +static void testAccessing( const char* collName ) +{ + PersMDDObj* accessedObj; + + cout << getpid() << " ....testAccessing" << endl; + /* + PersMDDColl objsSet( collName ); + + // To test PersMDDColl::printStatus( ) + objsSet.printStatus( ); + + // To test PersMDDObj::printStatus( ), MDDCollIter::createIterator( ) and + // MDDCollIter methods : + MDDCollIter* objsIt = objsSet.createIterator( ); + + for( int i = 1 ; objsIt->notDone( ); i++, objsIt->advance( )) + { + accessedObj = (PersMDDObj*) objsIt->getElement(); + cout << " --"<printStatus(); + } + delete objsIt; + */ +} + + diff --git a/servercomm/test/test_oid.cc b/servercomm/test/test_oid.cc new file mode 100644 index 0000000..280b499 --- /dev/null +++ b/servercomm/test/test_oid.cc @@ -0,0 +1,229 @@ +/* +* This file is part of rasdaman community. +* +* Rasdaman community 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 3 of the License, or +* (at your option) any later version. +* +* Rasdaman community 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 rasdaman community. If not, see . +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see +* or contact Peter Baumann via . +/ +/** + * SOURCE: test_dbcontent.cc + * + * MODULE: test + * + * PURPOSE: + * Reads the contents of the specified collection and prints + * it on the screen. + * + * COMMENTS: + * none + * +*/ + +#include +#include + +#include "o2template_CC.hxx" // declaration of O2 ref and coll classes + +#include "ulongtype.hh" + +#include "cachetamgr/persmddcoll.hh" +#include "cachetamgr/persmddobj.hh" +#include "cachetamgr/perstile.hh" + +#include "cachetamgr/persmddcolliter.hh" + +#include "adminif.hh" +#include "databaseif.hh" +#include "transactionif.hh" + +#include + +RMINITGLOBALS('C') + +extern char* myExecArgv0 = ""; + +static void +insertObj( char* dbName, OId o, char* cn ) +{ + MDDBaseType* mddType = (MDDBaseType*)TypeFactory::mapMDDType( "GreyImage" ); + r_Minterval domain( "[0:9,0:9]" ); + + // cout << " " << o << "," << cn << " ... " << flush; + + PersMDDObj* obj = new PersMDDObj( mddType, domain, dbName, o ); + PersMDDColl objsSet( cn ); + objsSet.insert( obj ); + delete obj; +} + + +static void removeObj( char* dbName, char* collName, OId o ) +{ + // open collection + PersMDDColl* coll = 0; + + char answer = 'n'; + cout << endl << "SCAN (y/n) ?" << flush; + cin >> answer; + + if( answer == 'y' ) + { + coll = new PersMDDColl( collName ); + MDDCollIter* collIter = coll->createIterator(); + MDDObj* mddObj; + for( collIter->reset(); collIter->notDone(); collIter->advance() ) + { + mddObj = collIter->getElement(); + /* + if( mddObj->isPersistent() ) + { + EOId eOId; + ((PersMDDObj*)mddObj)->getEOId( &eOId ); + + cout << "MDD " << eOId.getOId() << flush; + } + */ + + } + /* + cout << endl << "PRINT OBJECT (y/n) ?" << flush; + cin >> answer; + if( answer == 'y' ) + mddObj->printStatus( ); + */ + delete collIter; + + coll->releaseAll(); + delete coll; + + cout << endl << "SCAN end" << endl; + } + + coll = new PersMDDColl( collName ); + + if( coll ) + { + cout <<"o == " << o << " dbName == " << dbName << endl; + coll->remove( o, dbName ); + + coll->releaseAll(); + delete coll; + } +} + + +int checkArguments( int argc, char** argv, const char* searchText, int& optionValueIndex ) +{ + int found = 0; + int i=1; + + while( !found && i. +* +* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann / +rasdaman GmbH. +* +* For more information please see +* or contact Peter Baumann via . +/ +/** + * SOURCE: test_servercomm.cc + * + * MODULE: servercomm + * + * COMMENTS: + * None +*/ + + + +#include + +#define __EXECUTABLE__ +#define EARLY_TEMPLATE +#define DEBUG_MAIN +#define DEBUG +#include "debug.hh" +#include "template_inst.hh" + +#include "raslib/rmdebug.hh" +#include "qlparser/qtscalardata.hh" + +#include "servercomm/servercomm.hh" + + +extern char* myExecArgv0 = ""; +extern int tiling = 1; +extern unsigned long maxTransferBufferSize = 4000000; +extern int globalOptimizationLevel = 4; +extern char* dbSchema = 0; +extern int noTimeOut = 0; +char globalConnectId[255] = {0}; +bool udfEnabled = true; + +RMINITGLOBALS('C'); + +#include + + +int checkArguments( int argc, char** argv, const char* searchText, int& optionValueIndex ) +{ + int found = 0; + int i=1; + + while( !found && i::iterator i; + /* for (i=r->transferData->begin(); i!=r->transferData->end(); ++i) { + // t = (QtScalarData*)(*i); + // t->printStatus(); + }*/ + } + catch ( r_Error& errorObj ) + { + cerr << errorObj.what() << endl; + return -1; + } + catch ( ... ) + { + cerr << "Unknown exception caught in main." << endl; + return -1; + } + + return 0; +} -- cgit