diff --git a/Database/APR/FileCatalog/CMakeLists.txt b/Database/APR/FileCatalog/CMakeLists.txt index 2bd4add0bd233c3847ea6d4e663695974107e4a3..52ba24f02cbce55b98b5e16870062806766217a5 100644 --- a/Database/APR/FileCatalog/CMakeLists.txt +++ b/Database/APR/FileCatalog/CMakeLists.txt @@ -12,6 +12,7 @@ atlas_depends_on_subdirs( PUBLIC PRIVATE GaudiKernel AtlasTest/TestTools + Database/PersistentDataModel ) # Component(s) in the package: @@ -19,7 +20,8 @@ atlas_add_library( FileCatalog src/*.cpp PUBLIC_HEADERS FileCatalog INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${CORAL_LIBRARIES} POOLCore GaudiKernel AthenaBaseComps + LINK_LIBRARIES ${CORAL_LIBRARIES} POOLCore + GaudiKernel AthenaBaseComps PersistentDataModel PRIVATE_LINK_LIBRARIES TestTools ) atlas_add_test( URIParser_test diff --git a/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h b/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h index bc774adcde7037f6db38c13e76f2810f6c137f27..80bf9bd3676e915ca10943076f14a9ed3304d806 100644 --- a/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h +++ b/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h @@ -34,11 +34,13 @@ namespace pool { // ------------------------------ Catalog interface /// Create file identifier using UUID mechanism - std::string createFID() const { return _fc->createFID(); } + std::string createFID() const; void connect() { /* not doing anything in Gaudi FC */ } void disconnect() { /* not doing anything in Gaudi FC */ } - + /// Get the connect string + const std::string& connectInfo() const { return _fc->connectInfo(); } + /// redirect to init() for Gaudi FC void start() { init(); } /// Parse the DOM tree of the XML catalog @@ -116,8 +118,10 @@ namespace pool { /// Add new catalog identified by reference to the existing ones //void addCatalog( Gaudi::IFileCatalog* cat ) { _mgr->addCatalog(cat); } - /// Remove catalog identified by name from the existing ones + + /// Remove catalog identified by name from the existing ones. * or '' removes all void removeCatalog( const std::string& connect ) { _mgr->removeCatalog(connect); } + /// Remove catalog identified by reference from the existing ones //void removeCatalog( const Gaudi::IFileCatalog* cat ) { _mgr->removeCatalog(cat); } /// Access catalog container diff --git a/Database/APR/FileCatalog/src/IFileCatalog.cpp b/Database/APR/FileCatalog/src/IFileCatalog.cpp index 3830d0778662ecf9589d83d59c62a2cc985e51f9..8dd6ae17b57ffc34e711a8ce451619415c6f4d35 100644 --- a/Database/APR/FileCatalog/src/IFileCatalog.cpp +++ b/Database/APR/FileCatalog/src/IFileCatalog.cpp @@ -7,6 +7,7 @@ #include "GaudiKernel/SmartIF.h" #include "GaudiKernel/Bootstrap.h" #include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/IMessageSvc.h" #include <algorithm> #include "POOLCore/SystemTools.h" @@ -15,11 +16,8 @@ #include "FileCatalog/IFileCatalog.h" #include "AthenaBaseComps/AthMessaging.h" +#include "PersistentDataModel/Guid.h" -#include "GaudiKernel/IMessageSvc.h" -#include "GaudiKernel/Service.h" - -#include <iostream> using namespace pool; @@ -34,7 +32,16 @@ pool::IFileCatalog::IFileCatalog() Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc") ->setOutputLevel("XMLCatalog", SystemTools::GetOutputLvl() ); } - + + +std::string pool::IFileCatalog:: +createFID() const +{ + Guid myuid; + Guid::create(myuid); + return myuid.toString(); +} + void pool::IFileCatalog:: getFirstPFN( const std::string& fid, std::string& pfn, std::string& tech ) const @@ -75,8 +82,9 @@ registerPFN( const std::string& pfn, const std::string& ftype, std::string& fid if( existsPFN(pfn) ) { throw pool::Exception(std::string("PFN '") + pfn + "' already registered", "registerPFN", "FileCatalog"); } -// std::cout << "msg() level" << msg().level() << std::endl; + std::cout << "registerPFN: " << pfn << " GUID=" << fid << std::endl; if( fid.empty() ) fid = createFID(); + std::cout << "registerPFN: " << pfn << " GUID=" << fid << std::endl; ATH_MSG_DEBUG("Registering PFN=" << pfn << " of type=" << ftype << " GUID=" << fid); _fc->registerPFN(fid, pfn, ftype); } diff --git a/Database/APR/FileCatalog/utilities/FClistPFN.cpp b/Database/APR/FileCatalog/utilities/FClistPFN.cpp index 7d48e99b594a68098cea7c565b8bf24c2bcae7f6..e50c07f4fb50372322fa1607f7e090e005bf02cd 100755 --- a/Database/APR/FileCatalog/utilities/FClistPFN.cpp +++ b/Database/APR/FileCatalog/utilities/FClistPFN.cpp @@ -23,7 +23,7 @@ void printUsage(){ std::cout<<"usage: FClistPFN [-l lfname] [-u contactstring] [-t -h]" <<std::endl; } -static const char* opts[] = {"t","l","u","h",0}; +static const char* opts[] = {"t","l","u","f","h",0}; class contactParser{ @@ -57,7 +57,7 @@ int main(int argc, char** argv) std::string myuri; std::string mylfn; - std::string query(""); + std::string myfid; bool printall=false; try{ CommandLine commands(argc,argv); @@ -71,6 +71,9 @@ int main(int argc, char** argv) if( commands.Exists("l") ){ mylfn=commands.GetByName("l"); } + if( commands.Exists("f") ){ + myfid=commands.GetByName("f"); + } if( commands.Exists("t") ){ printall=true; } @@ -83,9 +86,6 @@ int main(int argc, char** argv) exit(0); } - if(!query.empty()&&!mylfn.empty()){ - std::cerr<< "Warning: list PFN by LFN..." <<std::endl; - } try{ std::auto_ptr<IFileCatalog> mycatalog(new IFileCatalog); if(myuri.empty()) { @@ -106,9 +106,12 @@ int main(int argc, char** argv) pool::IFileCatalog::Strings fids; if( !mylfn.empty() ) { fids.push_back( mycatalog->lookupLFN( mylfn ) ); - }else{ + } else if( !myfid.empty() ) { + fids.push_back( myfid ); + } else { + // go through all FIDs in the catalog mycatalog->getFIDs( fids ); - } + } for( const auto& fid: fids ) { pool::IFileCatalog::Files files; mycatalog->getPFNs( fid, files ); diff --git a/Database/APR/PersistencySvc/src/UserDatabase.cpp b/Database/APR/PersistencySvc/src/UserDatabase.cpp index d7baf854411df4ed2429fe77cd40c9666a35774a..acaf39ddc97af2332ace9146e6652d1af7f7e055 100644 --- a/Database/APR/PersistencySvc/src/UserDatabase.cpp +++ b/Database/APR/PersistencySvc/src/UserDatabase.cpp @@ -12,11 +12,9 @@ #include "PersistencySvc/ITransaction.h" #include "StorageSvc/DbType.h" #include "StorageSvc/pool.h" -#include "CoralBase/MessageStream.h" #include "FileCatalog/IFileCatalog.h" +#include "POOLCore/DbPrint.h" -#include <iostream> -using namespace std; static const std::string& emptyString = ""; @@ -156,7 +154,6 @@ pool::PersistencySvc::UserDatabase::connectForWrite( const pool::DatabaseConnect switch( m_nameType ) { case pool::DatabaseSpecification::PFN: m_the_pfn = m_name; - cout << "MN: connect write: " << m_the_pfn << endl; if ( this->fid().empty() ) { if( policy.writeModeForNonExisting() == pool::DatabaseConnectionPolicy::RAISE_ERROR ) { throw pool::PersistencySvcException( "Could not find the PFN \"" + m_name + "\" in the file catalog", @@ -171,7 +168,8 @@ pool::PersistencySvc::UserDatabase::connectForWrite( const pool::DatabaseConnect pool::DbType dbType( m_technology ); pool::DbType dbTypeMajor( dbType.majorType() ); m_catalog.registerPFN( m_the_pfn, dbTypeMajor.storageName(), m_the_fid ); - cout << "MN: registered PFN: " << m_the_pfn << " with FID:" << m_the_fid << endl; + DbPrint log("PersistencySvc::UserDB::connectForWrite()" ); + log << DbPrintLvl::Debug << "registered PFN: " << m_the_pfn << " with FID:" << m_the_fid << endmsg; dbRegistered = true; accessMode = pool::CREATE; } @@ -293,14 +291,14 @@ pool::PersistencySvc::UserDatabase::fid() const if ( m_nameType == pool::DatabaseSpecification::PFN ) { std::string technology; m_catalog.lookupFileByPFN( m_name, m_the_fid, technology ); - cout << "MN: lookup PFN: " << m_the_pfn << " returned FID: '" << m_the_fid << "'" - << " tech=" << technology << endl; + DbPrint log("PersistencySvc::UserDB::fid()" ); + log << DbPrintLvl::Debug << "lookupPFN: " << m_name << " returned FID: '" << m_the_fid << "'" + << " tech=" << technology << endmsg; if ( ! m_the_fid.empty() ) { if( technology.empty() ) { m_nameType = DatabaseSpecification::LFN; - coral::MessageStream log( "PersistencySvc::UserDatabase::fid()" ); - log << coral::Debug << "Retrying 'connect' using assumed PFN " << m_name - << " as LFN (no tech found in PFC)" << coral::MessageStream::endmsg; + log << DbPrintLvl::Debug << "Retrying 'connect' using assumed PFN " << m_name + << " as LFN (no tech found in PFC)" << endmsg; return m_the_fid; } m_the_pfn = m_name; @@ -310,15 +308,12 @@ pool::PersistencySvc::UserDatabase::fid() const else { if( m_transaction.type() != pool::ITransaction::UPDATE ) { // Fetch the FID from the db itself ! if( !m_technologySet ) { - coral::MessageStream log( "PersistencySvc::UserDatabase::fid()" ); - log << coral::Debug << "Opening database '" << m_name - << "' with no catalog entry and no technology set - assuming ROOT storage" - << coral::MessageStream::endmsg; + log << DbPrintLvl::Debug << "Opening database '" << m_name + << "' with no catalog entry and no technology set - assuming ROOT storage" << endmsg; m_technology = pool::ROOT_StorageType.type(); m_technologySet = true; } pool::PersistencySvc::MicroSessionManager& sessionManager = m_technologyDispatcher.microSessionManager( m_technology ); - cout << "MN: creating FID for PFN: " << m_name << endl; m_the_fid = sessionManager.fidForPfn( m_name ); if ( ! m_the_fid.empty() ) { m_the_pfn = m_name; diff --git a/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx b/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx index 5be656dfa9a1ec604194d1bafa8e8aa8aa63049f..77b717c8649d41773fa9604d73f70b87a52cd4c9 100644 --- a/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx +++ b/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx @@ -862,6 +862,7 @@ StatusCode PoolSvc::setFrontierCache(const std::string& conn) const { //__________________________________________________________________________ pool::IFileCatalog* PoolSvc::createCatalog() { pool::IFileCatalog* ctlg = new pool::IFileCatalog; + ctlg->removeCatalog("*"); for (auto& catalog : m_readCatalog.value()) { ATH_MSG_DEBUG("POOL ReadCatalog is " << catalog); if (catalog.substr(0, 8) == "apcfile:" || catalog.substr(0, 7) == "prfile:") {