ATLAS Offline Software
Loading...
Searching...
No Matches
IOVDbSvc.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
15
16#ifndef IOVDbSvc_IOVDbSvc_h
17#define IOVDbSvc_IOVDbSvc_h
18
19#include "GaudiKernel/IInterface.h"
20#include "GaudiKernel/IService.h"
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#include "SGTools/DataProxy.h"
31#include "PoolSvc/IPoolSvc.h"
33
39
40#include "CoolKernel/IDatabase.h"
41#include "CoolKernel/ValidityKey.h"
42
43#include "IOVDbConn.h"
44
45
46#include <string>
47#include <vector>
48#include <map>
49
50class IOVSvc;
51class IOVTime;
52class IOVRange;
53class StoreGateSvc;
54class IClassIDSvc;
55
56class EventID;
57class ITagInfoMgr;
58
59class IOVDbFolder;
60
63
76class IOVDbSvc : public extends<AthService,
77 IIOVCondDbSvc,
78 IIOVDbSvc,
79 IAddressProvider,
80 IIncidentListener,
81 IIoComponent>
82{
83public:
84
86 using base_class::base_class;
87 virtual ~IOVDbSvc();
88
90 virtual StatusCode initialize() override;
91 StatusCode io_reinit() override final;
92
94 virtual StatusCode finalize() override;
95 StatusCode io_finalize() override final;
96
97 // IIOVDbSvc interface
98
100 virtual cool::IDatabasePtr getDatabase( bool readOnly ) override;
101
104
106
107
108 virtual StatusCode preLoadAddresses( StoreID::type storeID,
109 tadList& list ) override;
110
112 virtual StatusCode loadAddresses( StoreID::type storeID,
113 tadList& list ) override;
114
116 virtual StatusCode updateAddress( StoreID::type storeID,
117 SG::TransientAddress* tad,
118 const EventContext& ctx ) override;
120
121
123
124
126 virtual StatusCode getRange( const CLID& clid,
127 const std::string& dbKey,
128 const IOVTime& time,
129 IOVRange& range,
130 std::string& tag,
131 std::unique_ptr<IOpaqueAddress>& ioa) override;
132
133
134
136 virtual StatusCode setRange( const CLID& clid,
137 const std::string& dbKey,
138 const IOVRange& range,
139 const std::string& tag ) override;
140
142 virtual StatusCode signalBeginRun(const IOVTime& beginRunTime,
143 const EventContext& ctx) override;
144
146 virtual void signalEndProxyPreload() override;
148
150 virtual void postConditionsLoad() override;
151
153 virtual void handle( const Incident& incident ) override;
154
156 virtual StatusCode processTagInfo() override;
157
158 // return list of SG keys being provided by IOVDbSvc
159 virtual std::vector<std::string> getKeyList() override;
160
163 virtual
164 bool getKeyInfo(const std::string& key, IIOVDbSvc::KeyInfo& info) override;
165
166 // drop an IOVDbSvc-managed object from Storegate, indicating we will
167 // not read it again and can free up memory
168 // If resetCache=True, also drop the corresponding folder cache
169 // so any subsequent reads will access the database again
170 // returns False if key not known to IOVDbSvc
171 virtual
172 bool dropObject(const std::string& key,const bool resetCache=false) override;
173
174
175private:
176 // internal methods
177 StatusCode checkConfigConsistency() const;
178 StatusCode checkEventSel();
179 StatusCode setupFolders();
180 StatusCode fillTagInfo();
181 StatusCode loadCaches(IOVDbConn* conn, const IOVTime* time=nullptr);
182
183 // job option parameters
184 // default database connection
185 Gaudi::Property<std::string> m_par_defaultConnection{this,"dbConnection","sqlite://;schema=cooldummy.db;dbname=OFLP200","default DB connection string"};
186 // IOVDbSvc global tag
187 Gaudi::Property<std::string> m_par_globalTag{this,"GlobalTag","","Global database tag"};
188 // production database instance, used to cross-check global tag
189 Gaudi::Property<std::string> m_par_dbinst{this,"DBInstance","","Database instance (like OFLP200)"};
190 // a list of folders to preload
191 Gaudi::Property<std::vector<std::string> > m_par_folders{this,"Folders",{},"List of database folders to preload","OrderedSet<std::string>"};
192 // a list of overriding tags definitions
193 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>"};
194 // a list of folders to write to file meta data
195 Gaudi::Property<std::vector<std::string> > m_par_foldersToWrite{this,"FoldersToMetaData",{},"list of folders to write to file meta data","OrderedSet<std::string>"};
196 // a flag to trigger the connections management
197 BooleanProperty m_par_manageConnections{this,"ManageConnections",true,"flag to trigger the connections management"};
198 // a flag to manage pool connections
199 BooleanProperty m_par_managePoolConnections{this,"ManagePoolConnections",true,"flag to manage pool connections"};
200 // a global force run number
201 IntegerProperty m_par_forceRunNumber{this,"forceRunNumber",0,"globally force run-number (default: no force)"};
202 // a global force lumiblock number
203 IntegerProperty m_par_forceLumiblockNumber{this,"forceLumiblockNumber",0,"globally force LB-number (default: no force)"};
204 // a global force timestamp
205 IntegerProperty m_par_forceTimestamp{this,"forceTimeStamp",0,"globally force time-stamp (default: no force)"};
206 // max number of pool files open allowed
207 IntegerProperty m_par_maxNumPoolFiles{this,"MaxPoolFilesOpen",5,"max number of pool files open allowed (0 means no limit)"};
208 // timestampslop - backdata timestamp IOVs by this many seconds
209 FloatProperty m_par_timeStampSlop{this,"TimeStampSlop",0.0,"backdata timestamp IOVs by this many seconds"};
210 // force larger numbers of runs to be cached
211 IntegerProperty m_par_cacheRun{this,"CacheRun",0,"force larger numbers of runs to be cached"};
212 // force larger timeranges to be cached (seconds)
213 IntegerProperty m_par_cacheTime{this,"CacheTime",0,"force larger timeranges to be cached (seconds)"};
214 // cache alignment - divide cache into N slices and align queries on slice
215 // should be useful to improve Frontier cache hit rate
216 UnsignedIntegerProperty m_par_cacheAlign{this,"CacheAlign",0,"cache alignment - divide cache into N slices and align queries on slice"};
217 // online mode flag to ignore missing channels outside cache range
218 BooleanProperty m_par_onlineMode{this,"OnlineMode",false,"online mode flag to ignore missing channels outside cache range"};
219 // check to ensure global/HVS tags are locked (for production)
220 BooleanProperty m_par_checklock{this,"CheckLock",false,"check to ensure global/HVS tags are locked (for production)"};
221 // Source of data as a string; default is "COOL_DATABASE"
222 StringProperty m_par_source{this,"Source","COOL_DATABASE","source of data as a string (default COOL_DATABASE)"};
223 // CREST Server URL with host number; default is "http://crest-undertow-api.web.cern.ch"
224 StringProperty m_par_crestServer{this,"crestServer","https://crest.cern.ch","CREST URL with the port number as a string (default https://crest.cern.ch)"};
225 // This map contains the pairs: COOL folder - CREST tag name
226 std::map<std::string, std::string> m_cresttagmap;
227 // Format of data; default is empty string (default for a given source)
228 StringProperty m_par_format{this,"Format",{},"Format of data; default is empty string (default for a given source)"};
229 // Can output to file for debugging purposes
230 BooleanProperty m_outputToFile{this,"OutputToFile",false,"output to file for debugging purposes"};
231 BooleanProperty m_crestCoolToFile{this,"CrestCoolToFile",false,"output to file crest or cool data in the same format for debugging purposes"};
232 // internal parameters
233 // handles to other services and tools
234 ServiceHandle<IIOVSvc> m_h_IOVSvc{this,"IOVSvc","IOVSvc"};
235 ServiceHandle<StoreGateSvc> m_h_sgSvc{this,"StoreGateSvc","StoreGateSvc"};
236 ServiceHandle<StoreGateSvc> m_h_detStore{this,"DetectorStore","DetectorStore"};
237 ServiceHandle<StoreGateSvc> m_h_metaDataStore{this,"MetaDataStore","StoreGateSvc/MetaDataStore"};
238 ServiceHandle<IAddressCreator> m_h_persSvc{this,"EventPersistencySvc","EventPersistencySvc"};
239 ServiceHandle<IClassIDSvc> m_h_clidSvc{this,"ClassIDSvc","ClassIDSvc"};
240 ServiceHandle<IPoolSvc> m_h_poolSvc{this,"PoolSvc","PoolSvc"};
241 PublicToolHandle<IIOVDbMetaDataTool> m_h_metaDataTool{this,"IOVDbMetaDataTool","IOVDbMetaDataTool"};
242 ServiceHandle<ITagInfoMgr> m_h_tagInfoMgr{this,"TagInfoMgr","TagInfoMgr"};
243
244 // Flag to signal when a pool payload has been requested. This
245 // implies that a pool file has been open during an event, and will
246 // allow one to close the pool file and the end of event.
248
249 // Pool service context
250 int poolSvcContext();
252
253 // Flag to keep track of which state we are in to know
254 // how to obtain the IOV time, i.e. during:
255 // initialization - IOV time is from the EventSelector
256 // begin run - IOV time should have been set with signalBeginRun
257 // event loop - IOV time is from EventInfo
258 // finalize alg - IOV time is the last event's time from EventInfo
266
267 // IOVTime to be set during initialation or begin run
269
270 // Global tag from TagInfo or joboptions
271 std::string m_globalTag{};
272
273 // IOV value to be subtraced for timeStampSlop
274 cool::ValidityKey m_iovslop{};
275
276 // vector of managed connections
277 typedef std::vector<IOVDbConn*> ConnVec;
279 // map of SG keyname to folder objects
280 typedef std::map<std::string,IOVDbFolder*> FolderMap;
282 // gloal abort flag
283 bool m_abort{false};
284
285};
286
287#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
interface for IOA providers
Abstract interface to IOVDbSvc to access IOVRange and tag information.
Definition IIOVDbSvc.h:38
Athena service for Interval Of Validity database.
Definition IOVDbSvc.h:82
virtual StatusCode finalize() override
Service finalize.
Definition IOVDbSvc.cxx:258
StringProperty m_par_format
Definition IOVDbSvc.h:228
BooleanProperty m_par_managePoolConnections
Definition IOVDbSvc.h:199
StatusCode loadCaches(IOVDbConn *conn, const IOVTime *time=nullptr)
PublicToolHandle< IIOVDbMetaDataTool > m_h_metaDataTool
Definition IOVDbSvc.h:241
std::vector< IOVDbConn * > ConnVec
Definition IOVDbSvc.h:277
ServiceHandle< StoreGateSvc > m_h_sgSvc
Definition IOVDbSvc.h:235
Gaudi::Property< std::vector< std::string > > m_par_overrideTags
Definition IOVDbSvc.h:193
virtual void handle(const Incident &incident) override
Incident service handle for EndEvent.
Definition IOVDbSvc.cxx:757
Gaudi::Property< std::vector< std::string > > m_par_folders
Definition IOVDbSvc.h:191
virtual cool::IDatabasePtr getDatabase(bool readOnly) override
Access to COOL database for a given folder.
Definition IOVDbSvc.cxx:297
BooleanProperty m_crestCoolToFile
Definition IOVDbSvc.h:231
virtual bool dropObject(const std::string &key, const bool resetCache=false) override
Definition IOVDbSvc.cxx:848
IAddressProvider::tadList tadList
Definition IOVDbSvc.h:102
std::map< std::string, IOVDbFolder * > FolderMap
Definition IOVDbSvc.h:280
BooleanProperty m_outputToFile
Definition IOVDbSvc.h:230
BooleanProperty m_par_checklock
Definition IOVDbSvc.h:220
IntegerProperty m_par_forceLumiblockNumber
Definition IOVDbSvc.h:203
BooleanProperty m_par_manageConnections
Definition IOVDbSvc.h:197
virtual StatusCode preLoadAddresses(StoreID::type storeID, tadList &list) override
Get all addresses that the provider wants to preload in SG maps.
Definition IOVDbSvc.cxx:315
StatusCode io_finalize() override final
Definition IOVDbSvc.cxx:253
ServiceHandle< IAddressCreator > m_h_persSvc
Definition IOVDbSvc.h:238
bool m_abort
Definition IOVDbSvc.h:283
std::map< std::string, std::string > m_cresttagmap
Definition IOVDbSvc.h:226
StatusCode checkConfigConsistency() const
virtual ~IOVDbSvc()
IOVTime m_iovTime
Definition IOVDbSvc.h:268
IntegerProperty m_par_maxNumPoolFiles
Definition IOVDbSvc.h:207
UnsignedIntegerProperty m_par_cacheAlign
Definition IOVDbSvc.h:216
StatusCode io_reinit() override final
Definition IOVDbSvc.cxx:246
IntegerProperty m_par_forceTimestamp
Definition IOVDbSvc.h:205
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:649
IntegerProperty m_par_cacheRun
Definition IOVDbSvc.h:211
@ FINALIZE_ALG
Definition IOVDbSvc.h:263
@ BEGIN_RUN
Definition IOVDbSvc.h:261
@ INITIALIZATION
Definition IOVDbSvc.h:260
@ EVENT_LOOP
Definition IOVDbSvc.h:262
IAddressProvider::tadListIterator tadListIterator
Definition IOVDbSvc.h:103
virtual StatusCode initialize() override
Service init.
Definition IOVDbSvc.cxx:160
StatusCode checkEventSel()
Definition IOVDbSvc.cxx:876
virtual void postConditionsLoad() override
May be called once conditions are loaded to let IOVDbSvc release resources.
Definition IOVDbSvc.cxx:732
BooleanProperty m_par_onlineMode
Definition IOVDbSvc.h:218
ServiceHandle< StoreGateSvc > m_h_metaDataStore
Definition IOVDbSvc.h:237
ServiceHandle< IClassIDSvc > m_h_clidSvc
Definition IOVDbSvc.h:239
ServiceHandle< ITagInfoMgr > m_h_tagInfoMgr
Definition IOVDbSvc.h:242
Gaudi::Property< std::string > m_par_dbinst
Definition IOVDbSvc.h:189
virtual StatusCode signalBeginRun(const IOVTime &beginRunTime, const EventContext &ctx) override
Set time for begin run.
Definition IOVDbSvc.cxx:657
ConnVec m_connections
Definition IOVDbSvc.h:278
int m_poolSvcContext
Definition IOVDbSvc.h:251
ServiceHandle< IPoolSvc > m_h_poolSvc
Definition IOVDbSvc.h:240
StatusCode fillTagInfo()
int poolSvcContext()
Definition IOVDbSvc.cxx:141
bool m_poolPayloadRequested
Definition IOVDbSvc.h:247
StatusCode setupFolders()
Definition IOVDbSvc.cxx:936
ServiceHandle< StoreGateSvc > m_h_detStore
Definition IOVDbSvc.h:236
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:828
Gaudi::Property< std::string > m_par_defaultConnection
Definition IOVDbSvc.h:185
virtual StatusCode loadAddresses(StoreID::type storeID, tadList &list) override
Get all new addresses from Provider for this Event.
Definition IOVDbSvc.cxx:442
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
Update a transient Address.
Definition IOVDbSvc.cxx:448
IOVDbSvc_state m_state
Definition IOVDbSvc.h:265
virtual std::vector< std::string > getKeyList() override
Definition IOVDbSvc.cxx:820
virtual void signalEndProxyPreload() override
Signal that callback has been fired.
Definition IOVDbSvc.cxx:728
IntegerProperty m_par_cacheTime
Definition IOVDbSvc.h:213
Gaudi::Property< std::vector< std::string > > m_par_foldersToWrite
Definition IOVDbSvc.h:195
Gaudi::Property< std::string > m_par_globalTag
Definition IOVDbSvc.h:187
IntegerProperty m_par_forceRunNumber
Definition IOVDbSvc.h:201
StringProperty m_par_crestServer
Definition IOVDbSvc.h:224
virtual StatusCode processTagInfo() override
Process TagInfo.
Definition IOVDbSvc.cxx:778
StringProperty m_par_source
Definition IOVDbSvc.h:222
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:565
FloatProperty m_par_timeStampSlop
Definition IOVDbSvc.h:209
std::string m_globalTag
Definition IOVDbSvc.h:271
FolderMap m_foldermap
Definition IOVDbSvc.h:281
cool::ValidityKey m_iovslop
Definition IOVDbSvc.h:274
ServiceHandle< IIOVSvc > m_h_IOVSvc
Definition IOVDbSvc.h:234
This class is a container for conditions data.
Validity Range object.
Definition IOVRange.h:30
Basic time unit for IOVSvc.
Definition IOVTime.h:33
This is a Athena service which manages detector description tag information.
Definition ITagInfoMgr.h:58
Support class for PropertyMgr.
Definition Property.h:23
The Athena Transient Store API.
defines an enum used by address providers to decide what kind of StoreGateSvc they are providing addr...
Definition StoreID.h:18
STL class.
=============================================================================
Forward declaration.
STL namespace.
#define private