Skip to content
Snippets Groups Projects
Commit 3be69b8c authored by Marcin Nowak's avatar Marcin Nowak :radioactive:
Browse files

Final cleanup for Gaudi FC + a switch to ATLAS Guid generator

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