diff --git a/Database/APR/CollectionBase/test/Factory_test.cxx b/Database/APR/CollectionBase/test/Factory_test.cxx index 9894b9a1f96f786683524fbbc151aedf826229c5..fffbfe50c12ecc2a6f80ed123e3dcd7628d464de 100644 --- a/Database/APR/CollectionBase/test/Factory_test.cxx +++ b/Database/APR/CollectionBase/test/Factory_test.cxx @@ -10,6 +10,7 @@ #include "PersistentDataModel/Token.h" #include "FileCatalog/IFileCatalog.h" +#include "POOLCore/SystemTools.h" #include "CollectionBase/ICollection.h" #include "CollectionBase/CollectionDescription.h" @@ -22,6 +23,8 @@ using namespace pool; int main(int argc, char** ) { + SystemTools::initGaudi(); + bool crude = argc>1; (void)remove ("CollectionCatalog0.xml"); diff --git a/Database/APR/CollectionUtilities/src/CollAppendBase.cpp b/Database/APR/CollectionUtilities/src/CollAppendBase.cpp index 1e246fafe47d0dd9623ca593fa6aef80137e0720..18f6fcdc3ad20ad49a1c8bde21a9cfef0199cf66 100644 --- a/Database/APR/CollectionUtilities/src/CollAppendBase.cpp +++ b/Database/APR/CollectionUtilities/src/CollAppendBase.cpp @@ -16,6 +16,7 @@ #include "CoralBase/Attribute.h" #include "POOLCore/Exception.h" +#include "POOLCore/SystemTools.h" #include "CollectionBase/boost_tokenizer_headers.h" #include <ctime> @@ -49,6 +50,7 @@ CollAppendBase::CollAppendBase(std::string name) : m_argsVec( name, true, &m_log ), m_initialized( false ) { + SystemTools::initGaudi(); m_metainfo = new MetaInfo(); // attempt to shut up Coverity, MN diff --git a/Database/APR/CollectionUtilities/utilities/CollAppend.cpp b/Database/APR/CollectionUtilities/utilities/CollAppend.cpp index 61ea152c447ef08e9b46dbea970065ddfd2a83f9..3fd7891d83041074932d88e58757405cb7990802 100644 --- a/Database/APR/CollectionUtilities/utilities/CollAppend.cpp +++ b/Database/APR/CollectionUtilities/utilities/CollAppend.cpp @@ -6,7 +6,6 @@ * @file CollAppend.cpp * @brief Utility to copy and merge POOL collections - uses CollAppendBase class * @author Marcin.Nowak@cern.ch - * $Id: CollAppend.cpp 726582 2016-02-27 11:23:37Z krasznaa $ */ #include "CollectionUtilities/CollAppendBase.h" diff --git a/Database/APR/CollectionUtilities/utilities/CollListAttrib.cpp b/Database/APR/CollectionUtilities/utilities/CollListAttrib.cpp index 3314b38b500826da8ba9d667be7980680caeb5b4..1bd676caf2885392ccc128e5b29af4b8aa500c76 100644 --- a/Database/APR/CollectionUtilities/utilities/CollListAttrib.cpp +++ b/Database/APR/CollectionUtilities/utilities/CollListAttrib.cpp @@ -7,7 +7,6 @@ * @brief Utility to list the metadata of a POOL collection * @author K. Karr <Kristo.Karr@cern.ch> * @author Marcin.Nowak@cern.ch - * $Id: CollListAttrib.cpp 726582 2016-02-27 11:23:37Z krasznaa $ */ #include "PersistentDataModel/Token.h" @@ -20,6 +19,7 @@ #include "CollectionBase/CollectionService.h" #include "POOLCore/Exception.h" +#include "POOLCore/SystemTools.h" #include "CoralBase/AttributeList.h" #include "CoralBase/Attribute.h" @@ -43,7 +43,8 @@ using namespace pool; int main(int argc, const char *argv[]) { string thisProgram("CollListAttrib"); - + SystemTools::initGaudi(); + try { pool::CollectionService collectionService; coral::MessageStream log( thisProgram ); diff --git a/Database/APR/CollectionUtilities/utilities/CollListFileGUID.cpp b/Database/APR/CollectionUtilities/utilities/CollListFileGUID.cpp index 026b4cd3a68c9e1622a4ee65043c78807822f3b9..aa24058b1017998570cb35ce9b9269a44f8fcfd2 100644 --- a/Database/APR/CollectionUtilities/utilities/CollListFileGUID.cpp +++ b/Database/APR/CollectionUtilities/utilities/CollListFileGUID.cpp @@ -27,6 +27,7 @@ #include "CoralBase/MessageStream.h" #include "POOLCore/Exception.h" +#include "POOLCore/SystemTools.h" #include "CollectionUtilities/Args2Container.h" #include "CollectionUtilities/SrcInfo.h" @@ -36,12 +37,11 @@ #include <iostream> #include <iomanip> #include <memory> + using namespace std; using namespace pool; - - void printGroupedGuids( const ICollectionGUIDQuery::CountedGroupedGUIDs& guids ) { cout << "Event count per distinct GUIDs group:" << endl; @@ -96,7 +96,8 @@ void printCountedGuids( const ICollectionGUIDQuery::CountedGroupedGUIDs& guids ) int main(int argc, const char *argv[]) { string thisProgram("CollListFileGUID"); - + SystemTools::initGaudi(); + try { coral::MessageStream log( thisProgram ); diff --git a/Database/APR/CollectionUtilities/utilities/CollListMetadata.cpp b/Database/APR/CollectionUtilities/utilities/CollListMetadata.cpp index 816711283db244ab9f8dfd3572854d1dc143f266..107a8e4a4085396d9c383173495a8810841dd247 100644 --- a/Database/APR/CollectionUtilities/utilities/CollListMetadata.cpp +++ b/Database/APR/CollectionUtilities/utilities/CollListMetadata.cpp @@ -14,6 +14,7 @@ #include "CoralBase/MessageStream.h" #include "POOLCore/Exception.h" +#include "POOLCore/SystemTools.h" #include "CollectionUtilities/Args2Container.h" #include "CollectionUtilities/SrcInfo.h" @@ -43,7 +44,6 @@ XERCES_CPP_NAMESPACE_USE -#include <iostream> using namespace std; using namespace pool; @@ -51,7 +51,8 @@ int main(int argc, const char *argv[]) { string thisProgram("CollListMetadata"); string file("CollMetadata.xml"); - + SystemTools::initGaudi(); + try { coral::MessageStream log( thisProgram ); diff --git a/Database/APR/CollectionUtilities/utilities/CollListPFN.cpp b/Database/APR/CollectionUtilities/utilities/CollListPFN.cpp index 1ea6767673ff8c262328e9ac629f9d9598dc982f..42c5150d07a7c6cb7a315f88ce31d1d38aef621f 100644 --- a/Database/APR/CollectionUtilities/utilities/CollListPFN.cpp +++ b/Database/APR/CollectionUtilities/utilities/CollListPFN.cpp @@ -21,6 +21,7 @@ #include "FileCatalog/IFileCatalog.h" #include "POOLCore/Exception.h" +#include "POOLCore/SystemTools.h" #include "CoralBase/MessageStream.h" @@ -36,6 +37,8 @@ using namespace pool; int main(int argc, const char *argv[]) { string thisProgram("CollListPFN"); + SystemTools::initGaudi(); + try { pool::CollectionService collectionService; diff --git a/Database/APR/CollectionUtilities/utilities/CollListToken.cpp b/Database/APR/CollectionUtilities/utilities/CollListToken.cpp index b3266b2511a67fcbc80840ed7bac1a8717054d30..e91a4f5a9bd756f3dc5706266ee2ada43c84b25d 100644 --- a/Database/APR/CollectionUtilities/utilities/CollListToken.cpp +++ b/Database/APR/CollectionUtilities/utilities/CollListToken.cpp @@ -7,7 +7,6 @@ * @brief Utility to list the event references of a POOL collection * @author K. Karr <Kristo.Karr@cern.ch> * @author Marcin.Nowak@cern.ch - * $Id: CollListToken.cpp 726582 2016-02-27 11:23:37Z krasznaa $ */ #include "PersistentDataModel/Token.h" @@ -23,6 +22,7 @@ #include "CoralBase/MessageStream.h" #include "POOLCore/Exception.h" +#include "POOLCore/SystemTools.h" #include "CollectionUtilities/Args2Container.h" #include "CollectionUtilities/SrcInfo.h" @@ -32,6 +32,7 @@ #include <sstream> #include <iostream> + using namespace std; using namespace pool; #define corENDL coral::MessageStream::endmsg @@ -39,6 +40,8 @@ using namespace pool; int main(int argc, const char *argv[]) { string thisProgram("CollListToken"); + SystemTools::initGaudi(); + try { coral::MessageStream log( thisProgram ); diff --git a/Database/APR/CollectionUtilities/utilities/CollQuery.cpp b/Database/APR/CollectionUtilities/utilities/CollQuery.cpp index 4284cf50200e2532670b9fdfc8fd8dffc30f4cb6..2d628e65e3425e36105505688f87b05862800595 100644 --- a/Database/APR/CollectionUtilities/utilities/CollQuery.cpp +++ b/Database/APR/CollectionUtilities/utilities/CollQuery.cpp @@ -7,7 +7,6 @@ * @brief Utility to list the metadata of a POOL collection * @author K. Karr <Kristo.Karr@cern.ch> * @author Marcin.Nowak@cern.ch - * $Id: CollQuery.cpp 556226 2013-07-30 15:42:48Z mnowak $ */ #include "PersistentDataModel/Token.h" @@ -22,6 +21,7 @@ #include "CollectionBase/CollectionService.h" #include "POOLCore/Exception.h" +#include "POOLCore/SystemTools.h" #include "CoralBase/AttributeList.h" #include "CoralBase/Attribute.h" @@ -164,6 +164,8 @@ using namespace std; int main(int argc, const char *argv[]) { string thisProgram("CollQuery"); + SystemTools::initGaudi(); + try { pool::CollectionService collectionService; coral::MessageStream log( thisProgram ); diff --git a/Database/APR/CollectionUtilities/utilities/coll_insertGuidToCatalog.cpp b/Database/APR/CollectionUtilities/utilities/coll_insertGuidToCatalog.cpp index 7b3a014e0e9feadb63d2b15aa3434e28d9474847..e091836cb330cf5b6efc30dbee580db0a5cc367f 100644 --- a/Database/APR/CollectionUtilities/utilities/coll_insertGuidToCatalog.cpp +++ b/Database/APR/CollectionUtilities/utilities/coll_insertGuidToCatalog.cpp @@ -9,6 +9,7 @@ #include "PersistentDataModel/Guid.h" #include "FileCatalog/IFileCatalog.h" #include "FileCatalog/URIParser.h" +#include "POOLCore/SystemTools.h" class InsertFileToCatalogApplication { public: @@ -122,6 +123,7 @@ InsertFileToCatalogApplication::printSyntax() int main( int argc, char* argv[] ) { + pool::SystemTools::initGaudi(); try { InsertFileToCatalogApplication app( argc, argv ); if ( app.parseArguments() ) { diff --git a/Database/APR/FileCatalog/CMakeLists.txt b/Database/APR/FileCatalog/CMakeLists.txt index 99a8fbaeb183cc04cfd9cc321090c8aad22723af..2bd4add0bd233c3847ea6d4e663695974107e4a3 100644 --- a/Database/APR/FileCatalog/CMakeLists.txt +++ b/Database/APR/FileCatalog/CMakeLists.txt @@ -44,11 +44,10 @@ atlas_add_executable( FCdeleteEntry # INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} # LINK_LIBRARIES ${CORAL_LIBRARIES} POOLCore TestTools GaudiKernel FileCatalog ) -# not supported witgh GFC -#atlas_add_executable( FCdeletePFN -# utilities/FCdeletePFN.cpp -# INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} -# LINK_LIBRARIES ${CORAL_LIBRARIES} POOLCore TestTools GaudiKernel FileCatalog ) +atlas_add_executable( FCdeletePFN + utilities/FCdeletePFN.cpp + INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} + LINK_LIBRARIES ${CORAL_LIBRARIES} POOLCore TestTools GaudiKernel FileCatalog ) atlas_add_executable( FClistGUID utilities/FClistGUID.cpp @@ -75,8 +74,8 @@ atlas_add_executable( FCregisterPFN INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} LINK_LIBRARIES ${CORAL_LIBRARIES} POOLCore TestTools GaudiKernel FileCatalog ) -# not supported witgh GFC -#atlas_add_executable( FCrenamePFN -# utilities/FCrenamePFN.cpp -# INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} -# LINK_LIBRARIES ${CORAL_LIBRARIES} POOLCore TestTools GaudiKernel FileCatalog ) +atlas_add_executable( FCrenamePFN + utilities/FCrenamePFN.cpp + INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} + LINK_LIBRARIES ${CORAL_LIBRARIES} POOLCore TestTools GaudiKernel FileCatalog ) + diff --git a/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h b/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h index 64c5da4eb1a7030946a383b035785d2cc4666f90..8c1f1e2eb848dc8cc25832ff7e1064ee73abbe69 100644 --- a/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h +++ b/Database/APR/FileCatalog/FileCatalog/IFileCatalog.h @@ -86,9 +86,15 @@ namespace pool { /// Delete FileID Node from the catalog void deleteFID( const std::string& FileID ) { return _fc->deleteFID(FileID); } + /// Delete PFN from the catalog (delete entire FID entry if it was the last PFN) + void deletePFN( const std::string& pfn ); + /// Register PFN, assign new FID if not given void registerPFN( const std::string& pfn, const std::string& ftype, std::string& fid ); + /// Rename PFN + void renamePFN( const std::string& pfn, const std::string& newpfn ); + /// adding replica to an existing PFN void addReplicaPFN( const std::string& pfn, const std::string& replica_pfn ); diff --git a/Database/APR/FileCatalog/src/IFileCatalog.cpp b/Database/APR/FileCatalog/src/IFileCatalog.cpp index 1fdf576244ef93f014fd4f1eb28ccf737b9b1c64..0d2e9ada096bd4248f94dd9d04dc3a490666d12a 100644 --- a/Database/APR/FileCatalog/src/IFileCatalog.cpp +++ b/Database/APR/FileCatalog/src/IFileCatalog.cpp @@ -16,6 +16,9 @@ #include "AthenaBaseComps/AthMessaging.h" +#include "GaudiKernel/IMessageSvc.h" +#include "GaudiKernel/Service.h" + #include <iostream> using namespace pool; @@ -25,7 +28,11 @@ pool::IFileCatalog::IFileCatalog() { _mgr = Gaudi::svcLocator()->service<Gaudi::IFileCatalogMgr>( "Gaudi::MultiFileCatalog" ); _fc = _mgr; + // set the output level of this service setLevel( SystemTools::GetOutputLvl() ); + // set the output level of the XMLCatalog component - works only if the Gaudi AppMgr was initialized + Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc") + ->setOutputLevel("XMLCatalog", SystemTools::GetOutputLvl() ); } @@ -61,6 +68,52 @@ lookupFileByPFN( const std::string& pfn, std::string& fid, std::string& tech ) c } +/// Delete PFN from the catalog (delete entire FID entry if it was the last PFN) +void pool::IFileCatalog:: +deletePFN( const std::string& pfn ) +{ + std::string fid = _fc->lookupPFN(pfn); + if( !fid.empty() ) { + Files pfns, lfns; + getPFNs( fid, pfns ); + getLFNs( fid, lfns ); + deleteFID( fid ); + for( const auto& p: pfns ) { + if( p.first != pfn ) registerPFN( p.first, p.second, fid ); + } + for( const auto& l: lfns ) { + registerLFN( fid, l.first ); + } + } +} + + +/// Rename PFN +void pool::IFileCatalog:: +renamePFN( const std::string& pfn, const std::string& newpfn ) +{ + std::string fid = _fc->lookupPFN(pfn); + if( !fid.empty() ) { + Files pfns, lfns; + getPFNs( fid, pfns ); + getLFNs( fid, lfns ); + deleteFID( fid ); + for( const auto& p: pfns ) { + if( p.first == pfn ) { + registerPFN( newpfn, p.second, fid ); + } else { + registerPFN( p.first, p.second, fid ); + } + } + for( const auto& l: lfns ) { + registerLFN( fid, l.first ); + } + } else { + ATH_MSG_DEBUG("RenamePFN: PFN=" << pfn << " not found!"); + } +} + + /// Register PFN, assign new FID if not given void pool::IFileCatalog:: registerPFN( const std::string& pfn, const std::string& ftype, std::string& fid ) @@ -69,8 +122,8 @@ registerPFN( const std::string& pfn, const std::string& ftype, std::string& fid throw pool::Exception(std::string("PFN '") + pfn + "' already registered", "registerPFN", "FileCatalog"); } // std::cout << "msg() level" << msg().level() << std::endl; - ATH_MSG_DEBUG("Registering PFN=" << pfn << " of type=" << ftype << " GUID=" << fid); if( fid.empty() ) fid = createFID(); + ATH_MSG_DEBUG("Registering PFN=" << pfn << " of type=" << ftype << " GUID=" << fid); _fc->registerPFN(fid, pfn, ftype); } diff --git a/Database/APR/FileCatalog/utilities/FCaddReplica.cpp b/Database/APR/FileCatalog/utilities/FCaddReplica.cpp index 6a852b80e2c43f42fa2b91a464c395a553e8554c..483367a9741d2f5051f287c1c23162c30119a444 100755 --- a/Database/APR/FileCatalog/utilities/FCaddReplica.cpp +++ b/Database/APR/FileCatalog/utilities/FCaddReplica.cpp @@ -2,19 +2,15 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -//$Id: FCaddReplica.cpp 509054 2012-07-05 13:33:16Z mnowak $ /**FCaddReplica.cpp -- FileCatalog command line tool to add replica pfn @author Zhen Xie @author Maria Girone - @date: 02/03/2005 Z.X. - set default logging to Warning if no POOL_OUTMSG_LEVEL is set; - separate logging stream to std::cerr, output stream to std::cout. - @date: 07/04/2005 Z.X. - adopt to split catalog interface */ + #include "FileCatalog/CommandLine.h" #include "FileCatalog/IFileCatalog.h" #include "POOLCore/Exception.h" +#include "POOLCore/SystemTools.h" #include <memory> using namespace pool; @@ -26,7 +22,9 @@ void printUsage(){ static const char* opts[] = {"r","p","g","u","h",0}; -int main(int argc, char** argv) { +int main(int argc, char** argv) +{ + SystemTools::initGaudi(); std::string myuri; std::string mypfn; diff --git a/Database/APR/FileCatalog/utilities/FCdeleteEntry.cpp b/Database/APR/FileCatalog/utilities/FCdeleteEntry.cpp index d731773ddb075f70e36785bd0c5ad8c0b7e0d53c..930ae299dec8a2298b91256bf4a2a503998adf0a 100755 --- a/Database/APR/FileCatalog/utilities/FCdeleteEntry.cpp +++ b/Database/APR/FileCatalog/utilities/FCdeleteEntry.cpp @@ -24,11 +24,12 @@ static const char* opts[] = {"q","l","p","u","h",0}; int main(int argc, char** argv) { + SystemTools::initGaudi(); + std::string myuri; std::string mylfn; std::string mypfn; std::string myquery; - // IFileCatalog::FileID myguid; try{ CommandLine commands(argc,argv); commands.CheckOptions(opts); diff --git a/Database/APR/FileCatalog/utilities/FCdeleteLFN.cpp b/Database/APR/FileCatalog/utilities/FCdeleteLFN.cpp index b03d750c312ca2049b3b155f3fb94653cb5788c5..886067384b21e93d8917f7af0de41a3a550607be 100755 --- a/Database/APR/FileCatalog/utilities/FCdeleteLFN.cpp +++ b/Database/APR/FileCatalog/utilities/FCdeleteLFN.cpp @@ -22,7 +22,10 @@ void printUsage(){ static const char* opts[] = {"q","l","u","h",0}; -int main(int argc, char** argv) { +int main(int argc, char** argv) +{ + SystemTools::initGaudi(); + std::string myuri; std::string mylfn; std::string myquery; diff --git a/Database/APR/FileCatalog/utilities/FCdeletePFN.cpp b/Database/APR/FileCatalog/utilities/FCdeletePFN.cpp index 36324cb2f94ad770890f8f66816170067a9d87c6..e036bf4fda9dfc4a5b6b1f1b8bf8a746b52dd7f4 100755 --- a/Database/APR/FileCatalog/utilities/FCdeletePFN.cpp +++ b/Database/APR/FileCatalog/utilities/FCdeletePFN.cpp @@ -24,6 +24,8 @@ static const char* opts[] = {"p","q","u","h",0}; int main(int argc, char** argv) { + SystemTools::initGaudi(); + std::string myuri; std::string mypfn; std::string myquery; diff --git a/Database/APR/FileCatalog/utilities/FClistGUID.cpp b/Database/APR/FileCatalog/utilities/FClistGUID.cpp index c5ba6f556f82135c4c1b1acfb301a6323a66e89e..09f792b4a35188a54c6d0dca2ab963162e5896c3 100644 --- a/Database/APR/FileCatalog/utilities/FClistGUID.cpp +++ b/Database/APR/FileCatalog/utilities/FClistGUID.cpp @@ -17,8 +17,6 @@ #include <string> using namespace pool; -using namespace std; - void printUsage(){ std::cout<<"usage: FClistGUID [-p pfname -l lfname -q query -u contactstring -h]" <<std::endl; @@ -56,6 +54,8 @@ private: int main(int argc, char** argv) { + SystemTools::initGaudi(); + std::string myuri; std::string mypfn; std::string mylfn; diff --git a/Database/APR/FileCatalog/utilities/FClistLFN.cpp b/Database/APR/FileCatalog/utilities/FClistLFN.cpp index 6e40a05ec12811565b233efbb32c6944b91d5cb1..e81ec89ff94261e9e7c5499b37f14c95a2185cf7 100755 --- a/Database/APR/FileCatalog/utilities/FClistLFN.cpp +++ b/Database/APR/FileCatalog/utilities/FClistLFN.cpp @@ -2,13 +2,9 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -//$Id: FClistLFN.cpp 509054 2012-07-05 13:33:16Z mnowak $ /**FClistLFN.cpp -- FileCatalog command line tool to list all the LFN entries from the catalog. @author Zhen Xie @author Maria Girone - @date: 02/03/2005 Z.X. - set default logging to Warning if no POOL_OUTMSG_LEVEL is set; - separate logging stream to std::cerr, output stream to std::cout. */ #include "FileCatalog/CommandLine.h" @@ -56,6 +52,8 @@ private: int main(int argc, char** argv) { + SystemTools::initGaudi(); + std::string myuri; std::string mypfn; try{ diff --git a/Database/APR/FileCatalog/utilities/FClistPFN.cpp b/Database/APR/FileCatalog/utilities/FClistPFN.cpp index 83dce3ff98d02950ed9b702207d0bdee3aad7e8e..7d48e99b594a68098cea7c565b8bf24c2bcae7f6 100755 --- a/Database/APR/FileCatalog/utilities/FClistPFN.cpp +++ b/Database/APR/FileCatalog/utilities/FClistPFN.cpp @@ -2,14 +2,11 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -//$Id: FClistPFN.cpp 778462 2016-10-14 12:29:52Z mnowak $ /**FClistPFN.cpp -- FileCatalog command line tool to list the PFN entries from the catalog @author: Zhen Xie @author: Maria Girone - @date: 02/03/2005 Z.X. - set default logging to Warning if no POOL_OUTMSG_LEVEL is set; - separate logging stream to std::cerr, output stream to std::cout. */ + #include "FileCatalog/CommandLine.h" #include "FileCatalog/IFileCatalog.h" #include "FileCatalog/URIParser.h" @@ -56,6 +53,8 @@ private: int main(int argc, char** argv) { + SystemTools::initGaudi(); + std::string myuri; std::string mylfn; std::string query(""); diff --git a/Database/APR/FileCatalog/utilities/FCregisterLFN.cpp b/Database/APR/FileCatalog/utilities/FCregisterLFN.cpp index 5215b307896fbdcc2f5751790e2f62d4131f5686..5a76ae75fb8eecf0bd6dbf9a1d263d1110da393e 100755 --- a/Database/APR/FileCatalog/utilities/FCregisterLFN.cpp +++ b/Database/APR/FileCatalog/utilities/FCregisterLFN.cpp @@ -2,14 +2,11 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -//$Id: FCregisterLFN.cpp 509054 2012-07-05 13:33:16Z mnowak $ /**FCregisterLFN.cpp -- FileCatalog command line tool to register a LFN @author: Zhen Xie @author: Maria Girone - @date: 02/03/2005 Z.X. - set default logging to Warning if no POOL_OUTMSG_LEVEL is set; - separate logging stream to std::cerr, output stream to std::cout */ + #include "FileCatalog/CommandLine.h" #include "FileCatalog/IFileCatalog.h" #include "FileCatalog/URIParser.h" @@ -28,6 +25,8 @@ static const char* opts[] = {"p","l","u","h",0}; int main(int argc, char** argv) { + SystemTools::initGaudi(); + std::string myuri; std::string mypfn; std::string mylfn; diff --git a/Database/APR/FileCatalog/utilities/FCregisterPFN.cpp b/Database/APR/FileCatalog/utilities/FCregisterPFN.cpp index f480c8c1ef3b0a775669790e5a71ae2071ed9a00..af6f4547aaa8f95c8c31d8b9d3c62a0a3d0e078c 100755 --- a/Database/APR/FileCatalog/utilities/FCregisterPFN.cpp +++ b/Database/APR/FileCatalog/utilities/FCregisterPFN.cpp @@ -2,17 +2,11 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -//$Id: FCregisterPFN.cpp 509054 2012-07-05 13:33:16Z mnowak $ -/**FCregisterPFN.cpp -- FileCatalog command line tool registerPFN +/** + FCregisterPFN.cpp -- FileCatalog command line tool registerPFN Register a PFN in the File Catalog: a unique FileID is generated and inserted in the catalog, - @author: Zhen Xie - @author: Maria Girone - @date: 02/03/2005 Z.X. - set default logging to Warning if no POOL_OUTMSG_LEVEL is set; - separate logging stream to std::cerr, output stream to std::cout. - @date: 07/04/2005 Z.X. - adopt to split interface - */ +*/ + #include "FileCatalog/CommandLine.h" #include "FileCatalog/IFileCatalog.h" #include "FileCatalog/URIParser.h" @@ -21,14 +15,18 @@ #include <memory> using namespace pool; + void printUsage(){ std::cout<< "usage: registerPFN -p pfname [ -u contactstring -t filetype -g guid -h ]" <<std::endl; } + static const char* opts[] = {"p","t","g","u","h",0}; int main(int argc, char** argv) { + SystemTools::initGaudi(); + std::string myuri; std::string mypfn; std::string myfiletype; diff --git a/Database/APR/FileCatalog/utilities/FCrenamePFN.cpp b/Database/APR/FileCatalog/utilities/FCrenamePFN.cpp index 87c8ca26616e4cbc53b42ceab2634a7398711221..cef1fbdb080bd26f7b872a8fb697a55b8a89ca6e 100755 --- a/Database/APR/FileCatalog/utilities/FCrenamePFN.cpp +++ b/Database/APR/FileCatalog/utilities/FCrenamePFN.cpp @@ -2,17 +2,14 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -//$Id: FCrenamePFN.cpp 509054 2012-07-05 13:33:16Z mnowak $ /**FCrenamePFN.cpp -- FileCatalog command line tool to rename PFN. Used in the case the file has been moved. @author: Zhen Xie - @date: 02/03/2005 Z.X. - set default logging to Warning if no POOL_OUTMSG_LEVEL is set; - separate logging stream to std::cerr, output stream to std::cout */ #include "FileCatalog/CommandLine.h" #include "FileCatalog/IFileCatalog.h" #include "FileCatalog/URIParser.h" #include "POOLCore/Exception.h" +#include "POOLCore/SystemTools.h" #include <memory> using namespace pool; @@ -26,6 +23,8 @@ static const char* opts[] = {"p","n","u","h",0}; int main(int argc, char** argv) { + SystemTools::initGaudi(); + std::string myuri; std::string mypfn; std::string mynewpfn; @@ -63,9 +62,7 @@ int main(int argc, char** argv) mycatalog->setWriteCatalog( p.contactstring() ); mycatalog->connect(); mycatalog->start(); - - //MN: There is no renamePFN method in Gaudi::IFileCatalog - implement if needed - mycatalog->renamePFN(mypfn,mynewpfn); + mycatalog->renamePFN(mypfn, mynewpfn); mycatalog->commit(); mycatalog->disconnect(); }catch (const pool::Exception& er){ diff --git a/Database/APR/POOLCore/POOLCore/SystemTools.h b/Database/APR/POOLCore/POOLCore/SystemTools.h index e58e5916b79fc18c1185f7ff36234da2bb6d476b..e944ac9ade46e882b500e1a0c3a98feb0b8082b4 100755 --- a/Database/APR/POOLCore/POOLCore/SystemTools.h +++ b/Database/APR/POOLCore/POOLCore/SystemTools.h @@ -35,6 +35,9 @@ namespace pool{ // read the PFC_MSGLEVEL env setting static MSG::Level GetOutputLvlFromEnv(); + + // initialize the Gaudi framework for standalone executables + static bool initGaudi(); }; } // ns pool #endif diff --git a/Database/APR/POOLCore/src/SystemTools.cpp b/Database/APR/POOLCore/src/SystemTools.cpp index 576ec6a32ebdaed356b640468cdbbceeb97044a6..3c4e665d24e62d8a054efaca6793ad59b3cd7bf9 100755 --- a/Database/APR/POOLCore/src/SystemTools.cpp +++ b/Database/APR/POOLCore/src/SystemTools.cpp @@ -3,12 +3,23 @@ */ #include "POOLCore/SystemTools.h" + +#include "GaudiKernel/IAppMgrUI.h" +#include "GaudiKernel/Bootstrap.h" +#include "GaudiKernel/ISvcManager.h" +#include "GaudiKernel/ISvcLocator.h" +#include "GaudiKernel/IProperty.h" + +#include "POOLCore/DbPrint.h" + #include <sys/stat.h> #include <cstdlib> #include <sstream> #include <libgen.h> #include <string.h> +using namespace pool; + namespace pool { const char* SystemTools::GetEnv(const char* key){ @@ -111,6 +122,32 @@ namespace pool return MSG::NIL; } + + bool SystemTools::initGaudi() { + // Create an instance of an application manager + IInterface* iface = Gaudi::createApplicationMgr(); + if( !iface ) { + DbPrint log("APR.initGaudi"); + log << DbPrintLvl::Warning << "Gaudi framework failed to initialize" << endmsg; + return false; + } + SmartIF<ISvcManager> svcMgr(iface); + SmartIF<IAppMgrUI> appMgr(iface); + SmartIF<IProperty> propMgr(iface); + SmartIF<ISvcLocator> svcLoc(iface); + + propMgr->setProperty( "JobOptionsType", "NONE" ) .ignore(); + // prevents some output from the AppMgr + propMgr->setProperty( "OutputLeveL", "5" ) .ignore(); + // this prevents AppMgr "welcome" output + propMgr->setProperty( "AppName", "" ) .ignore(); + + if( !appMgr->configure().isSuccess() || !appMgr->initialize().isSuccess() ) { + std::cerr << "Gaudi ApplicationMgr failed to initialize" << std::endl; + return false; + } + return true; + } } // ns pool diff --git a/Database/APR/PersistencySvc/utilities/pool_insertFileToCatalog.cpp b/Database/APR/PersistencySvc/utilities/pool_insertFileToCatalog.cpp index edecd246063c72274e7865438dd8a06b277ad9f5..2040c53329863111f0e2057703f74e5aa2ac90cd 100644 --- a/Database/APR/PersistencySvc/utilities/pool_insertFileToCatalog.cpp +++ b/Database/APR/PersistencySvc/utilities/pool_insertFileToCatalog.cpp @@ -7,6 +7,7 @@ #include "PersistencySvc/SimpleUtilityBase.h" #include "FileCatalog/URIParser.h" #include "FileCatalog/IFileCatalog.h" +#include "POOLCore/SystemTools.h" using namespace pool; @@ -94,6 +95,7 @@ InsertFileToCatalogApplication::printSyntax() int main( int argc, char* argv[] ) { + SystemTools::initGaudi(); InsertFileToCatalogApplication app( argc, argv ); return app.run(); } diff --git a/Database/APR/StorageSvc/test/StorageSvc.xml b/Database/APR/StorageSvc/test/StorageSvc.xml deleted file mode 100644 index 9040dc8a609023903c3ba4ee0546b772c4931d80..0000000000000000000000000000000000000000 --- a/Database/APR/StorageSvc/test/StorageSvc.xml +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<atn> - <TEST name="StorageSvcTest" type="makecheck" suite="Examples"> - <package>Database/APR/StorageSvc</package> - <timelimit>10</timelimit> - <author> scott snyder </author> - <mailto> snyder@bnl.gov </mailto> - <expectations> - <errorMessage>Athena exited abnormally</errorMessage> - <errorMessage>differ</errorMessage> - <warningMessage> # WARNING_MESSAGE : post.sh> ERROR</warningMessage> - <successMessage>check ok</successMessage> - <returnValue>0</returnValue> - </expectations> - </TEST> -</atn> diff --git a/Database/APR/StorageSvc/test/StorageSvc_mtShape_test.cxx b/Database/APR/StorageSvc/test/StorageSvc_mtShape_test.cxx index 781a4b794ed99ee8c7f0ce929bbe588df9f19268..8118565610ce2f87c343f086f43b974fdd962917 100644 --- a/Database/APR/StorageSvc/test/StorageSvc_mtShape_test.cxx +++ b/Database/APR/StorageSvc/test/StorageSvc_mtShape_test.cxx @@ -2,8 +2,6 @@ Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration */ -//#include "StorageSvc/DbTransform.h" -//#include "StorageSvc/DbReflex.h" #include "StorageSvc/DbTypeInfo.h" #include "StorageSvc/DbTransform.h" diff --git a/Database/APR/Tests/FileCatalog_Functionality/FCtest.cpp b/Database/APR/Tests/FileCatalog_Functionality/FCtest.cpp index c2a63c9422a3ba6b04ac81e3f5edcd5a574b2179..11324ef60f51dcc7ace1b760d0897e3482df67b6 100644 --- a/Database/APR/Tests/FileCatalog_Functionality/FCtest.cpp +++ b/Database/APR/Tests/FileCatalog_Functionality/FCtest.cpp @@ -12,6 +12,7 @@ #include <iostream> #include <cstdlib> #include "POOLCore/Exception.h" +#include "POOLCore/SystemTools.h" #include "FileCatalog/IFileCatalog.h" using namespace pool; @@ -44,6 +45,7 @@ public: mysql }; void setUp(){ + SystemTools::initGaudi(); mycatalog=new IFileCatalog; source=new IFileCatalog; dest=new IFileCatalog; diff --git a/Database/AthenaPOOL/PoolSvc/CMakeLists.txt b/Database/AthenaPOOL/PoolSvc/CMakeLists.txt index 835b47361203e8bc7ef17d9a6f9860ae4f3e1d63..d756c5a877cce00c721664aafd76554bd05333ed 100644 --- a/Database/AthenaPOOL/PoolSvc/CMakeLists.txt +++ b/Database/AthenaPOOL/PoolSvc/CMakeLists.txt @@ -17,6 +17,7 @@ atlas_depends_on_subdirs( Control/AthenaBaseComps Control/AthenaKernel Database/APR/StorageSvc + Database/APR/FileCatalog Database/ConnectionManagement/DBReplicaSvc Database/PersistentDataModel Tools/PathResolver ) @@ -28,7 +29,8 @@ find_package( CORAL COMPONENTS CoralBase CoralKernel RelationalAccess ) atlas_add_component( PoolSvc PoolSvc/*.h src/*.cxx src/components/*.cxx INCLUDE_DIRS ${CORAL_INCLUDE_DIRS} - LINK_LIBRARIES ${CORAL_LIBRARIES} DataModelRoot CollectionBase PersistencySvc GaudiKernel + LINK_LIBRARIES ${CORAL_LIBRARIES} DataModelRoot CollectionBase + PersistencySvc GaudiKernel FileCatalog AthenaBaseComps AthenaKernel StorageSvc PersistentDataModel PathResolver ) # Install files from the package: diff --git a/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx b/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx index 919b324049c0e696e23b78a09db793df023d9c8e..44205a6a42dc56dbb309f089a2bd24e7c9ace488 100644 --- a/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx +++ b/Database/AthenaPOOL/PoolSvc/src/PoolSvc.cxx @@ -22,7 +22,6 @@ #include "CollectionBase/CollectionDescription.h" #include "FileCatalog/IFileCatalog.h" -#include "FileCatalog/IFCAction.h" #include "PersistencySvc/IPersistencySvc.h" #include "PersistencySvc/ISession.h" @@ -351,12 +350,10 @@ const pool::IFileCatalog* PoolSvc::catalog() const { //__________________________________________________________________________ void PoolSvc::lookupBestPfn(const std::string& token, std::string& pfn, std::string& type) const { std::string dbID; - pool::FCregister action; - m_catalog->setAction(action); if (token.substr(0, 4) == "PFN:") { - action.lookupFileByPFN(token.substr(4), dbID, type); // PFN -> FID + m_catalog->lookupFileByPFN(token.substr(4), dbID, type); // PFN -> FID } else if (token.substr(0, 4) == "LFN:") { - action.lookupFileByLFN(token.substr(4), dbID); // LFN -> FID + m_catalog->lookupFileByLFN(token.substr(4), dbID); // LFN -> FID } else if (token.substr(0, 4) == "FID:") { dbID = token.substr(4); } else if (token.size() > Guid::null().toString().size()) { // full token @@ -366,24 +363,22 @@ void PoolSvc::lookupBestPfn(const std::string& token, std::string& pfn, std::str } else { // guid only dbID = token; } - action.lookupBestPFN(dbID, pool::FileCatalog::READ, pool::FileCatalog::SEQUENTIAL, pfn, type); // FID -> best PFN + m_catalog->getFirstPFN(dbID, pfn, type); // FID -> best PFN } //__________________________________________________________________________ void PoolSvc::renamePfn(const std::string& pf, const std::string& newpf) const { std::string dbID, type; - pool::FCregister action; - m_catalog->setAction(action); - action.lookupFileByPFN(pf, dbID, type); + m_catalog->lookupFileByPFN(pf, dbID, type); if (dbID.empty()) { ATH_MSG_WARNING("Failed to lookup: " << pf << " in FileCatalog"); return; } - action.lookupFileByPFN(newpf, dbID, type); + m_catalog->lookupFileByPFN(newpf, dbID, type); if (!dbID.empty()) { ATH_MSG_INFO("Found: " << newpf << " in FileCatalog"); return; } - action.renamePFN(pf, newpf); + m_catalog->renamePFN(pf, newpf); } //__________________________________________________________________________ pool::ICollection* PoolSvc::createCollection(const std::string& collectionType, @@ -416,10 +411,8 @@ pool::ICollection* PoolSvc::createCollection(const std::string& collectionType, // Check POOL FileCatalog entry. bool insertFile = false; if (connection.substr(0, 4) == "PFN:") { - pool::IFCAction action; - m_catalog->setAction(action); std::string fid, fileType; - action.lookupFileByPFN(connection.substr(4), fid, fileType); + m_catalog->lookupFileByPFN(connection.substr(4), fid, fileType); if (fid.empty()) { // No entry in file catalog insertFile = true; ATH_MSG_INFO("File is not in Catalog! Attempt to open it anyway."); @@ -450,10 +443,8 @@ pool::ICollection* PoolSvc::createCollection(const std::string& collectionType, ATH_MSG_INFO("Failed to find container " << collection << " to create POOL collection."); if (insertFile && m_attemptCatalogPatch.value()) { dbH->setTechnology(pool::ROOT_StorageType.type()); - pool::FCregister action; - m_catalog->setAction(action); std::string fid = dbH->fid(); - action.registerPFN(connection.substr(4), "ROOT_All", fid); + m_catalog->registerPFN(connection.substr(4), "ROOT_All", fid); } return(nullptr); // no events } @@ -491,10 +482,8 @@ pool::ICollection* PoolSvc::createCollection(const std::string& collectionType, << connection << "' - FileCatalog will NOT be updated."); } else { dbH->setTechnology(pool::ROOT_StorageType.type()); - pool::FCregister action; - m_catalog->setAction(action); std::string fid = dbH->fid(); - action.registerPFN(connection.substr(4), "ROOT_All", fid); + m_catalog->registerPFN(connection.substr(4), "ROOT_All", fid); } } return(collPtr); diff --git a/Database/AthenaRoot/AthenaRootComps/src/RootSvc.cxx b/Database/AthenaRoot/AthenaRootComps/src/RootSvc.cxx index bd8c3f239bce9dee60aef92e203bfa0ead11c13e..47d38be346ff7978ac36745dc60f17f31403ae94 100755 --- a/Database/AthenaRoot/AthenaRootComps/src/RootSvc.cxx +++ b/Database/AthenaRoot/AthenaRootComps/src/RootSvc.cxx @@ -15,7 +15,6 @@ // POOL/APR includes for Catalog #include "FileCatalog/IFileCatalog.h" -#include "FileCatalog/IFCAction.h" // fwk includes #include "AthenaKernel/IDictLoaderSvc.h" @@ -125,19 +124,14 @@ void RootSvc::destructObject(const RootType& /*type*/, void* /*pObj*/) const { /// Open the file `fname` with open mode `mode` StatusCode RootSvc::open(const std::string& fname, const std::string& /*mode*/) { // Catalog to get fid... - Guid fid = Guid::null(); if (m_catalog != 0) { std::string fidString, ftype; - pool::IFCAction action; - m_catalog->setAction(action); - action.lookupFileByPFN(fname, fidString, ftype); - if (!fidString.empty()) { - fid.fromString(fidString); - } else { - Guid::create(fid); - fidString = fid.toString(); - action.registerPFN(fname, "ROOT_All", fidString); + m_catalog->lookupFileByPFN(fname, fidString, ftype); + if( fidString.empty() ) { + m_catalog->registerPFN(fname, "ROOT_All", fidString); } + Guid fid; + fid.fromString(fidString); } Athena::RootConnection* conn = 0; ConnMap_t::const_iterator fitr = m_conns.find(fid); @@ -205,19 +199,14 @@ StatusCode RootSvc::disconnect(const std::string& fname) { /// @returns NULL if no such file is known to this service Athena::RootConnection* RootSvc::connection(const std::string& fname) { // Catalog to get fid... - Guid fid = Guid::null(); if (m_catalog != 0) { - std::string fidString, ftype; - pool::IFCAction action; - m_catalog->setAction(action); - action.lookupFileByPFN(fname, fidString, ftype); - if (!fidString.empty()) { - fid.fromString(fidString); - } else { - Guid::create(fid); - fidString = fid.toString(); - action.registerPFN(fname, "ROOT_All", fidString); - } + std::string fidString, ftype; + m_catalog->lookupFileByPFN(fname, fidString, ftype); + if( fidString.empty() ) { + m_catalog->registerPFN(fname, "ROOT_All", fidString); + } + Guid fid; + fid.fromString(fidString); } Athena::RootConnection* conn = 0; ConnMap_t::const_iterator fitr = m_conns.find(fid); diff --git a/Database/CoolConvUtilities/src/AtlCoolCopy.cxx b/Database/CoolConvUtilities/src/AtlCoolCopy.cxx index 7085f120c03d1e06ea5f070db0c045ad381b2b1c..0395b55ae3ac86150be17ca226475334fc185d6f 100755 --- a/Database/CoolConvUtilities/src/AtlCoolCopy.cxx +++ b/Database/CoolConvUtilities/src/AtlCoolCopy.cxx @@ -31,8 +31,6 @@ #include "CoralBase/AttributeListException.h" #include "FileCatalog/IFileCatalog.h" -#include "FileCatalog/IFCAction.h" -#include "FileCatalog/IFCContainer.h" #include "PersistencySvc/IDatabase.h" #include "PersistencySvc/ISession.h" #include "PersistencySvc/ITransaction.h" @@ -3022,9 +3020,6 @@ int AtlCoolCopy::resolvePoolRefs() { // prepare POOL session pool_utility.startSession(); } - pool::FClookup lookup; - catalog->setAction(lookup); - // inject additional GUIDs/LFNs if needed if (m_addguid.size()>0) { for (std::vector<std::string>::const_iterator itr=m_addguid.begin(); @@ -3037,7 +3032,7 @@ int AtlCoolCopy::resolvePoolRefs() { for (std::vector<std::string>::const_iterator itr=m_addlfn.begin(); itr!=m_addlfn.end();++itr) { std::string guid; - lookup.lookupFileByLFN(*itr,guid); + catalog->lookupFileByLFN(*itr,guid); std::cout << "Add POOL file GUID: " << guid << " from LFN " << *itr << std::endl; m_poolrefs[guid]=PoolMapElement(1,"ADDLFN"); @@ -3054,8 +3049,8 @@ int AtlCoolCopy::resolvePoolRefs() { for (PoolMap::iterator ipool=m_poolrefs.begin(); ipool!=m_poolrefs.end();++ipool) { pool::FileCatalog::FileID guid=ipool->first; - pool::LFNContainer mylfn(catalog,100); - lookup.lookupLFN(guid,mylfn); + pool::IFileCatalog::Files lfns; + catalog->getLFNs( lfns ); if (mylfn.hasNext()) { // file found in cataloge - print LFN and usage count const std::string lfn=mylfn.Next().lfname();