ATLAS Offline Software
PoolSvc.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef POOLSVC_H
6 #define POOLSVC_H
7 
13 #include "PoolSvc/IPoolSvc.h"
14 #include "GaudiKernel/IIoComponent.h"
18 
19 #include <string>
20 #include <vector>
21 #include <map>
22 #include <mutex>
23 
24 // Forward declarations
25 namespace pool {
26  class IContainer;
27  class IDatabase;
28  class IPersistencySvc;
29 }
30 
31 template <class TYPE> class SvcFactory;
32 
36 class PoolSvc : public ::AthService, virtual public IPoolSvc, virtual public IIoComponent {
37  // Allow the factory class access to the constructor
38  friend class SvcFactory<PoolSvc>;
39 
40 public: // Non-static members
42  virtual StatusCode initialize() override;
43  virtual StatusCode io_reinit() override;
45  virtual StatusCode start() override;
46  virtual StatusCode stop() override;
48  virtual StatusCode finalize() override;
49  virtual StatusCode io_finalize() override;
51  virtual StatusCode queryInterface(const InterfaceID& riid, void** ppvInterface) override;
52 
57  virtual
58  Token* registerForWrite(const Placement* placement,
59  const void* obj,
60  const RootType& classDesc) override;
61 
65  virtual
66  void setObjPtr(void*& obj, const Token* token) override;
67 
70  virtual
71  unsigned int getOutputContext(const std::string& label) override;
72 
76  virtual
77  unsigned int getInputContext(const std::string& label,
78  unsigned int maxFile = 0) override;
79 
81  virtual
82  const std::map<std::string, unsigned int>& getInputContextMap() const override;
83 
85  virtual
86  const coral::Context* context() const override;
87 
90  virtual
91  void loadComponent(const std::string& compName) override;
92 
95  virtual
96  void setShareMode(bool shareCat) override;
97 
99  virtual
100  const pool::IFileCatalog* catalog() const override;
101 
106  virtual
107  void lookupBestPfn(const std::string& token, std::string& pfn, std::string& type) const override;
108 
112  virtual
113  void renamePfn(const std::string& pf, const std::string& newpf) override;
114 
120  virtual
121  pool::ICollection* createCollection(const std::string& collectionType,
122  const std::string& connection,
123  const std::string& collectionName,
124  unsigned int contextId = IPoolSvc::kInputStream) const override;
125 
130  virtual
131  Token* getToken(const std::string& connection,
132  const std::string& collection,
133  const unsigned long ientry) const override;
134 
136  virtual
138  unsigned int contextId = IPoolSvc::kInputStream) override;
139 
142  virtual
143  StatusCode commit(unsigned int contextId = IPoolSvc::kInputStream) const override;
144 
147  virtual
148  StatusCode commitAndHold(unsigned int contextId = IPoolSvc::kInputStream) const override;
149 
152  virtual
153  StatusCode disconnect(unsigned int contextId = IPoolSvc::kInputStream) const override;
154 
158  virtual
159  StatusCode disconnectDb(const std::string& connection,
160  unsigned int contextId = IPoolSvc::kInputStream) const override;
161 
163  virtual
164  long long int getFileSize(const std::string& dbName, long tech, unsigned int contextId) const override;
165 
167  virtual
168  StatusCode getAttribute(const std::string& optName,
169  std::string& data,
170  long tech,
171  unsigned int contextId = IPoolSvc::kInputStream) const override;
172 
174  virtual
175  StatusCode getAttribute(const std::string& optName,
176  std::string& data,
177  long tech,
178  const std::string& dbName,
179  const std::string& contName = "",
180  unsigned int contextId = IPoolSvc::kInputStream) const override;
181 
183  virtual
184  StatusCode setAttribute(const std::string& optName,
185  const std::string& data,
186  long tech,
187  unsigned int contextId = IPoolSvc::kOutputStream) const override;
188 
190  virtual
191  StatusCode setAttribute(const std::string& optName,
192  const std::string& data,
193  long tech,
194  const std::string& dbName,
195  const std::string& contName = "",
196  unsigned int contextId = IPoolSvc::kOutputStream) const override;
197 
199  virtual
200  StatusCode setFrontierCache(const std::string& conn) override;
201 
204  //PoolSvc(const std::string& name, ISvcLocator* pSvcLocator);
206  virtual ~PoolSvc();
207 
208 private: // data
209  typedef std::recursive_mutex CallMutex;
211  coral::Context* m_context{nullptr};
212  bool m_shareCat{false};
214  std::vector<pool::IPersistencySvc*> m_persistencySvcVec;
215  std::vector<CallMutex*> m_pers_mut;
216  std::map<std::string, unsigned int> m_inputContextLabel;
217  std::map<std::string, unsigned int> m_outputContextLabel;
218  std::string m_mainOutputLabel{};
219  std::map<unsigned int, unsigned int> m_contextMaxFile;
220  // Cache for open file guids for each m_persistencySvcVec member, protected by m_pers_mut
221  mutable std::map<unsigned int, std::list<Guid> > m_guidLists ATLAS_THREAD_SAFE;
222 
223 private: // properties
225  StringProperty m_fileOpen{this,"FileOpen","overwrite"};
228  IntegerProperty m_dbAgeLimit{this,"MaxFilesOpen",0};
231  StringProperty m_writeCatalog{this,"WriteCatalog","xmlcatalog_file:PoolFileCatalog.xml"};
233  StringArrayProperty m_readCatalog{this,"ReadCatalog",{},"List of catalog files to read from","OrderedSet<std::string>"};
235  BooleanProperty m_useROOTIMT{this,"UseROOTImplicitMT",true};
237  BooleanProperty m_useROOTMaxTree{this,"UseROOTIncreaseVMaxTree",false};
238 
240  BooleanProperty m_attemptCatalogPatch{this,"AttemptCatalogPatch",true};
242  IntegerProperty m_retrialPeriod{this,"ConnectionRetrialPeriod",300};
244  IntegerProperty m_retrialTimeOut{this,"ConnectionRetrialTimeOut",3600};
246  IntegerProperty m_timeOut{this,"ConnectionTimeOut",5};
248  BooleanProperty m_connClean{this,"ConnectionCleanUp",false};
250  IntegerProperty m_frontierComp{this,"FrontierCompression",5};
251  StringArrayProperty m_frontierRefresh{this,"FrontierRefreshSchema",{}};
253  BooleanProperty m_sortReplicas{this,"SortReplicas",true};
254 
255 private: // internal helper functions
256  // delete all APR::Persistency Services, Catalog, Mutexes and Indexes
257  void clearState();
258 
260  void patchCatalog(const std::string& pfn, pool::IDatabase& dbH) const;
261 
262  // setup APR persistency
264 
266  std::unique_ptr<pool::IDatabase> getDbHandle(unsigned int contextId, const std::string& dbName) const;
268  std::unique_ptr<pool::IContainer> getContainerHandle(pool::IDatabase* dbH, const std::string& contName) const;
269 
271  std::string poolCondPath(const std::string& leaf);
272 };
273 #endif
AthService::AthService
AthService()
PoolSvc::stop
virtual StatusCode stop() override
Definition: PoolSvc.cxx:230
PoolSvc::m_timeOut
IntegerProperty m_timeOut
ConnectionTimeOut, the time out for CORAL Connection Service: default = 5 seconds.
Definition: PoolSvc.h:246
PoolSvc::queryInterface
virtual StatusCode queryInterface(const InterfaceID &riid, void **ppvInterface) override
Required of all Gaudi services: see Gaudi documentation for details.
Definition: PoolSvc.cxx:278
IPoolSvc::kOutputStream
@ kOutputStream
Definition: IPoolSvc.h:40
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
AddEmptyComponent.compName
compName
Definition: AddEmptyComponent.py:32
Placement
This class holds all the necessary information to guide the writing of an object in a physical place.
Definition: Placement.h:19
PoolSvc::ATLAS_THREAD_SAFE
std::map< unsigned int, std::list< Guid > > m_guidLists ATLAS_THREAD_SAFE
Definition: PoolSvc.h:221
IPoolSvc
This class provides the interface to the LCG POOL persistency software.
Definition: IPoolSvc.h:36
checkCorrelInHIST.conn
conn
Definition: checkCorrelInHIST.py:25
PoolSvc::getDbHandle
std::unique_ptr< pool::IDatabase > getDbHandle(unsigned int contextId, const std::string &dbName) const
Get Database handle.
Definition: PoolSvc.cxx:996
PoolSvc::m_retrialTimeOut
IntegerProperty m_retrialTimeOut
ConnectionRetrialTimeOut, the retrial time out for CORAL Connection Service: default = 300 seconds.
Definition: PoolSvc.h:244
PoolSvc::m_pool_mut
CallMutex m_pool_mut
Definition: PoolSvc.h:210
PoolSvc::m_fileOpen
StringProperty m_fileOpen
FileOpen, the open mode for the file ("append" or "overwrite").
Definition: PoolSvc.h:225
PoolSvc::m_frontierComp
IntegerProperty m_frontierComp
Frontier proprties, compression level and list of schemas to be refreshed: default = 5.
Definition: PoolSvc.h:250
PoolSvc::m_inputContextLabel
std::map< std::string, unsigned int > m_inputContextLabel
Definition: PoolSvc.h:216
PoolSvc::connect
virtual StatusCode connect(pool::ITransaction::Type type, unsigned int contextId=IPoolSvc::kInputStream) override
Connect to a logical database unit; PersistencySvc is chosen according to transaction type (accessmod...
Definition: PoolSvc.cxx:599
PoolSvc::commit
virtual StatusCode commit(unsigned int contextId=IPoolSvc::kInputStream) const override
Commit data for a given contextId and flush buffer.
Definition: PoolSvc.cxx:631
PoolSvc::m_attemptCatalogPatch
BooleanProperty m_attemptCatalogPatch
AttemptCatalogPatch, option to create catalog: default = false.
Definition: PoolSvc.h:240
PlotCalibFromCool.label
label
Definition: PlotCalibFromCool.py:78
SvcFactory
Definition: AthCnvSvc.h:28
pool
pool namespace
Definition: libname.h:15
PoolSvc::catalog
virtual const pool::IFileCatalog * catalog() const override
Definition: PoolSvc.cxx:409
PoolSvc::disconnect
virtual StatusCode disconnect(unsigned int contextId=IPoolSvc::kInputStream) const override
Disconnect PersistencySvc associated with a contextId.
Definition: PoolSvc.cxx:664
PoolSvc::m_frontierRefresh
StringArrayProperty m_frontierRefresh
Definition: PoolSvc.h:251
PoolSvc
This class provides the interface to the LCG POOL persistency software.
Definition: PoolSvc.h:36
PoolSvc::m_context
coral::Context * m_context
Definition: PoolSvc.h:211
PoolSvc::setAttribute
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:796
PoolSvc::getFileSize
virtual long long int getFileSize(const std::string &dbName, long tech, unsigned int contextId) const override
Get POOL FileSize attribute for database without logging a message.
Definition: PoolSvc.cxx:704
PoolSvc::m_writeCatalog
StringProperty m_writeCatalog
WriteCatalog, the file catalog to be used to register output files (also default input catalog): defa...
Definition: PoolSvc.h:231
PoolSvc::setObjPtr
virtual void setObjPtr(void *&obj, const Token *token) override
Definition: PoolSvc.cxx:313
PoolSvc::m_useROOTMaxTree
BooleanProperty m_useROOTMaxTree
Increase virtual TTree size to avoid backreads in multithreading, default = false.
Definition: PoolSvc.h:237
pool::ITransaction::Type
Type
Transaction type enumeration.
Definition: ITransaction.h:28
Token
This class provides a token that identifies in a unique way objects on the persistent storage.
Definition: Token.h:21
PoolSvc::renamePfn
virtual void renamePfn(const std::string &pf, const std::string &newpf) override
Definition: PoolSvc.cxx:431
PoolSvc::CallMutex
std::recursive_mutex CallMutex
Definition: PoolSvc.h:209
PoolSvc::m_pers_mut
std::vector< CallMutex * > m_pers_mut
Definition: PoolSvc.h:215
IPoolSvc::kInputStream
@ kInputStream
Definition: IPoolSvc.h:40
PoolSvc::m_mainOutputLabel
std::string m_mainOutputLabel
Definition: PoolSvc.h:218
pool::IFileCatalog
Definition: IFileCatalog.h:23
PoolSvc::context
virtual const coral::Context * context() const override
Definition: PoolSvc.cxx:397
PoolSvc::getOutputContext
virtual unsigned int getOutputContext(const std::string &label) override
Definition: PoolSvc.cxx:341
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
PoolSvc::getContainerHandle
std::unique_ptr< pool::IContainer > getContainerHandle(pool::IDatabase *dbH, const std::string &contName) const
Get Container handle.
Definition: PoolSvc.cxx:1026
AthService
Definition: AthService.h:32
PixelModuleFeMask_create_db.dbName
string dbName
Definition: PixelModuleFeMask_create_db.py:21
PoolSvc::getToken
virtual Token * getToken(const std::string &connection, const std::string &collection, const unsigned long ientry) const override
Definition: PoolSvc.cxx:575
PoolSvc::disconnectDb
virtual StatusCode disconnectDb(const std::string &connection, unsigned int contextId=IPoolSvc::kInputStream) const override
Disconnect single Database.
Definition: PoolSvc.cxx:686
PoolSvc::createCollection
virtual pool::ICollection * createCollection(const std::string &collectionType, const std::string &connection, const std::string &collectionName, unsigned int contextId=IPoolSvc::kInputStream) const override
Definition: PoolSvc.cxx:446
PoolSvc::commitAndHold
virtual StatusCode commitAndHold(unsigned int contextId=IPoolSvc::kInputStream) const override
Commit data for a given contextId and hold buffer.
Definition: PoolSvc.cxx:649
PoolSvc::m_sortReplicas
BooleanProperty m_sortReplicas
Use DBReplicaSvc to sort database connections, default = true.
Definition: PoolSvc.h:253
PoolSvc::setFrontierCache
virtual StatusCode setFrontierCache(const std::string &conn) override
Setup Frontier cache for given logical or physical connection name.
Definition: PoolSvc.cxx:892
PoolSvc::clearState
void clearState()
Definition: PoolSvc.cxx:242
PoolSvc::getAttribute
virtual StatusCode getAttribute(const std::string &optName, std::string &data, long tech, unsigned int contextId=IPoolSvc::kInputStream) const override
Get POOL attributes - domain.
Definition: PoolSvc.cxx:722
PoolSvc::m_catalog
pool::IFileCatalog * m_catalog
Definition: PoolSvc.h:213
PoolSvc::m_contextMaxFile
std::map< unsigned int, unsigned int > m_contextMaxFile
Definition: PoolSvc.h:219
pool::IDatabase
Definition: IDatabase.h:25
PoolSvc::m_readCatalog
StringArrayProperty m_readCatalog
ReadCatalog, the list of additional POOL input file catalogs to consult: default = empty vector.
Definition: PoolSvc.h:233
PoolSvc::m_dbAgeLimit
IntegerProperty m_dbAgeLimit
MaxFilesOpen, option to have PoolSvc limit the number of open Input Files: default = 0 (No files are ...
Definition: PoolSvc.h:228
PoolSvc::m_shareCat
bool m_shareCat
Definition: PoolSvc.h:212
PoolSvc::patchCatalog
void patchCatalog(const std::string &pfn, pool::IDatabase &dbH) const
Definition: PoolSvc.cxx:567
IPoolSvc.h
This file contains the class definition for the IPoolSvc interface class.
PoolSvc::loadComponent
virtual void loadComponent(const std::string &compName) override
Definition: PoolSvc.cxx:401
PoolSvc::getInputContextMap
virtual const std::map< std::string, unsigned int > & getInputContextMap() const override
Definition: PoolSvc.cxx:393
PoolSvc::poolCondPath
std::string poolCondPath(const std::string &leaf)
Resolve a file using ATLAS_POOLCOND_PATH.
Definition: PoolSvc.cxx:1043
PoolSvc::lookupBestPfn
virtual void lookupBestPfn(const std::string &token, std::string &pfn, std::string &type) const override
Definition: PoolSvc.cxx:413
PoolSvc::registerForWrite
virtual Token * registerForWrite(const Placement *placement, const void *obj, const RootType &classDesc) override
Definition: PoolSvc.cxx:289
PoolSvc::finalize
virtual StatusCode finalize() override
Required of all Gaudi services:
Definition: PoolSvc.cxx:261
PoolSvc::setShareMode
virtual void setShareMode(bool shareCat) override
Definition: PoolSvc.cxx:405
PoolSvc::start
virtual StatusCode start() override
Required of all Gaudi services:
Definition: PoolSvc.cxx:218
python.output.AtlRunQueryRoot.pf
pf
Definition: AtlRunQueryRoot.py:988
PoolSvc::initialize
virtual StatusCode initialize() override
Required of all Gaudi services:
Definition: PoolSvc.cxx:57
PoolSvc::m_persistencySvcVec
std::vector< pool::IPersistencySvc * > m_persistencySvcVec
Definition: PoolSvc.h:214
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
PoolSvc::setupPersistencySvc
StatusCode setupPersistencySvc()
Definition: PoolSvc.cxx:184
PoolSvc::~PoolSvc
virtual ~PoolSvc()
Destructor.
Definition: PoolSvc.cxx:993
AthService.h
PoolSvc::m_retrialPeriod
IntegerProperty m_retrialPeriod
ConnectionRetrialPeriod, retry period for CORAL Connection Service: default = 30 seconds.
Definition: PoolSvc.h:242
PoolSvc::createCatalog
pool::IFileCatalog * createCatalog()
Definition: PoolSvc.cxx:953
PoolSvc::io_reinit
virtual StatusCode io_reinit() override
Definition: PoolSvc.cxx:143
Guid.h
This file contains the class definition for the Guid class (migrated from POOL).
checker_macros.h
Define macros for attributes used to control the static checker.
python.PyAthena.obj
obj
Definition: PyAthena.py:135
PoolSvc::getInputContext
virtual unsigned int getInputContext(const std::string &label, unsigned int maxFile=0) override
Definition: PoolSvc.cxx:368
PoolSvc::m_connClean
BooleanProperty m_connClean
ConnectionCleanUp - whether to use CORAL connection management thread: default = false.
Definition: PoolSvc.h:248
pool::ICollection
Definition: ICollection.h:24
PoolSvc::io_finalize
virtual StatusCode io_finalize() override
Definition: PoolSvc.cxx:266
PoolSvc::m_useROOTIMT
BooleanProperty m_useROOTIMT
Use ROOT Implicit MultiThreading, default = true.
Definition: PoolSvc.h:235
PoolSvc::m_outputContextLabel
std::map< std::string, unsigned int > m_outputContextLabel
Definition: PoolSvc.h:217
TScopeAdapter
Definition: RootType.h:119