ATLAS Offline Software
Loading...
Searching...
No Matches
PoolSvc Class Reference

This class provides the interface to the LCG POOL persistency software. More...

#include <PoolSvc.h>

Inheritance diagram for PoolSvc:
Collaboration diagram for PoolSvc:

Classes

class  ContextLock

Public Member Functions

virtual StatusCode initialize () override
 Required of all Gaudi services:
virtual StatusCode io_reinit () override
virtual StatusCode start () override
 Required of all Gaudi services:
virtual StatusCode stop () override
virtual StatusCode finalize () override
 Required of all Gaudi services:
virtual StatusCode io_finalize () override
virtual TokenregisterForWrite (const Placement *placement, const void *obj, const RootType &classDesc) override
virtual void setObjPtr (void *&obj, const Token *token) override
virtual unsigned int getOutputContext (const std::string &label) override
virtual unsigned int getInputContext (const std::string &label, unsigned int maxFile=0) override
virtual std::map< std::string, unsigned int > getInputContextMap () const override
virtual unsigned int getInputContextMapSize () const override
virtual const coral::Context * context () const override
virtual void loadComponent (const std::string &compName) override
virtual void setShareMode (bool shareCat) override
virtual void startCatalog () override
virtual void commitCatalog () override
virtual void lookupBestPfn (const std::string &token, std::string &pfn, std::string &type) const override
virtual void renamePfn (const std::string &pf, const std::string &newpf) override
virtual pool::ICollectioncreateCollection (const std::string &connection, const std::string &collectionName, const pool::DbType &collectionType=pool::POOL_StorageType.type(), unsigned int contextId=IPoolSvc::kInputStream) const override
virtual TokengetToken (const std::string &connection, const std::string &collection, const unsigned long ientry) const override
virtual StatusCode connect (Io::IoFlag type, unsigned int contextId=IPoolSvc::kInputStream) override
 Connect to a logical database unit; PersistencySvc is chosen according to transaction type (accessmode).
virtual StatusCode commit (unsigned int contextId=IPoolSvc::kInputStream) const override
 Commit data for a given contextId and flush buffer.
virtual StatusCode commitAndHold (unsigned int contextId=IPoolSvc::kInputStream) const override
 Commit data for a given contextId and hold buffer.
virtual StatusCode disconnect (unsigned int contextId=IPoolSvc::kInputStream) const override
 Disconnect PersistencySvc associated with a contextId.
virtual StatusCode disconnectDb (const std::string &connection, unsigned int contextId=IPoolSvc::kInputStream) const override
 Disconnect single Database.
virtual StatusCode getAttribute (const std::string &optName, std::string &data, long tech, unsigned int contextId=IPoolSvc::kInputStream) const override
 Get POOL attributes - domain.
virtual StatusCode getAttribute (const std::string &optName, std::string &data, long tech, const std::string &dbName, const std::string &contName="", unsigned int contextId=IPoolSvc::kInputStream) const override
 Get POOL attributes - db/file, container/collection.
virtual StatusCode setAttribute (const std::string &optName, const std::string &data, long tech, unsigned int contextId=IPoolSvc::kOutputStream) const override
 Set POOL attributes - domain.
virtual StatusCode setAttribute (const std::string &optName, const std::string &data, long tech, const std::string &dbName, const std::string &contName="", unsigned int contextId=IPoolSvc::kOutputStream) const override
 Set POOL attributes - db/file, container/collection.
virtual StatusCode setFrontierCache (const std::string &conn) override
 Setup Frontier cache for given logical or physical connection name.
virtual ~PoolSvc ()
 Destructor.

Private Types

typedef std::recursive_mutex CallMutex

Private Member Functions

void clearState ()
pool::IFileCatalogcreateCatalog ()
void patchCatalog (const std::string &pfn, pool::IDatabase &dbH) const
StatusCode setupPersistencySvc ()
std::unique_ptr< pool::IDatabasegetDbHandle (unsigned int contextId, const std::string &dbName) const
 Get Database handle.
std::unique_ptr< pool::IContainergetContainerHandle (pool::IDatabase *dbH, const std::string &contName) const
 Get Container handle.
std::string poolCondPath (const std::string &leaf)
 Resolve a file using ATLAS_POOLCOND_PATH.

Private Attributes

CallMutex m_pool_mut
coral::Context * m_context {nullptr}
bool m_shareCat {false}
pool::IFileCatalogm_catalog {nullptr}
std::vector< pool::ISession * > m_dbSessionVec
std::vector< CallMutex * > m_pers_mut
std::map< std::string, unsigned int > m_inputContextLabel
std::map< std::string, unsigned int > m_outputContextLabel
std::string m_mainOutputLabel {}
std::map< unsigned int, unsigned int > m_contextMaxFile
std::map< unsigned int, std::list< Guid > > m_guidLists ATLAS_THREAD_SAFE
Gaudi::Property< int > m_dbAgeLimit {this,"MaxFilesOpen",0}
 MaxFilesOpen, option to have PoolSvc limit the number of open Input Files: default = 0 (No files are closed automatically).
Gaudi::Property< std::string > m_writeCatalog {this,"WriteCatalog","xmlcatalog_file:PoolFileCatalog.xml"}
 WriteCatalog, the file catalog to be used to register output files (also default input catalog): default = "" (use POOL default).
Gaudi::Property< std::vector< std::string > > m_readCatalog {this,"ReadCatalog",{},"List of catalog files to read from","OrderedSet<std::string>"}
 ReadCatalog, the list of additional POOL input file catalogs to consult: default = empty vector.
Gaudi::Property< bool > m_useROOTIMT {this,"UseROOTImplicitMT",true}
 Use ROOT Implicit MultiThreading, default = true.
Gaudi::Property< bool > m_useROOTMaxTree {this,"UseROOTIncreaseVMaxTree",false}
 Increase virtual TTree size to avoid backreads in multithreading, default = false.
Gaudi::Property< bool > m_attemptCatalogPatch {this,"AttemptCatalogPatch",true}
 AttemptCatalogPatch, option to create catalog: default = false.
Gaudi::Property< int > m_retrialPeriod {this,"ConnectionRetrialPeriod",300}
 ConnectionRetrialPeriod, retry period for CORAL Connection Service: default = 30 seconds.
Gaudi::Property< int > m_retrialTimeOut {this,"ConnectionRetrialTimeOut",3600}
 ConnectionRetrialTimeOut, the retrial time out for CORAL Connection Service: default = 300 seconds.
Gaudi::Property< int > m_timeOut {this,"ConnectionTimeOut",5}
 ConnectionTimeOut, the time out for CORAL Connection Service: default = 5 seconds.
Gaudi::Property< bool > m_connClean {this,"ConnectionCleanUp",false}
 ConnectionCleanUp - whether to use CORAL connection management thread: default = false.
Gaudi::Property< int > m_frontierComp {this,"FrontierCompression",5}
 Frontier proprties, compression level and list of schemas to be refreshed: default = 5.
Gaudi::Property< std::vector< std::string > > m_frontierRefresh {this,"FrontierRefreshSchema",{}}

Detailed Description

This class provides the interface to the LCG POOL persistency software.

Definition at line 37 of file PoolSvc.h.

Member Typedef Documentation

◆ CallMutex

typedef std::recursive_mutex PoolSvc::CallMutex
private

Definition at line 210 of file PoolSvc.h.

Constructor & Destructor Documentation

◆ ~PoolSvc()

PoolSvc::~PoolSvc ( )
virtual

Destructor.

Definition at line 905 of file PoolSvc.cxx.

905 {
906}

Member Function Documentation

◆ clearState()

void PoolSvc::clearState ( )
private

Definition at line 215 of file PoolSvc.cxx.

215 {
216 std::lock_guard<CallMutex> lock(m_pool_mut);
217 // Cleanup persistency service
218 for (const auto& dbSession : m_dbSessionVec) {
219 delete dbSession;
220 }
221 m_dbSessionVec.clear();
222 for (const auto& persistencyMutex : m_pers_mut) {
223 delete persistencyMutex;
224 }
225 m_mainOutputLabel.clear();
226 m_inputContextLabel.clear();
227 m_outputContextLabel.clear();
228 m_pers_mut.clear();
229 if (m_catalog != nullptr) {
230 m_catalog->commit();
231 delete m_catalog; m_catalog = nullptr;
232 }
233}
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
pool::IFileCatalog * m_catalog
Definition PoolSvc.h:227
CallMutex m_pool_mut
Definition PoolSvc.h:224
std::vector< pool::ISession * > m_dbSessionVec
Definition PoolSvc.h:228
std::map< std::string, unsigned int > m_outputContextLabel
Definition PoolSvc.h:231
std::vector< CallMutex * > m_pers_mut
Definition PoolSvc.h:229
std::map< std::string, unsigned int > m_inputContextLabel
Definition PoolSvc.h:230
std::string m_mainOutputLabel
Definition PoolSvc.h:232

◆ commit()

StatusCode PoolSvc::commit ( unsigned int contextId = IPoolSvc::kInputStream) const
overridevirtual

Commit data for a given contextId and flush buffer.

Parameters
contextId[IN] poolStream to be commited.

Definition at line 564 of file PoolSvc.cxx.

564 {
565 if (contextId >= m_dbSessionVec.size()) {
566 return(StatusCode::FAILURE);
567 }
569 auto session = m_dbSessionVec[contextId];
570 if (session != nullptr && session->transaction().isActive()) {
571 if (!session->commit()) {
572 ATH_MSG_ERROR("POOL commit failed " << session);
573 return(StatusCode::FAILURE);
574 }
575 if (session->transaction().type() == Io::READ) {
576 session->disconnectAll();
577 }
578 }
579 return(StatusCode::SUCCESS);
580}
#define ATH_MSG_ERROR(x)

◆ commitAndHold()

StatusCode PoolSvc::commitAndHold ( unsigned int contextId = IPoolSvc::kInputStream) const
overridevirtual

Commit data for a given contextId and hold buffer.

Parameters
contextId[IN] poolStream to be commited.

Definition at line 582 of file PoolSvc.cxx.

582 {
583 if (contextId >= m_dbSessionVec.size()) {
584 return(StatusCode::FAILURE);
585 }
587 pool::ISession* session = m_dbSessionVec[contextId];
588 if (session != nullptr && session->transaction().isActive()) {
589 if (!session->commitAndHold()) {
590 ATH_MSG_ERROR("POOL commitAndHold failed " << session);
591 return(StatusCode::FAILURE);
592 }
593 }
594 return(StatusCode::SUCCESS);
595}
virtual ITransaction & transaction()=0
Returns the transaction interface.
virtual bool commitAndHold()=0
Commits the holds transaction.
virtual bool isActive() const =0
Checks if the transaction is active.

◆ commitCatalog()

void PoolSvc::commitCatalog ( )
overridevirtual
Returns
void

Definition at line 377 of file PoolSvc.cxx.

377 {
378 if (m_catalog != nullptr) {
379 m_catalog->commit();
380 }
381}

◆ connect()

StatusCode PoolSvc::connect ( Io::IoFlag type,
unsigned int contextId = IPoolSvc::kInputStream )
overridevirtual

Connect to a logical database unit; PersistencySvc is chosen according to transaction type (accessmode).

Definition at line 532 of file PoolSvc.cxx.

532 {
533 if (type != Io::READ) {
534 if (contextId >= m_dbSessionVec.size()) {
535 ATH_MSG_WARNING("connect: Using default output Stream instead of id = " << contextId);
536 contextId = IPoolSvc::kOutputStream;
537 }
538 } else {
539 if (contextId > m_dbSessionVec.size()) {
540 ATH_MSG_WARNING("connect: Using default input Stream instead of id = " << contextId);
541 contextId = IPoolSvc::kInputStream;
542 } else if (contextId == m_dbSessionVec.size()) {
543 ATH_MSG_INFO("Connecting to InputStream for: " << contextId);
544 contextId = this->getInputContext("");
545 }
546 }
547 if (contextId >= m_dbSessionVec.size()) {
548 return(StatusCode::FAILURE);
549 }
551 auto session = m_dbSessionVec[contextId];
552 // Connect to a logical database using the pre-defined technology and dbID
553 if (session->transaction().isActive()) {
554 return(StatusCode::SUCCESS);
555 }
556 if (!session->start(type)) {
557 ATH_MSG_ERROR("connect failed session = " << session << " type = " << type);
558 return(StatusCode::FAILURE);
559 }
560
561 return(StatusCode::SUCCESS);
562}
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
@ kOutputStream
Definition IPoolSvc.h:37
@ kInputStream
Definition IPoolSvc.h:37
virtual unsigned int getInputContext(const std::string &label, unsigned int maxFile=0) override
Definition PoolSvc.cxx:324

◆ context()

const coral::Context * PoolSvc::context ( ) const
overridevirtual
Returns
the context.

Definition at line 359 of file PoolSvc.cxx.

359 {
360 return(m_context);
361}
coral::Context * m_context
Definition PoolSvc.h:225

◆ createCatalog()

pool::IFileCatalog * PoolSvc::createCatalog ( )
private

Definition at line 866 of file PoolSvc.cxx.

866 {
867 pool::IFileCatalog* ctlg = new pool::IFileCatalog;
868 ctlg->removeCatalog("*");
869 for (auto& catalog : m_readCatalog.value()) {
870 ATH_MSG_DEBUG("POOL ReadCatalog is " << catalog);
871 if (catalog.compare(0, 8,"apcfile:") == 0 || catalog.compare(0, 7, "prfile:") == 0) {
872 std::string::size_type cpos = catalog.find(':');
873 // check for file accessed via ATLAS_POOLCOND_PATH
874 std::string file = poolCondPath(catalog.substr(cpos + 1));
875 if (!file.empty()) {
876 ATH_MSG_INFO("Resolved path (via ATLAS_POOLCOND_PATH) is " << file);
877 ctlg->addReadCatalog("file:" + file);
878 } else {
879 // As backup, check for file accessed via PathResolver
880 file = PathResolver::find_file(catalog.substr(cpos + 1), "DATAPATH");
881 if (!file.empty()) {
882 ATH_MSG_INFO("Resolved path (via DATAPATH) is " << file);
883 ctlg->addReadCatalog("file:" + file);
884 } else {
885 ATH_MSG_INFO("Unable find catalog "
886 << catalog
887 << " in $ATLAS_POOLCOND_PATH and $DATAPATH");
888 }
889 }
890 } else {
891 ctlg->addReadCatalog(catalog);
892 }
893 }
894 try {
895 ATH_MSG_INFO("POOL WriteCatalog is " << m_writeCatalog.value());
896 ctlg->setWriteCatalog(m_writeCatalog.value());
897 } catch(std::exception& e) {
898 ATH_MSG_ERROR("setWriteCatalog - caught exception: " << e.what());
899 return(nullptr); // This catalog is not setup properly!
900 }
901 return(ctlg);
902}
#define ATH_MSG_DEBUG(x)
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
std::string poolCondPath(const std::string &leaf)
Resolve a file using ATLAS_POOLCOND_PATH.
Definition PoolSvc.cxx:946
Gaudi::Property< std::vector< std::string > > m_readCatalog
ReadCatalog, the list of additional POOL input file catalogs to consult: default = empty vector.
Definition PoolSvc.h:245
Gaudi::Property< std::string > m_writeCatalog
WriteCatalog, the file catalog to be used to register output files (also default input catalog): defa...
Definition PoolSvc.h:243
void addReadCatalog(const std::string &connect)
Add new catalog, identified by name, to the existing ones.
void removeCatalog(const std::string &connect)
Remove catalog identified by name from the existing ones. * or '' removes all.
void setWriteCatalog(const std::string &connect)
Establish the writable catalog, identified by name.
TFile * file

◆ createCollection()

pool::ICollection * PoolSvc::createCollection ( const std::string & connection,
const std::string & collectionName,
const pool::DbType & collectionType = pool::POOL_StorageType.type(),
unsigned int contextId = IPoolSvc::kInputStream ) const
overridevirtual
Returns
a pointer to a Pool Collection.
Parameters
collectionType[IN] string containing the collection type.
connection[IN] string containing the connection.
collectionName[IN] string containing the persistent name of the collection.
contextId[IN] id for PoolSvc persistency service to use for input.

Definition at line 416 of file PoolSvc.cxx.

419 {
420 ATH_MSG_DEBUG("createCollection() type=" << collectionType.storageName() << ", connection=" << connection
421 << ", name=" << collectionName << ", contextID=" << contextId);
422 if (contextId >= m_dbSessionVec.size()) {
423 ATH_MSG_WARNING("createCollection: Using default input Stream instead of id = " << contextId);
424 contextId = IPoolSvc::kInputStream;
425 }
427 // Check POOL FileCatalog entry.
428 bool insertFile = false;
429 if (connection.compare(0, 4, "PFN:") == 0) {
430 std::string fid, fileType;
431 m_catalog->lookupFileByPFN(connection.substr(4), fid, fileType);
432 if (fid.empty()) { // No entry in file catalog
433 insertFile = true;
434 ATH_MSG_INFO("File is not in Catalog! Attempt to open it anyway.");
435 }
436 }
437 if (collectionType.majorType() == pool::POOL_StorageType.type()) {
438 // Check whether Collection Container exists.
439 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
440 if (dbH == nullptr) {
441 ATH_MSG_INFO("Failed to get Session/DatabaseHandle to create POOL collection.");
442 return(nullptr);
443 }
444 try {
445 if (dbH->openMode() == Io::INVALID) {
446 dbH->connectForRead();
447 }
448 std::map<unsigned int, unsigned int>::const_iterator maxFileIter = m_contextMaxFile.find(contextId);
449 if (maxFileIter != m_contextMaxFile.end() && maxFileIter->second > 0 && !dbH->fid().empty()) {
450 const Guid guid(dbH->fid());
451 m_guidLists[contextId].remove(guid);
452 m_guidLists[contextId].push_back(guid);
453 while (m_guidLists[contextId].size() > maxFileIter->second + 1) {
454 this->disconnectDb("FID:" + m_guidLists[contextId].begin()->toString(), contextId).ignore();
455 }
456 }
457 } catch (std::exception& e) {
458 ATH_MSG_INFO("Failed to open container to check POOL collection - trying.");
459 }
460 }
461
462 // access to these variables is locked below:
463 pool::CollectionService collSvc ATLAS_THREAD_SAFE = pool::CollectionService();
464 pool::ICollection* collPtr ATLAS_THREAD_SAFE = nullptr;
465
466 // Try to open EventTags Collection in the input file
467 std::scoped_lock sc_lock(m_pool_mut);
468 std::string error_text;
469 try {
470 collPtr = collSvc.open(collectionName, collectionType, connection, m_dbSessionVec[contextId]);
471 } catch (std::exception &e) {
472 collPtr = nullptr;
473 error_text = e.what();
474 }
475 if( !collPtr ) {
476 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
477 if (dbH != nullptr && !dbH->fid().empty()) {
478 return(nullptr); // no events
479 }
480 throw std::runtime_error( "Failed to open Collection: " + error_text + ", PoolSvc::createCollection");
481 }
482 if (insertFile && m_attemptCatalogPatch.value()) {
483 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
484 if (dbH == nullptr) {
485 ATH_MSG_INFO("Failed to create FileCatalog entry.");
486 } else if (dbH->fid().empty()) {
487 ATH_MSG_INFO("Cannot retrieve the FID of an existing POOL database: '"
488 << connection << "' - FileCatalog will NOT be updated.");
489 } else {
490 patchCatalog(connection.substr(4), *dbH);
491 }
492 }
493 // For multithreaded processing (with multiple events in flight),
494 // increase virtual tree size to accomodate back reads
495 if (m_useROOTMaxTree && contextId == IPoolSvc::kInputStream && Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents() > 1) {
496 if (!this->setAttribute("TREE_MAX_VIRTUAL_SIZE", "-1", pool::ROOT_StorageType.type(), connection.substr(4), "CollectionTree", IPoolSvc::kInputStream).isSuccess()) {
497 ATH_MSG_WARNING("Failed to increase maximum virtual TTree size.");
498 }
499 }
500
501 return(collPtr);
502}
size_t size() const
Number of registered mappings.
void patchCatalog(const std::string &pfn, pool::IDatabase &dbH) const
Definition PoolSvc.cxx:504
virtual StatusCode setAttribute(const std::string &optName, const std::string &data, long tech, unsigned int contextId=IPoolSvc::kOutputStream) const override
Set POOL attributes - domain.
Definition PoolSvc.cxx:711
Gaudi::Property< bool > m_useROOTMaxTree
Increase virtual TTree size to avoid backreads in multithreading, default = false.
Definition PoolSvc.h:249
virtual StatusCode disconnectDb(const std::string &connection, unsigned int contextId=IPoolSvc::kInputStream) const override
Disconnect single Database.
Definition PoolSvc.cxx:619
std::map< unsigned int, unsigned int > m_contextMaxFile
Definition PoolSvc.h:233
std::unique_ptr< pool::IDatabase > getDbHandle(unsigned int contextId, const std::string &dbName) const
Get Database handle.
Definition PoolSvc.cxx:908
Gaudi::Property< bool > m_attemptCatalogPatch
AttemptCatalogPatch, option to create catalog: default = false.
Definition PoolSvc.h:252
std::map< unsigned int, std::list< Guid > > m_guidLists ATLAS_THREAD_SAFE
Definition PoolSvc.h:235
const std::string storageName() const
Human readable storage type.
int majorType() const
Access to major type.
Definition DbType.h:67
int type() const
Access to full type.
Definition DbType.h:65
std::string toString(const Translation3D &translation, int precision=4)
GeoPrimitvesToStringConverter.
static const DbType ROOT_StorageType
Definition DbType.h:85
static const DbType POOL_StorageType
Definition DbType.h:84

◆ disconnect()

StatusCode PoolSvc::disconnect ( unsigned int contextId = IPoolSvc::kInputStream) const
overridevirtual

Disconnect PersistencySvc associated with a contextId.

Parameters
contextId[IN] poolStream to be disconnected.

Definition at line 597 of file PoolSvc.cxx.

597 {
598 ATH_MSG_DEBUG("Disconnect request for contextId=" << contextId);
599 if (contextId >= m_dbSessionVec.size()) {
600 return(StatusCode::SUCCESS);
601 }
603 pool::ISession* session = m_dbSessionVec[contextId];
604 if (session != nullptr && session->transaction().isActive()) {
605 if (!commit(contextId).isSuccess()) {
606 ATH_MSG_ERROR("disconnect failed to commit " << session);
607 return(StatusCode::FAILURE);
608 }
609 if (session->disconnectAll()) {
610 ATH_MSG_DEBUG("Disconnected PersistencySvc session");
611 } else {
612 ATH_MSG_ERROR("disconnect failed to diconnect PersistencySvc");
613 return(StatusCode::FAILURE);
614 }
615 }
616 return(StatusCode::SUCCESS);
617}
virtual StatusCode commit(unsigned int contextId=IPoolSvc::kInputStream) const override
Commit data for a given contextId and flush buffer.
Definition PoolSvc.cxx:564
virtual bool disconnectAll()=0
Explicitly disconnects all the databases.

◆ disconnectDb()

StatusCode PoolSvc::disconnectDb ( const std::string & connection,
unsigned int contextId = IPoolSvc::kInputStream ) const
overridevirtual

Disconnect single Database.

Parameters
connection[IN] connection string for Database to be disconnected.
contextId[IN] context id of database to be disconnected.

Definition at line 619 of file PoolSvc.cxx.

619 {
620 if (contextId >= m_dbSessionVec.size()) {
621 return(StatusCode::SUCCESS);
622 }
624 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, connection);
625 if (dbH == nullptr) {
626 ATH_MSG_ERROR("Failed to get Session/DatabaseHandle.");
627 return(StatusCode::FAILURE);
628 }
629 std::map<unsigned int, unsigned int>::const_iterator maxFileIter = m_contextMaxFile.find(contextId);
630 if (maxFileIter != m_contextMaxFile.end() && maxFileIter->second > 0) {
631 m_guidLists[contextId].remove(Guid(dbH->fid()));
632 }
633 dbH->disconnect();
634 return(StatusCode::SUCCESS);
635}

◆ finalize()

StatusCode PoolSvc::finalize ( )
overridevirtual

Required of all Gaudi services:

Definition at line 235 of file PoolSvc.cxx.

235 {
236 clearState();
237 return(::AthService::finalize());
238}
void clearState()
Definition PoolSvc.cxx:215

◆ getAttribute() [1/2]

StatusCode PoolSvc::getAttribute ( const std::string & optName,
std::string & data,
long tech,
const std::string & dbName,
const std::string & contName = "",
unsigned int contextId = IPoolSvc::kInputStream ) const
overridevirtual

Get POOL attributes - db/file, container/collection.

Definition at line 660 of file PoolSvc.cxx.

665 {
667 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, dbName);
668 if (dbH == nullptr) {
669 ATH_MSG_DEBUG("getAttribute: Failed to get Session/DatabaseHandle to get POOL property.");
670 return(StatusCode::FAILURE);
671 }
672 if (dbH->openMode() == Io::INVALID) {
673 if (m_dbSessionVec[contextId]->transaction().type() == Io::WRITE || m_dbSessionVec[contextId]->transaction().type() == Io::APPEND) {
674 dbH->setTechnology(tech);
675 dbH->connectForWrite();
676 } else {
677 dbH->connectForRead();
678 }
679 }
680 std::ostringstream oss;
681 if (contName.empty()) {
682 if (data == "DbLonglong") {
683 oss << std::dec << dbH->technologySpecificAttributes().attribute<long long int>(optName);
684 } else if (data == "double") {
685 oss << std::dec << dbH->technologySpecificAttributes().attribute<double>(optName);
686 } else if (data == "string") {
687 oss << dbH->technologySpecificAttributes().attribute<char*>(optName);
688 } else {
689 oss << std::dec << dbH->technologySpecificAttributes().attribute<int>(optName);
690 }
691 ATH_MSG_INFO("Database (" << dbH->pfn() << ") attribute [" << optName << "]" << ": " << oss.str());
692 } else {
693 std::unique_ptr<pool::IContainer> contH = getContainerHandle(dbH.get(), contName);
694 if (contH == nullptr) {
695 ATH_MSG_DEBUG("Failed to get ContainerHandle to get POOL property.");
696 return(StatusCode::FAILURE);
697 }
698 if (data == "DbLonglong") {
699 oss << std::dec << contH->technologySpecificAttributes().attribute<long long int>(optName);
700 } else if (data == "double") {
701 oss << std::dec << contH->technologySpecificAttributes().attribute<double>(optName);
702 } else {
703 oss << std::dec << contH->technologySpecificAttributes().attribute<int>(optName);
704 }
705 ATH_MSG_INFO("Container attribute [" << contName << "." << optName << "]: " << oss.str());
706 }
707 data = oss.str();
708 return(StatusCode::SUCCESS);
709}
std::unique_ptr< pool::IContainer > getContainerHandle(pool::IDatabase *dbH, const std::string &contName) const
Get Container handle.
Definition PoolSvc.cxx:932

◆ getAttribute() [2/2]

StatusCode PoolSvc::getAttribute ( const std::string & optName,
std::string & data,
long tech,
unsigned int contextId = IPoolSvc::kInputStream ) const
overridevirtual

Get POOL attributes - domain.

Definition at line 637 of file PoolSvc.cxx.

640 {
641 if (contextId >= m_dbSessionVec.size()) {
642 ATH_MSG_WARNING("getAttribute: Using default input Stream instead of id = " << contextId);
643 contextId = IPoolSvc::kInputStream;
644 }
646 pool::ISession* sesH = m_dbSessionVec[contextId];
647 std::ostringstream oss;
648 if (data == "DbLonglong") {
649 oss << std::dec << sesH->technologySpecificAttributes(tech).attribute<long long int>(optName);
650 } else if (data == "double") {
651 oss << std::dec << sesH->technologySpecificAttributes(tech).attribute<double>(optName);
652 } else {
653 oss << std::dec << sesH->technologySpecificAttributes(tech).attribute<int>(optName);
654 }
655 data = oss.str();
656 ATH_MSG_INFO("Domain attribute [" << optName << "]" << ": " << data);
657 return(StatusCode::SUCCESS);
658}
virtual const ITechnologySpecificAttributes & technologySpecificAttributes(long technology) const =0
Returns the object holding the technology specific attributes for a given technology domain.
T attribute(const std::string &attributeName, const std::string &option="")
Templated method to retrieve an attribute.

◆ getContainerHandle()

std::unique_ptr< pool::IContainer > PoolSvc::getContainerHandle ( pool::IDatabase * dbH,
const std::string & contName ) const
private

Get Container handle.

Definition at line 932 of file PoolSvc.cxx.

932 {
933 pool::IContainer* contH = nullptr;
934 if (dbH == nullptr) {
935 ATH_MSG_DEBUG("No DatabaseHandle to get Container.");
936 return(nullptr);
937 }
938 if (contName.find("DataHeader") != std::string::npos) {
939 contH = dbH->containerHandle(contName.substr(0, contName.find("_p")));
940 } else {
941 contH = dbH->containerHandle(contName);
942 }
943 return(std::unique_ptr<pool::IContainer>(contH));
944}
virtual IContainer * containerHandle(const std::string &name)=0
Returns a pointer to a container object. The user acquires ownership of that object.

◆ getDbHandle()

std::unique_ptr< pool::IDatabase > PoolSvc::getDbHandle ( unsigned int contextId,
const std::string & dbName ) const
private

Get Database handle.

Definition at line 908 of file PoolSvc.cxx.

908 {
909 if (contextId >= m_dbSessionVec.size()) {
910 ATH_MSG_WARNING("getDbHandle: Using default input Stream instead of id = " << contextId);
911 contextId = IPoolSvc::kInputStream;
912 }
913 pool::ISession* sesH = m_dbSessionVec[contextId];
914 if (!sesH->transaction().isActive()) {
915 Io::IoFlag transMode = Io::READ;
916 ATH_MSG_DEBUG("Start transaction, type = " << transMode);
917 if (!sesH->transaction().start(transMode)) {
918 ATH_MSG_WARNING("Failed to start transaction, type = " << transMode);
919 return(nullptr);
920 }
921 }
922 if (dbName.compare(0, 4,"PFN:") == 0) {
924 } else if (dbName.compare(0, 4, "LFN:") == 0) {
926 } else if (dbName.compare(0, 4,"FID:") == 0) {
928 }
930}
virtual std::unique_ptr< IDatabase > databaseHandle(const std::string &dbName, DatabaseSpecification::NameType dbNameType)=0
Returns a pointer to a database object. The user acquires ownership of that object.
virtual bool start(Io::IoFlag type=Io::READ)=0
Starts a new transaction. Returns the success of the operation.
@ FID
Physical File Name.
Definition IDatabase.h:26
@ LFN
File IDentifier.
Definition IDatabase.h:27

◆ getInputContext()

unsigned int PoolSvc::getInputContext ( const std::string & label,
unsigned int maxFile = 0 )
overridevirtual
Returns
an Id for an input context (POOL persistency service) and create it if needed.
Parameters
label[IN] string label to name new context and allow sharing (returns existing contextId)
maxFile[IN] maximum number of open input files.

Definition at line 324 of file PoolSvc.cxx.

324 {
325 std::lock_guard<CallMutex> lock(m_pool_mut);
326 if (!label.empty()) {
327 std::map<std::string, unsigned int>::const_iterator contextIter = m_inputContextLabel.find(label);
328 if (contextIter != m_inputContextLabel.end()) {
329 if (maxFile > 0) {
330 m_contextMaxFile[contextIter->second] = maxFile;
331 }
332 return(contextIter->second);
333 }
334 }
335 const unsigned int id = m_dbSessionVec.size();
336 m_dbSessionVec.push_back( pool::createSession(*m_catalog, maxFile).release() );
337 m_pers_mut.push_back(new CallMutex);
338 if (!connect(Io::READ, id).isSuccess()) {
339 ATH_MSG_WARNING("Failed to connect Input PersistencySvc: " << id);
341 }
342 if (!label.empty()) {
343 m_inputContextLabel.insert(std::pair<std::string, unsigned int>(label, id));
344 }
345 m_contextMaxFile.insert(std::pair<unsigned int, int>(id, maxFile));
346 return(id);
347}
virtual StatusCode connect(Io::IoFlag type, unsigned int contextId=IPoolSvc::kInputStream) override
Connect to a logical database unit; PersistencySvc is chosen according to transaction type (accessmod...
Definition PoolSvc.cxx:532
std::recursive_mutex CallMutex
Definition PoolSvc.h:210
static std::string release
Definition computils.h:50
std::string label(const std::string &format, int i)
Definition label.h:19
std::unique_ptr< ISession > createSession(IFileCatalog &catalog, int ageLimit=-1)

◆ getInputContextMap()

std::map< std::string, unsigned int > PoolSvc::getInputContextMap ( ) const
overridevirtual
Returns
copy of the map of all labelled input contexts.

Definition at line 349 of file PoolSvc.cxx.

349 {
350 std::lock_guard<CallMutex> lock(m_pool_mut);
351 return(m_inputContextLabel);
352}

◆ getInputContextMapSize()

unsigned int PoolSvc::getInputContextMapSize ( ) const
overridevirtual
Returns
size of the map of all labelled input contexts.

Definition at line 354 of file PoolSvc.cxx.

354 {
355 std::lock_guard<CallMutex> lock(m_pool_mut);
356 return(m_inputContextLabel.size());
357}

◆ getOutputContext()

unsigned int PoolSvc::getOutputContext ( const std::string & label)
overridevirtual
Returns
an Id for an output context (POOL persistency service) and create it if needed.
Parameters
label[IN] string label to name new context and allow sharing (returns existing contextId)

Definition at line 304 of file PoolSvc.cxx.

304 {
305 std::lock_guard<CallMutex> lock(m_pool_mut);
306 if (m_mainOutputLabel.empty()) {
308 m_outputContextLabel.insert(std::pair<std::string, unsigned int>(label, IPoolSvc::kOutputStream));
309 }
310 if (label == m_mainOutputLabel || label.empty()) {
312 }
313 std::map<std::string, unsigned int>::const_iterator contextIter = m_outputContextLabel.find(label);
314 if (contextIter != m_outputContextLabel.end()) {
315 return(contextIter->second);
316 }
317 const unsigned int id = m_dbSessionVec.size();
318 m_dbSessionVec.push_back(pool::createSession(*m_catalog).release());
319 m_pers_mut.push_back(new CallMutex);
320 m_outputContextLabel.insert(std::pair<std::string, unsigned int>(label, id));
321 return(id);
322}

◆ getToken()

Token * PoolSvc::getToken ( const std::string & connection,
const std::string & collection,
const unsigned long ientry ) const
overridevirtual
Returns
a token for a container entry.
Parameters
connection[IN] string containing the connection/file name.
collection[IN] string containing the persistent name of the collection.
ientry[IN] entry number for the token to be returned

Definition at line 512 of file PoolSvc.cxx.

514 {
515 std::lock_guard<CallMutex> lock(*m_pers_mut[IPoolSvc::kInputStream]);
516 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(IPoolSvc::kInputStream, connection);
517 if (dbH == nullptr) {
518 return(nullptr);
519 }
520 if (dbH->openMode() == Io::INVALID) {
521 dbH->connectForRead();
522 }
523 std::unique_ptr<pool::IContainer> contH = getContainerHandle(dbH.get(), collection);
524 if (contH == nullptr) {
525 return(nullptr);
526 }
527 auto tokenIter = std::unique_ptr<pool::ITokenIterator>(contH->tokens());
528 // the Token returned by the iterator has the refCount already increased
529 return tokenIter->seek(ientry)? tokenIter->next() : nullptr;
530}

◆ initialize()

StatusCode PoolSvc::initialize ( )
overridevirtual

Required of all Gaudi services:

Definition at line 54 of file PoolSvc.cxx.

54 {
55 ATH_CHECK(::AthService::initialize());
56
57 // Register this service for 'I/O' events
58 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
59 ATH_CHECK(iomgr.retrieve());
60 ATH_CHECK(iomgr->io_register(this));
61 // Register input file's names with the I/O manager, unless in SharedWrite mode, set by AthenaPoolCnvSvc
62 bool allGood = true;
63 for (const auto& catalog : m_readCatalog.value()) {
64 if (catalog.starts_with("xmlcatalog_file:")) {
65 const std::string fileName = catalog.substr(16);
66 if (!iomgr->io_register(this, IIoComponentMgr::IoMode::READ, fileName, fileName).isSuccess()) {
67 ATH_MSG_FATAL("could not register [" << catalog << "] for input !");
68 allGood = false;
69 } else {
70 ATH_MSG_INFO("io_register[" << this->name() << "](" << catalog << ") [ok]");
71 }
72 }
73 }
74 if (m_writeCatalog.value().starts_with("xmlcatalog_file:")) {
75 const std::string fileName = m_writeCatalog.value().substr(16);
76 if (!iomgr->io_register(this, IIoComponentMgr::IoMode::WRITE, fileName, fileName).isSuccess()) {
77 ATH_MSG_FATAL("could not register [" << m_writeCatalog.value() << "] for input !");
78 allGood = false;
79 } else {
80 ATH_MSG_INFO("io_register[" << this->name() << "](" << m_writeCatalog.value() << ") [ok]");
81 }
82 }
83 if (!allGood) {
84 return(StatusCode::FAILURE);
85 }
86 m_context = &coral::Context::instance();
87 if (m_context == nullptr) {
88 ATH_MSG_FATAL("Failed to access CORAL Context");
89 return(StatusCode::FAILURE);
90 }
91 coral::ConnectionService conSvcH;
92 coral::IConnectionServiceConfiguration& csConfig = conSvcH.configuration();
93 csConfig.setConnectionRetrialPeriod(m_retrialPeriod);
94 csConfig.setConnectionRetrialTimeOut(m_retrialTimeOut);
95 if (m_connClean) {
96 csConfig.enablePoolAutomaticCleanUp();
97 csConfig.setConnectionTimeOut(m_timeOut);
98 } else {
99 csConfig.disablePoolAutomaticCleanUp();
100 csConfig.setConnectionTimeOut(0);
101 }
102 ATH_MSG_INFO("Set connectionsvc retry/timeout/IDLE timeout to "
104 << "/"
106 << "/"
107 << m_timeOut
108 << " seconds with connection cleanup "
109 << (csConfig.isPoolAutomaticCleanUpEnabled() ? "enabled" : "disabled"));
110 // set Frontier web cache compression level
111 coral::IWebCacheControl& webCache = conSvcH.webCacheControl();
112 webCache.setCompressionLevel(m_frontierComp);
113 ATH_MSG_INFO("Frontier compression level set to " << webCache.compressionLevel());
114 MSG::Level athLvl = msg().level();
115 ATH_MSG_DEBUG("OutputLevel is " << (int)athLvl);
117 return(setupPersistencySvc());
118}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_FATAL(x)
Gaudi::Property< int > m_retrialTimeOut
ConnectionRetrialTimeOut, the retrial time out for CORAL Connection Service: default = 300 seconds.
Definition PoolSvc.h:256
Gaudi::Property< int > m_timeOut
ConnectionTimeOut, the time out for CORAL Connection Service: default = 5 seconds.
Definition PoolSvc.h:258
Gaudi::Property< int > m_retrialPeriod
ConnectionRetrialPeriod, retry period for CORAL Connection Service: default = 30 seconds.
Definition PoolSvc.h:254
Gaudi::Property< bool > m_connClean
ConnectionCleanUp - whether to use CORAL connection management thread: default = false.
Definition PoolSvc.h:260
Gaudi::Property< int > m_frontierComp
Frontier proprties, compression level and list of schemas to be refreshed: default = 5.
Definition PoolSvc.h:262
StatusCode setupPersistencySvc()
Definition PoolSvc.cxx:162
bool allGood
Loop over the SDOs & Digits.
static void setLevel(MSG::Level l)
Definition DbPrint.h:20
MsgStream & msg
Definition testRead.cxx:32

◆ io_finalize()

StatusCode PoolSvc::io_finalize ( )
overridevirtual

Definition at line 240 of file PoolSvc.cxx.

240 {
241 ATH_MSG_INFO("I/O finalization...");
242 for (size_t i = 0; i < m_dbSessionVec.size(); i++) {
243 if ((m_dbSessionVec[i]->transaction().type() == Io::WRITE || m_dbSessionVec[i]->transaction().type() == Io::APPEND) &&
244 !disconnect(i).isSuccess()) {
245 ATH_MSG_WARNING("Cannot disconnect output Stream " << i);
246 }
247 }
248 clearState();
249 return(StatusCode::SUCCESS);
250}
virtual StatusCode disconnect(unsigned int contextId=IPoolSvc::kInputStream) const override
Disconnect PersistencySvc associated with a contextId.
Definition PoolSvc.cxx:597

◆ io_reinit()

StatusCode PoolSvc::io_reinit ( )
overridevirtual

Definition at line 121 of file PoolSvc.cxx.

121 {
122 ATH_MSG_INFO("I/O reinitialization...");
123 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
124 if (!iomgr.retrieve().isSuccess()) {
125 ATH_MSG_FATAL("Could not retrieve IoComponentMgr !");
126 return(StatusCode::FAILURE);
127 }
128 if (!iomgr->io_hasitem(this)) {
129 ATH_MSG_FATAL("IoComponentMgr does not know about myself !");
130 return(StatusCode::FAILURE);
131 }
132 std::vector<std::string> readcat = m_readCatalog.value();
133 for (std::size_t icat = 0, imax = readcat.size(); icat < imax; icat++) {
134 if (readcat[icat].compare(0, 16, "xmlcatalog_file:") == 0) {
135 std::string fileName = readcat[icat].substr(16);
136 if (iomgr->io_contains(this, fileName)) {
137 if (!iomgr->io_retrieve(this, fileName).isSuccess()) {
138 ATH_MSG_FATAL("Could not retrieve new value for [" << fileName << "] !");
139 return(StatusCode::FAILURE);
140 }
141 readcat[icat] = "xmlcatalog_file:" + fileName;
142 }
143 }
144 }
145 // all good... copy over.
146 m_readCatalog = readcat;
147 if (m_writeCatalog.value().compare(0, 16, "xmlcatalog_file:") == 0) {
148 std::string fileName = m_writeCatalog.value().substr(16);
149 if (iomgr->io_contains(this, fileName)) {
150 if (!iomgr->io_retrieve(this, fileName).isSuccess()) {
151 ATH_MSG_FATAL("Could not retrieve new value for [" << fileName << "] !");
152 return(StatusCode::FAILURE);
153 }
154 if (!m_shareCat) {
155 m_writeCatalog.setValue("xmlcatalog_file:" + fileName);
156 }
157 }
158 }
159 return(setupPersistencySvc());
160}
int imax(int i, int j)
bool m_shareCat
Definition PoolSvc.h:226
std::pair< int, int > compare(const AmgSymMatrix(N) &m1, const AmgSymMatrix(N) &m2, double precision=1e-9, bool relative=false)
compare two matrices, returns the indices of the first element that fails the condition,...

◆ loadComponent()

void PoolSvc::loadComponent ( const std::string & compName)
overridevirtual
Returns
void
Parameters
compName[IN] string name of the component to be loaded.

Definition at line 363 of file PoolSvc.cxx.

363 {
364 m_context->loadComponent(compName);
365}

◆ lookupBestPfn()

void PoolSvc::lookupBestPfn ( const std::string & token,
std::string & pfn,
std::string & type ) const
overridevirtual
Returns
void
Parameters
token[IN] filename/token string to be translated
pfn[OUT] string PFN of database
type[OUT] string filetype of database

Definition at line 383 of file PoolSvc.cxx.

383 {
384 std::string dbID;
385 if (token.compare(0, 4, "PFN:") == 0) {
386 m_catalog->lookupFileByPFN(token.substr(4), dbID, type); // PFN -> FID
387 } else if (token.compare(0, 4, "LFN:") == 0) {
388 dbID = m_catalog->lookupLFN(token.substr(4)); // LFN -> FID
389 } else if (token.compare(0, 4, "FID:") == 0) {
390 dbID = token.substr(4);
391 } else if (token.size() > Guid::stringSize()) { // full token
392 Token tok;
393 tok.fromString(token);
394 dbID = tok.dbID().toString();
395 } else { // guid only
396 dbID = token;
397 }
398 m_catalog->getFirstPFN(dbID, pfn, type); // FID -> best PFN
399}
constexpr void toString(std::span< char, StrLen > buf, bool uppercase=true) const noexcept
Automatic conversion to string representation.
static constexpr int stringSize()
Definition Guid.h:61
Token & fromString(const std::string_view from)
Build from the string representation of a token.
Definition Token.cxx:169
const Guid & dbID() const
Access database identifier.
Definition Token.h:65

◆ patchCatalog()

void PoolSvc::patchCatalog ( const std::string & pfn,
pool::IDatabase & dbH ) const
private

Definition at line 504 of file PoolSvc.cxx.

504 {
505 std::scoped_lock lock(m_pool_mut);
507 std::string fid = dbH.fid();
508 pool::IFileCatalog* catalog_locked ATLAS_THREAD_SAFE = m_catalog;
509 catalog_locked->registerPFN(pfn, "ROOT_All", fid);
510}
virtual bool setTechnology(long technology)=0
Sets the technology identifier for this database.
virtual const std::string & fid()=0
Returns the file identifier of this database.

◆ poolCondPath()

std::string PoolSvc::poolCondPath ( const std::string & leaf)
private

Resolve a file using ATLAS_POOLCOND_PATH.

Definition at line 946 of file PoolSvc.cxx.

946 {
947 // look for files at $ATLAS_POOLCOND_PATH/<leaf>
948 // return full filename if exists, or empty string if not
949 const char* cpath = std::getenv("ATLAS_POOLCOND_PATH");
950 if (cpath && strcmp(cpath, "") != 0) {
951 const std::string testpath = std::string(cpath) + "/" + leaf;
952
953 // Try to open file for reading. Note that a simple stat call may return
954 // a wrong result if the file is residing on an auto-mounted FS (ATR-28801).
955 if (FILE* fp = std::fopen(testpath.c_str(), "r")) {
956 std::fclose(fp);
957 return testpath;
958 }
959 }
960 return {};
961}

◆ registerForWrite()

Token * PoolSvc::registerForWrite ( const Placement * placement,
const void * obj,
const RootType & classDesc )
overridevirtual
Returns
a token to a Data Object written to Pool.
Parameters
placement[IN] pointer to the placement hint.
obj[IN] pointer to the Data Object to be written to Pool.
classDesc[IN] pointer to the Seal class description for the Data Object.

Definition at line 252 of file PoolSvc.cxx.

254 {
255 unsigned int contextId = IPoolSvc::kOutputStream;
256 const std::string& auxString = placement->auxString();
257 if (!auxString.empty()) {
258 if (auxString.compare(0, 6, "[CTXT=") == 0) {
259 ::sscanf(auxString.c_str(), "[CTXT=%08X]", &contextId);
260 } else if (auxString.compare(0, 8, "[CLABEL=") == 0) {
261 contextId = this->getOutputContext(auxString);
262 }
263 if (contextId >= m_dbSessionVec.size()) {
264 ATH_MSG_WARNING("registerForWrite: Using default output Stream instead of id = " << contextId);
265 contextId = IPoolSvc::kOutputStream;
266 }
267 }
268 std::lock_guard<CallMutex> lock(*m_pers_mut[contextId]);
269 Token* token = m_dbSessionVec[contextId]->registerForWrite(*placement, obj, classDesc);
270 if (token == nullptr) {
271 ATH_MSG_WARNING("Cannot write object: " << placement->containerName());
272 }
273 return(token);
274}
const std::string & auxString() const
Access auxiliary string.
Definition Placement.h:41
const std::string & containerName() const
Access container name.
Definition Placement.h:33
virtual unsigned int getOutputContext(const std::string &label) override
Definition PoolSvc.cxx:304

◆ renamePfn()

void PoolSvc::renamePfn ( const std::string & pf,
const std::string & newpf )
overridevirtual
Returns
void
Parameters
pf[IN] filename to be renamed
newpf[IN] new filename

Definition at line 401 of file PoolSvc.cxx.

401 {
402 std::string dbID, type;
403 m_catalog->lookupFileByPFN(pf, dbID, type);
404 if (dbID.empty()) {
405 ATH_MSG_WARNING("Failed to lookup: " << pf << " in FileCatalog");
406 return;
407 }
408 m_catalog->lookupFileByPFN(newpf, dbID, type);
409 if (!dbID.empty()) {
410 ATH_MSG_INFO("Found: " << newpf << " in FileCatalog");
411 return;
412 }
413 m_catalog->renamePFN(pf, newpf);
414}

◆ setAttribute() [1/2]

StatusCode PoolSvc::setAttribute ( const std::string & optName,
const std::string & data,
long tech,
const std::string & dbName,
const std::string & contName = "",
unsigned int contextId = IPoolSvc::kOutputStream ) const
overridevirtual

Set POOL attributes - db/file, container/collection.

Definition at line 735 of file PoolSvc.cxx.

740 {
741 if (contextId >= m_dbSessionVec.size()) {
742 ATH_MSG_WARNING("setAttribute: Using default output Stream instead of id = " << contextId);
743 contextId = IPoolSvc::kOutputStream;
744 }
746 std::unique_ptr<pool::IDatabase> dbH = getDbHandle(contextId, dbName);
747 if (dbH == nullptr) {
748 ATH_MSG_DEBUG("Failed to get Session/DatabaseHandle to set POOL property.");
749 return(StatusCode::FAILURE);
750 }
751 if (dbH->openMode() == Io::INVALID) {
752 if (m_dbSessionVec[contextId]->transaction().type() == Io::WRITE || m_dbSessionVec[contextId]->transaction().type() == Io::APPEND) {
753 dbH->setTechnology(tech);
754 dbH->connectForWrite();
755 } else {
756 dbH->connectForRead();
757 }
758 }
759 bool retError = false;
760 std::string objName;
761 bool hasTTreeName = (contName.length() > 6 && contName.compare(0, 6, "TTree=") == 0);
762 if (contName.empty() || hasTTreeName || m_dbSessionVec[contextId]->transaction().type() == Io::READ) {
763 objName = hasTTreeName ? contName.substr(6) : contName;
764 if( !isNumber(data) ) {
765 retError = dbH->technologySpecificAttributes().setAttribute(optName, data.c_str(), objName);
766 } else if( data[data.size() - 1] == 'L' ) {
767 retError = dbH->technologySpecificAttributes().setAttribute<long long int>(optName, atoll(data.c_str()), objName);
768 } else {
769 retError = dbH->technologySpecificAttributes().setAttribute<int>(optName, atoi(data.c_str()), objName);
770 }
771 if (!retError) {
772 ATH_MSG_DEBUG("Failed to set POOL property, " << optName << " to " << data);
773 return(StatusCode::FAILURE);
774 }
775 } else {
776 std::unique_ptr<pool::IContainer> contH = getContainerHandle(dbH.get(), contName);
777 if (contH == nullptr) {
778 ATH_MSG_DEBUG("Failed to get ContainerHandle to set POOL property.");
779 return(StatusCode::FAILURE);
780 }
781 if (auto p = contName.find('('); p != std::string::npos) {
782 objName = contName.substr(p + 1); // Get BranchName between parenthesis
783 objName.erase(objName.find(')'));
784 } else if (auto p = contName.find("::"); p != std::string::npos) {
785 objName = contName.substr(p + 2); // Split off Tree name
786 } else if (auto p = contName.find('_'); p != std::string::npos) {
787 objName = contName.substr(p + 1); // Split off "POOLContainer"
788 objName.erase(objName.find('/')); // Split off key
789 }
790 std::string::size_type off = 0;
791 while ((off = objName.find_first_of("<>/")) != std::string::npos) {
792 objName[off] = '_'; // Replace special chars (e.g. templates)
793 }
794 if (data[data.size() - 1] == 'L') {
795 retError = contH->technologySpecificAttributes().setAttribute<long long int>(optName, atoll(data.c_str()), objName);
796 } else {
797 retError = contH->technologySpecificAttributes().setAttribute<int>(optName, atoi(data.c_str()), objName);
798 }
799 if (!retError) {
800 ATH_MSG_DEBUG("Failed to set POOL container property, " << optName << " for " << contName << " : " << objName << " to " << data);
801 return(StatusCode::FAILURE);
802 }
803 }
804 return(StatusCode::SUCCESS);
805}
bool isNumber(const std::string &s)
Definition PoolSvc.cxx:49
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...

◆ setAttribute() [2/2]

StatusCode PoolSvc::setAttribute ( const std::string & optName,
const std::string & data,
long tech,
unsigned int contextId = IPoolSvc::kOutputStream ) const
overridevirtual

Set POOL attributes - domain.

Definition at line 711 of file PoolSvc.cxx.

714 {
715 if (contextId >= m_dbSessionVec.size()) {
716 ATH_MSG_WARNING("setAttribute: Using default output Stream instead of id = " << contextId);
717 contextId = IPoolSvc::kOutputStream;
718 }
720 pool::ISession* sesH = m_dbSessionVec[contextId];
721 if (data[data.size() - 1] == 'L') {
722 if (!sesH->technologySpecificAttributes(tech).setAttribute<long long int>(optName, atoll(data.c_str()))) {
723 ATH_MSG_DEBUG("Failed to set POOL property, " << optName << " to " << data);
724 return(StatusCode::FAILURE);
725 }
726 } else {
727 if (!sesH->technologySpecificAttributes(tech).setAttribute<int>(optName, atoi(data.c_str()))) {
728 ATH_MSG_DEBUG("Failed to set POOL property, " << optName << " to " << data);
729 return(StatusCode::FAILURE);
730 }
731 }
732 return(StatusCode::SUCCESS);
733}
bool setAttribute(const std::string &attributeName, const T &atttibuteValue, const std::string &option="")
Templated method to set an attribute.

◆ setFrontierCache()

StatusCode PoolSvc::setFrontierCache ( const std::string & conn)
overridevirtual

Setup Frontier cache for given logical or physical connection name.

Definition at line 807 of file PoolSvc.cxx.

807 {
808 std::lock_guard<CallMutex> lock(m_pool_mut);
809 ATH_MSG_VERBOSE("setFrontierCache called for connection:" << conn);
810 // setup the Frontier cache information for the given logical or physical connection string
811 // first determine if the connection is logical (no ':')
812 std::vector<std::string> physcons;
813 if (conn.find(':') == std::string::npos) {
814 // if logical, have to lookup list of physical replicas, and consider each
815 // need the CORAL ILookupSvc interface which must be loaded if needed
816 const std::string lookSvcStr("CORAL/Services/XMLLookupService");
817 coral::IHandle<coral::ILookupService> lookSvcH = m_context->query<coral::ILookupService>();
818 if (!lookSvcH.isValid()) {
819 m_context->loadComponent(lookSvcStr);
820 lookSvcH = m_context->query<coral::ILookupService>();
821 }
822 if (!lookSvcH.isValid()) {
823 ATH_MSG_ERROR("Cannot locate " << lookSvcStr);
824 return(StatusCode::FAILURE);
825 }
826 coral::IDatabaseServiceSet* dbset = lookSvcH->lookup(conn, coral::ReadOnly);
827 if (dbset != nullptr) {
828 for (int irep = 0, nrep = dbset->numberOfReplicas(); irep < nrep; ++irep) {
829 const std::string pcon = dbset->replica(irep).connectionString();
830 if (pcon.compare(0, 9, "frontier:") == 0) {
831 physcons.push_back(std::move(pcon));
832 }
833 }
834 delete dbset; dbset = nullptr;
835 } else {
836 ATH_MSG_DEBUG("setFrontierCache: Could not find any replicas for " << conn);
837 }
838 } else if (conn.compare(0, 9, "frontier:") == 0) {
839 physcons.push_back(conn);
840 }
841 // check if any replicas will try and use frontier
842 if (physcons.size() == 0) {
843 return(StatusCode::SUCCESS);
844 }
845 coral::ConnectionService conSvcH;
846 // for each frontier replica, define the web cache info
847 // get the WebCacheControl interface via ConnectionSvc
848 // note ConnectionSvc should already be loaded by initialize
849 coral::IWebCacheControl& webCache = conSvcH.webCacheControl();
850 for (const auto& physcon : physcons) {
851 const auto& refreshList = m_frontierRefresh.value();
852 if (std::find(refreshList.begin(), refreshList.end(), physcon) == refreshList.end()
853 && std::find(refreshList.begin(), refreshList.end(), conn) == refreshList.end()) {
854 // set that a table DUMMYTABLE should be refreshed - indicates that everything
855 // else in the schema should not be
856 webCache.refreshTable(physcon, "DUMMYTABLE");
857 } else {
858 // set the schema to be refreshed
859 webCache.refreshSchemaInfo(physcon);
860 }
861 ATH_MSG_DEBUG("Cache flag for connection " << physcon << " set to " << webCache.webCacheInfo(physcon).isSchemaInfoCached());
862 }
863 return(StatusCode::SUCCESS);
864}
#define ATH_MSG_VERBOSE(x)
Gaudi::Property< std::vector< std::string > > m_frontierRefresh
Definition PoolSvc.h:263

◆ setObjPtr()

void PoolSvc::setObjPtr ( void *& obj,
const Token * token )
overridevirtual
Returns
void
Parameters
obj[OUT] pointer to the Data Object.
token[IN] token of the Data Object for which a Pool Ref is filled.

Definition at line 276 of file PoolSvc.cxx.

276 {
277 unsigned int contextId = IPoolSvc::kInputStream;
278 const std::string& auxString = token->auxString();
279 if (!auxString.empty()) {
280 if (auxString.compare(0, 6, "[CTXT=") == 0) {
281 ::sscanf(auxString.c_str(), "[CTXT=%08X]", &contextId);
282 } else if (auxString.compare(0, 8, "[CLABEL=") == 0) {
283 contextId = this->getInputContext(auxString);
284 }
285 if (contextId >= m_dbSessionVec.size()) {
286 ATH_MSG_WARNING("setObjPtr: Using default input Stream instead of id = " << contextId);
287 contextId = IPoolSvc::kInputStream;
288 }
289 }
290 ATH_MSG_VERBOSE("setObjPtr: token=" << token->toString() << ", auxString=" << auxString << ", contextID=" << contextId);
291 // Get Context ID/label from Token
292 std::lock_guard<CallMutex> lock(*m_pers_mut[contextId]);
293 obj = m_dbSessionVec[contextId]->readObject(*token, obj);
294 std::map<unsigned int, unsigned int>::const_iterator maxFileIter = m_contextMaxFile.find(contextId);
295 if (maxFileIter != m_contextMaxFile.end() && maxFileIter->second > 0) {
296 m_guidLists[contextId].remove(token->dbID());
297 m_guidLists[contextId].push_back(token->dbID());
298 while (m_guidLists[contextId].size() > maxFileIter->second) {
299 this->disconnectDb("FID:" + m_guidLists[contextId].begin()->toString(), contextId).ignore();
300 }
301 }
302}
const std::string & auxString() const
Access auxiliary string.
Definition Token.h:92
const std::string toString() const
Retrieve the string representation of the token.
Definition Token.cxx:135

◆ setShareMode()

void PoolSvc::setShareMode ( bool shareCat)
overridevirtual
Returns
void
Parameters
shareCat[IN] bool to share the file catalog.

Definition at line 367 of file PoolSvc.cxx.

367 {
368 m_shareCat = shareCat;
369}

◆ setupPersistencySvc()

StatusCode PoolSvc::setupPersistencySvc ( )
private

Definition at line 162 of file PoolSvc.cxx.

162 {
163 clearState();
164 ATH_MSG_INFO("Setting up FileCatalog and Streams");
166 if (m_catalog != nullptr) {
167 m_catalog->start();
168 } else {
169 ATH_MSG_FATAL("Failed to setup POOL File Catalog.");
170 return(StatusCode::FAILURE);
171 }
172 // Setup a persistency services
173 m_dbSessionVec.push_back(pool::createSession(*m_catalog).release()); // Read Service
174 m_pers_mut.push_back(new CallMutex);
175 if (!m_dbSessionVec[IPoolSvc::kInputStream]->technologySpecificAttributes(pool::ROOT_StorageType.type()).setAttribute<bool>("ENABLE_THREADSAFETY", true)) {
176 ATH_MSG_FATAL("Failed to enable thread safety in ROOT via PersistencySvc.");
177 return(StatusCode::FAILURE);
178 }
179 m_contextMaxFile.insert(std::pair<unsigned int, int>(IPoolSvc::kInputStream, m_dbAgeLimit));
180 if (!connect(Io::READ, IPoolSvc::kInputStream).isSuccess()) {
181 ATH_MSG_FATAL("Failed to connect Input PersistencySvc.");
182 return(StatusCode::FAILURE);
183 }
184 m_dbSessionVec.push_back(pool::createSession(*m_catalog).release()); // Write Service
185 m_pers_mut.push_back(new CallMutex);
186
187 return(StatusCode::SUCCESS);
188}
pool::IFileCatalog * createCatalog()
Definition PoolSvc.cxx:866
Gaudi::Property< int > m_dbAgeLimit
MaxFilesOpen, option to have PoolSvc limit the number of open Input Files: default = 0 (No files are ...
Definition PoolSvc.h:240

◆ start()

StatusCode PoolSvc::start ( )
overridevirtual

Required of all Gaudi services:

Definition at line 190 of file PoolSvc.cxx.

190 {
191 // Switiching on ROOT implicit multi threading for AthenaMT
192 if (m_useROOTIMT && Gaudi::Concurrency::ConcurrencyFlags::numThreads() > 1) {
193 if (!m_dbSessionVec[IPoolSvc::kInputStream]->technologySpecificAttributes(pool::ROOT_StorageType.type()).setAttribute<int>("ENABLE_IMPLICITMT", Gaudi::Concurrency::ConcurrencyFlags::numThreads() - 1)) {
194 ATH_MSG_FATAL("Failed to enable implicit multithreading in ROOT via PersistencySvc.");
195 return(StatusCode::FAILURE);
196 }
197 ATH_MSG_INFO("Enabled implicit multithreading in ROOT via PersistencySvc to: " << Gaudi::Concurrency::ConcurrencyFlags::numThreads() - 1);
198 }
199 return(StatusCode::SUCCESS);
200}
Gaudi::Property< bool > m_useROOTIMT
Use ROOT Implicit MultiThreading, default = true.
Definition PoolSvc.h:247

◆ startCatalog()

void PoolSvc::startCatalog ( )
overridevirtual
Returns
void

Definition at line 371 of file PoolSvc.cxx.

371 {
372 if (m_catalog != nullptr) {
373 m_catalog->start();
374 }
375}

◆ stop()

StatusCode PoolSvc::stop ( )
overridevirtual

Definition at line 202 of file PoolSvc.cxx.

202 {
203 ATH_MSG_VERBOSE("stop()");
204 bool retError = false;
205 for (unsigned int contextId = 0, imax = m_dbSessionVec.size(); contextId < imax; contextId++) {
206 if (!disconnect(contextId).isSuccess()) {
207 ATH_MSG_FATAL("Cannot disconnect Stream: " << contextId);
208 retError = true;
209 }
210 }
211 return(retError ? StatusCode::FAILURE : StatusCode::SUCCESS);
212}

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::map<unsigned int, std::list<Guid> > m_guidLists PoolSvc::ATLAS_THREAD_SAFE
mutableprivate

Definition at line 235 of file PoolSvc.h.

◆ m_attemptCatalogPatch

Gaudi::Property<bool> PoolSvc::m_attemptCatalogPatch {this,"AttemptCatalogPatch",true}
private

AttemptCatalogPatch, option to create catalog: default = false.

Definition at line 252 of file PoolSvc.h.

252{this,"AttemptCatalogPatch",true};

◆ m_catalog

pool::IFileCatalog* PoolSvc::m_catalog {nullptr}
private

Definition at line 227 of file PoolSvc.h.

227{nullptr};

◆ m_connClean

Gaudi::Property<bool> PoolSvc::m_connClean {this,"ConnectionCleanUp",false}
private

ConnectionCleanUp - whether to use CORAL connection management thread: default = false.

Definition at line 260 of file PoolSvc.h.

260{this,"ConnectionCleanUp",false};

◆ m_context

coral::Context* PoolSvc::m_context {nullptr}
private

Definition at line 225 of file PoolSvc.h.

225{nullptr};

◆ m_contextMaxFile

std::map<unsigned int, unsigned int> PoolSvc::m_contextMaxFile
private

Definition at line 233 of file PoolSvc.h.

◆ m_dbAgeLimit

Gaudi::Property<int> PoolSvc::m_dbAgeLimit {this,"MaxFilesOpen",0}
private

MaxFilesOpen, option to have PoolSvc limit the number of open Input Files: default = 0 (No files are closed automatically).

Definition at line 240 of file PoolSvc.h.

240{this,"MaxFilesOpen",0};

◆ m_dbSessionVec

std::vector<pool::ISession*> PoolSvc::m_dbSessionVec
private

Definition at line 228 of file PoolSvc.h.

◆ m_frontierComp

Gaudi::Property<int> PoolSvc::m_frontierComp {this,"FrontierCompression",5}
private

Frontier proprties, compression level and list of schemas to be refreshed: default = 5.

Definition at line 262 of file PoolSvc.h.

262{this,"FrontierCompression",5};

◆ m_frontierRefresh

Gaudi::Property<std::vector<std::string> > PoolSvc::m_frontierRefresh {this,"FrontierRefreshSchema",{}}
private

Definition at line 263 of file PoolSvc.h.

263{this,"FrontierRefreshSchema",{}};

◆ m_inputContextLabel

std::map<std::string, unsigned int> PoolSvc::m_inputContextLabel
private

Definition at line 230 of file PoolSvc.h.

◆ m_mainOutputLabel

std::string PoolSvc::m_mainOutputLabel {}
private

Definition at line 232 of file PoolSvc.h.

232{};

◆ m_outputContextLabel

std::map<std::string, unsigned int> PoolSvc::m_outputContextLabel
private

Definition at line 231 of file PoolSvc.h.

◆ m_pers_mut

std::vector<CallMutex*> PoolSvc::m_pers_mut
private

Definition at line 229 of file PoolSvc.h.

◆ m_pool_mut

CallMutex PoolSvc::m_pool_mut
mutableprivate

Definition at line 224 of file PoolSvc.h.

◆ m_readCatalog

Gaudi::Property<std::vector<std::string> > PoolSvc::m_readCatalog {this,"ReadCatalog",{},"List of catalog files to read from","OrderedSet<std::string>"}
private

ReadCatalog, the list of additional POOL input file catalogs to consult: default = empty vector.

Definition at line 245 of file PoolSvc.h.

245{this,"ReadCatalog",{},"List of catalog files to read from","OrderedSet<std::string>"};

◆ m_retrialPeriod

Gaudi::Property<int> PoolSvc::m_retrialPeriod {this,"ConnectionRetrialPeriod",300}
private

ConnectionRetrialPeriod, retry period for CORAL Connection Service: default = 30 seconds.

Definition at line 254 of file PoolSvc.h.

254{this,"ConnectionRetrialPeriod",300};

◆ m_retrialTimeOut

Gaudi::Property<int> PoolSvc::m_retrialTimeOut {this,"ConnectionRetrialTimeOut",3600}
private

ConnectionRetrialTimeOut, the retrial time out for CORAL Connection Service: default = 300 seconds.

Definition at line 256 of file PoolSvc.h.

256{this,"ConnectionRetrialTimeOut",3600};

◆ m_shareCat

bool PoolSvc::m_shareCat {false}
private

Definition at line 226 of file PoolSvc.h.

226{false};

◆ m_timeOut

Gaudi::Property<int> PoolSvc::m_timeOut {this,"ConnectionTimeOut",5}
private

ConnectionTimeOut, the time out for CORAL Connection Service: default = 5 seconds.

Definition at line 258 of file PoolSvc.h.

258{this,"ConnectionTimeOut",5};

◆ m_useROOTIMT

Gaudi::Property<bool> PoolSvc::m_useROOTIMT {this,"UseROOTImplicitMT",true}
private

Use ROOT Implicit MultiThreading, default = true.

Definition at line 247 of file PoolSvc.h.

247{this,"UseROOTImplicitMT",true};

◆ m_useROOTMaxTree

Gaudi::Property<bool> PoolSvc::m_useROOTMaxTree {this,"UseROOTIncreaseVMaxTree",false}
private

Increase virtual TTree size to avoid backreads in multithreading, default = false.

Definition at line 249 of file PoolSvc.h.

249{this,"UseROOTIncreaseVMaxTree",false};

◆ m_writeCatalog

Gaudi::Property<std::string> PoolSvc::m_writeCatalog {this,"WriteCatalog","xmlcatalog_file:PoolFileCatalog.xml"}
private

WriteCatalog, the file catalog to be used to register output files (also default input catalog): default = "" (use POOL default).

Definition at line 243 of file PoolSvc.h.

243{this,"WriteCatalog","xmlcatalog_file:PoolFileCatalog.xml"};

The documentation for this class was generated from the following files: