ATLAS Offline Software
Loading...
Searching...
No Matches
IOVDbSvc.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
15
16#ifndef IOVDbSvc_IOVDbSvc_h
17#define IOVDbSvc_IOVDbSvc_h
18
19#include "IOVDbConn.h"
20#include "IOVDbFolder.h"
21
22#include "GaudiKernel/StatusCode.h"
23#include "GaudiKernel/ClassID.h"
24#include "GaudiKernel/IIncidentListener.h"
25#include "GaudiKernel/ServiceHandle.h"
26#include "GaudiKernel/ToolHandle.h"
27#include "GaudiKernel/IAddressCreator.h"
28#include "GaudiKernel/IIoComponent.h"
29
35#include "CoolKernel/IDatabase.h"
36#include "CoolKernel/ValidityKey.h"
40#include "PoolSvc/IPoolSvc.h"
41
42#include <string>
43#include <vector>
44#include <map>
45#include <memory>
46
47class IOVRange;
48class StoreGateSvc;
49class IClassIDSvc;
50class EventID;
53
66class IOVDbSvc : public extends<AthService,
67 IIOVCondDbSvc,
68 IIOVDbSvc,
69 IAddressProvider,
70 IIncidentListener,
71 IIoComponent>
72{
73public:
74
76 using base_class::base_class;
77
79 virtual StatusCode initialize() override;
80 StatusCode io_reinit() override final;
81
83 virtual StatusCode finalize() override;
84 StatusCode io_finalize() override final;
85
86 // IIOVDbSvc interface
87
89 virtual cool::IDatabasePtr getDatabase( bool readOnly ) override;
90
93
95
96
97 virtual StatusCode preLoadAddresses( StoreID::type storeID,
98 tadList& list ) override;
99
101 virtual StatusCode loadAddresses( StoreID::type storeID,
102 tadList& list ) override;
103
105 virtual StatusCode updateAddress( StoreID::type storeID,
107 const EventContext& ctx ) override;
109
110
112
113
115 virtual StatusCode getRange( const CLID& clid,
116 const std::string& dbKey,
117 const IOVTime& time,
118 IOVRange& range,
119 std::string& tag,
120 std::unique_ptr<IOpaqueAddress>& ioa) override;
121
122
123
125 virtual StatusCode setRange( const CLID& clid,
126 const std::string& dbKey,
127 const IOVRange& range,
128 const std::string& tag ) override;
129
131 virtual StatusCode signalBeginRun(const IOVTime& beginRunTime,
132 const EventContext& ctx) override;
133
135 virtual void signalEndProxyPreload() override;
137
139 virtual void postConditionsLoad() override;
140
142 virtual void handle( const Incident& incident ) override;
143
145 virtual StatusCode processTagInfo() override;
146
147 // return list of SG keys being provided by IOVDbSvc
148 virtual std::vector<std::string> getKeyList() override;
149
152 virtual
153 bool getKeyInfo(const std::string& key, IIOVDbSvc::KeyInfo& info) override;
154
155 // drop an IOVDbSvc-managed object from Storegate, indicating we will
156 // not read it again and can free up memory
157 // If resetCache=True, also drop the corresponding folder cache
158 // so any subsequent reads will access the database again
159 // returns False if key not known to IOVDbSvc
160 virtual
161 bool dropObject(const std::string& key,const bool resetCache=false) override;
162
163
164private:
165 // internal methods
166 StatusCode checkConfigConsistency() const;
167 StatusCode checkEventSel();
168 StatusCode setupFolders();
169 StatusCode fillTagInfo();
170 StatusCode loadCaches(IOVDbConn* conn, const IOVTime* time=nullptr);
171
172 // job option parameters
173 // default database connection
174 Gaudi::Property<std::string> m_par_defaultConnection{this,"dbConnection","sqlite://;schema=cooldummy.db;dbname=OFLP200","default DB connection string"};
175 // IOVDbSvc global tag
176 Gaudi::Property<std::string> m_par_globalTag{this,"GlobalTag","","Global database tag"};
177 // production database instance, used to cross-check global tag
178 Gaudi::Property<std::string> m_par_dbinst{this,"DBInstance","","Database instance (like OFLP200)"};
179 // a list of folders to preload
180 Gaudi::Property<std::vector<std::string> > m_par_folders{this,"Folders",{},"List of database folders to preload","OrderedSet<std::string>"};
181 // a list of overriding tags definitions
182 Gaudi::Property<std::vector<std::string> > m_par_overrideTags{this,"overrideTags",{},"List of xml-modifiers for folders like <prefix>/My/Folder</prefix><tag>MyFolderTag</tag>","OrderedSet<std::string>"};
183 // a list of folders to write to file meta data
184 Gaudi::Property<std::vector<std::string> > m_par_foldersToWrite{this,"FoldersToMetaData",{},"list of folders to write to file meta data","OrderedSet<std::string>"};
185 // a flag to trigger the connections management
186 BooleanProperty m_par_manageConnections{this,"ManageConnections",true,"flag to trigger the connections management"};
187 // a flag to manage pool connections
188 BooleanProperty m_par_managePoolConnections{this,"ManagePoolConnections",true,"flag to manage pool connections"};
189 // a global force run number
190 IntegerProperty m_par_forceRunNumber{this,"forceRunNumber",0,"globally force run-number (default: no force)"};
191 // a global force lumiblock number
192 IntegerProperty m_par_forceLumiblockNumber{this,"forceLumiblockNumber",0,"globally force LB-number (default: no force)"};
193 // a global force timestamp
194 IntegerProperty m_par_forceTimestamp{this,"forceTimeStamp",0,"globally force time-stamp (default: no force)"};
195 // max number of pool files open allowed
196 IntegerProperty m_par_maxNumPoolFiles{this,"MaxPoolFilesOpen",5,"max number of pool files open allowed (0 means no limit)"};
197 // timestampslop - backdata timestamp IOVs by this many seconds
198 FloatProperty m_par_timeStampSlop{this,"TimeStampSlop",0.0,"backdata timestamp IOVs by this many seconds"};
199 // force larger numbers of runs to be cached
200 IntegerProperty m_par_cacheRun{this,"CacheRun",0,"force larger numbers of runs to be cached"};
201 // force larger timeranges to be cached (seconds)
202 IntegerProperty m_par_cacheTime{this,"CacheTime",0,"force larger timeranges to be cached (seconds)"};
203 // cache alignment - divide cache into N slices and align queries on slice
204 // should be useful to improve Frontier cache hit rate
205 UnsignedIntegerProperty m_par_cacheAlign{this,"CacheAlign",0,"cache alignment - divide cache into N slices and align queries on slice"};
206 // online mode flag to ignore missing channels outside cache range
207 BooleanProperty m_par_onlineMode{this,"OnlineMode",false,"online mode flag to ignore missing channels outside cache range"};
208 // check to ensure global/HVS tags are locked (for production)
209 BooleanProperty m_par_checklock{this,"CheckLock",false,"check to ensure global/HVS tags are locked (for production)"};
210 // Source of data as a string; default is "COOL_DATABASE"
211 StringProperty m_par_source{this,"Source","COOL_DATABASE","source of data as a string (default COOL_DATABASE)"};
212 // CREST Server URL with host number; default is "http://crest-undertow-api.web.cern.ch"
213 StringProperty m_par_crestServer{this,"crestServer","https://crest.cern.ch","CREST URL with the port number as a string (default https://crest.cern.ch)"};
214 // This map contains the pairs: COOL folder - CREST tag name
215 std::map<std::string, std::string> m_cresttagmap;
216 // Format of data; default is empty string (default for a given source)
217 StringProperty m_par_format{this,"Format",{},"Format of data; default is empty string (default for a given source)"};
218 // Can output to file for debugging purposes
219 BooleanProperty m_outputToFile{this,"OutputToFile",false,"output to file for debugging purposes"};
220 BooleanProperty m_crestCoolToFile{this,"CrestCoolToFile",false,"output to file crest or cool data in the same format for debugging purposes"};
221 // internal parameters
222 // handles to other services and tools
223 ServiceHandle<IIOVSvc> m_h_IOVSvc{this,"IOVSvc","IOVSvc"};
224 ServiceHandle<StoreGateSvc> m_h_sgSvc{this,"StoreGateSvc","StoreGateSvc"};
225 ServiceHandle<StoreGateSvc> m_h_detStore{this,"DetectorStore","DetectorStore"};
226 ServiceHandle<StoreGateSvc> m_h_metaDataStore{this,"MetaDataStore","StoreGateSvc/MetaDataStore"};
227 ServiceHandle<IAddressCreator> m_h_persSvc{this,"EventPersistencySvc","EventPersistencySvc"};
228 ServiceHandle<IClassIDSvc> m_h_clidSvc{this,"ClassIDSvc","ClassIDSvc"};
229 ServiceHandle<IPoolSvc> m_h_poolSvc{this,"PoolSvc","PoolSvc"};
230 PublicToolHandle<IIOVDbMetaDataTool> m_h_metaDataTool{this,"IOVDbMetaDataTool","IOVDbMetaDataTool"};
231 ServiceHandle<ITagInfoMgr> m_h_tagInfoMgr{this,"TagInfoMgr","TagInfoMgr"};
232
233 // Flag to signal when a pool payload has been requested. This
234 // implies that a pool file has been open during an event, and will
235 // allow one to close the pool file and the end of event.
237
238 // Pool service context
239 int poolSvcContext();
241
242 // Flag to keep track of which state we are in to know
243 // how to obtain the IOV time, i.e. during:
244 // initialization - IOV time is from the EventSelector
245 // begin run - IOV time should have been set with signalBeginRun
246 // event loop - IOV time is from EventInfo
247 // finalize alg - IOV time is the last event's time from EventInfo
255
256 // IOVTime to be set during initialation or begin run
258
259 // Global tag from TagInfo or joboptions
260 std::string m_globalTag{};
261
262 // IOV value to be subtraced for timeStampSlop
263 cool::ValidityKey m_iovslop{};
264
265 // vector of managed connections
266 std::vector<std::unique_ptr<IOVDbConn>> m_connections;
267
268 // map of SG keyname to folder objects
269 typedef std::map<std::string, std::unique_ptr<IOVDbFolder>> FolderMap;
271 // gloal abort flag
272 bool m_abort{false};
273
274};
275
276#endif
uint32_t CLID
The Class ID type.
This is an interface to a tool used to manage the IOV Meta Data for a given object in the MetaData St...
Abstract interface to IOVDbSvc to access IOVRange and tag information.
Basic time unit for IOVSvc.
This file contains the class definition for the IPoolSvc interface class.
This class is a collection of AttributeLists where each one is associated with a channel number.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition EventID.h:35
std::list< SG::TransientAddress * > tadList
tadList::iterator tadListIterator
Athena service for Interval Of Validity database.
Definition IOVDbSvc.h:72
virtual StatusCode finalize() override
Service finalize.
Definition IOVDbSvc.cxx:234
StringProperty m_par_format
Definition IOVDbSvc.h:217
BooleanProperty m_par_managePoolConnections
Definition IOVDbSvc.h:188
StatusCode loadCaches(IOVDbConn *conn, const IOVTime *time=nullptr)
PublicToolHandle< IIOVDbMetaDataTool > m_h_metaDataTool
Definition IOVDbSvc.h:230
ServiceHandle< StoreGateSvc > m_h_sgSvc
Definition IOVDbSvc.h:224
Gaudi::Property< std::vector< std::string > > m_par_overrideTags
Definition IOVDbSvc.h:182
virtual void handle(const Incident &incident) override
Incident service handle for EndEvent.
Definition IOVDbSvc.cxx:726
Gaudi::Property< std::vector< std::string > > m_par_folders
Definition IOVDbSvc.h:180
virtual cool::IDatabasePtr getDatabase(bool readOnly) override
Access to COOL database for a given folder.
Definition IOVDbSvc.cxx:266
BooleanProperty m_crestCoolToFile
Definition IOVDbSvc.h:220
virtual bool dropObject(const std::string &key, const bool resetCache=false) override
Definition IOVDbSvc.cxx:817
IAddressProvider::tadList tadList
Definition IOVDbSvc.h:91
BooleanProperty m_outputToFile
Definition IOVDbSvc.h:219
BooleanProperty m_par_checklock
Definition IOVDbSvc.h:209
IntegerProperty m_par_forceLumiblockNumber
Definition IOVDbSvc.h:192
BooleanProperty m_par_manageConnections
Definition IOVDbSvc.h:186
virtual StatusCode preLoadAddresses(StoreID::type storeID, tadList &list) override
Get all addresses that the provider wants to preload in SG maps.
Definition IOVDbSvc.cxx:285
StatusCode io_finalize() override final
Definition IOVDbSvc.cxx:228
ServiceHandle< IAddressCreator > m_h_persSvc
Definition IOVDbSvc.h:227
bool m_abort
Definition IOVDbSvc.h:272
std::map< std::string, std::string > m_cresttagmap
Definition IOVDbSvc.h:215
StatusCode checkConfigConsistency() const
IOVTime m_iovTime
Definition IOVDbSvc.h:257
IntegerProperty m_par_maxNumPoolFiles
Definition IOVDbSvc.h:196
UnsignedIntegerProperty m_par_cacheAlign
Definition IOVDbSvc.h:205
StatusCode io_reinit() override final
Definition IOVDbSvc.cxx:220
IntegerProperty m_par_forceTimestamp
Definition IOVDbSvc.h:194
virtual StatusCode setRange(const CLID &clid, const std::string &dbKey, const IOVRange &range, const std::string &tag) override
Set range for a particular data object.
Definition IOVDbSvc.cxx:615
IntegerProperty m_par_cacheRun
Definition IOVDbSvc.h:200
@ FINALIZE_ALG
Definition IOVDbSvc.h:252
@ BEGIN_RUN
Definition IOVDbSvc.h:250
@ INITIALIZATION
Definition IOVDbSvc.h:249
@ EVENT_LOOP
Definition IOVDbSvc.h:251
IAddressProvider::tadListIterator tadListIterator
Definition IOVDbSvc.h:92
virtual StatusCode initialize() override
Service init.
Definition IOVDbSvc.cxx:143
StatusCode checkEventSel()
Definition IOVDbSvc.cxx:845
virtual void postConditionsLoad() override
May be called once conditions are loaded to let IOVDbSvc release resources.
Definition IOVDbSvc.cxx:700
BooleanProperty m_par_onlineMode
Definition IOVDbSvc.h:207
ServiceHandle< StoreGateSvc > m_h_metaDataStore
Definition IOVDbSvc.h:226
ServiceHandle< IClassIDSvc > m_h_clidSvc
Definition IOVDbSvc.h:228
ServiceHandle< ITagInfoMgr > m_h_tagInfoMgr
Definition IOVDbSvc.h:231
Gaudi::Property< std::string > m_par_dbinst
Definition IOVDbSvc.h:178
virtual StatusCode signalBeginRun(const IOVTime &beginRunTime, const EventContext &ctx) override
Set time for begin run.
Definition IOVDbSvc.cxx:624
int m_poolSvcContext
Definition IOVDbSvc.h:240
ServiceHandle< IPoolSvc > m_h_poolSvc
Definition IOVDbSvc.h:229
StatusCode fillTagInfo()
int poolSvcContext()
Definition IOVDbSvc.cxx:123
bool m_poolPayloadRequested
Definition IOVDbSvc.h:236
StatusCode setupFolders()
Definition IOVDbSvc.cxx:906
ServiceHandle< StoreGateSvc > m_h_detStore
Definition IOVDbSvc.h:225
virtual bool getKeyInfo(const std::string &key, IIOVDbSvc::KeyInfo &info) override
Return information about SG key return false if this key is not known to IOVDbSvc.
Definition IOVDbSvc.cxx:796
Gaudi::Property< std::string > m_par_defaultConnection
Definition IOVDbSvc.h:174
virtual StatusCode loadAddresses(StoreID::type storeID, tadList &list) override
Get all new addresses from Provider for this Event.
Definition IOVDbSvc.cxx:410
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
Update a transient Address.
Definition IOVDbSvc.cxx:416
IOVDbSvc_state m_state
Definition IOVDbSvc.h:254
virtual std::vector< std::string > getKeyList() override
Definition IOVDbSvc.cxx:789
virtual void signalEndProxyPreload() override
Signal that callback has been fired.
Definition IOVDbSvc.cxx:695
IntegerProperty m_par_cacheTime
Definition IOVDbSvc.h:202
Gaudi::Property< std::vector< std::string > > m_par_foldersToWrite
Definition IOVDbSvc.h:184
Gaudi::Property< std::string > m_par_globalTag
Definition IOVDbSvc.h:176
IntegerProperty m_par_forceRunNumber
Definition IOVDbSvc.h:190
StringProperty m_par_crestServer
Definition IOVDbSvc.h:213
virtual StatusCode processTagInfo() override
Process TagInfo.
Definition IOVDbSvc.cxx:748
StringProperty m_par_source
Definition IOVDbSvc.h:211
virtual StatusCode getRange(const CLID &clid, const std::string &dbKey, const IOVTime &time, IOVRange &range, std::string &tag, std::unique_ptr< IOpaqueAddress > &ioa) override
Get range for a particular data object identified by its clid and key and a requested IOVTime.
Definition IOVDbSvc.cxx:532
FloatProperty m_par_timeStampSlop
Definition IOVDbSvc.h:198
std::string m_globalTag
Definition IOVDbSvc.h:260
FolderMap m_foldermap
Definition IOVDbSvc.h:270
cool::ValidityKey m_iovslop
Definition IOVDbSvc.h:263
std::vector< std::unique_ptr< IOVDbConn > > m_connections
Definition IOVDbSvc.h:266
std::map< std::string, std::unique_ptr< IOVDbFolder > > FolderMap
Definition IOVDbSvc.h:269
ServiceHandle< IIOVSvc > m_h_IOVSvc
Definition IOVDbSvc.h:223
This class is a container for conditions data.
Validity Range object.
Definition IOVRange.h:30
Basic time unit for IOVSvc.
Definition IOVTime.h:33
The Athena Transient Store API.
Filled by IIOVDbSvc::getKeyInfo.
Definition IIOVDbSvc.h:44