ATLAS Offline Software
Loading...
Searching...
No Matches
IOVSvcTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef IOVSVC_IOVSVCTOOL_H
6#define IOVSVC_IOVSVCTOOL_H 1
7
8
9/*****************************************************************************
10 *
11 * IOVSvcTool.h
12 * IOVSvc
13 *
14 * Author: Charles Leggett
15 *
16 * Provides automatic updating and callbacks for time dependent data
17 * This AlgTool does the real work.
18 *
19 *****************************************************************************/
20
21
23#include "GaudiKernel/StatusCode.h"
24#include "GaudiKernel/ClassID.h"
25#include "GaudiKernel/IIncidentListener.h"
26#include "GaudiKernel/ServiceHandle.h"
27
29#include "SGTools/DataProxy.h"
30#include "IOVSvc/IIOVSvcTool.h"
31#include "IOVEntry.h"
32
33#include <string>
34#include <set>
35#include <map>
36#include <utility>
37#include <atomic>
38#include <memory>
39
40class StoreGateSvc;
41class IIncidentSvc;
42class Incident;
44class IClassIDSvc;
45class IProxyDict;
46class IToolSvc;
47
48namespace SG {
49 class TransientAddress;
50 class DataProxy;
51}
52
53struct SortTADptr {
54 using is_transparent = void;
55
56 template<typename X, typename Y>
57 bool operator() (X&& x, Y&& y) const {
58 return x->clID() == y->clID() ? x->name() < y->name() : x->clID() < y->clID();
59 }
60};
61
62struct SortDPptr {
63 bool operator() ( const SG::DataProxy*,
64 const SG::DataProxy* ) const;
65};
66
67class IOVSvcTool: public extends<AthAlgTool, IIOVSvcTool, IIncidentListener> {
68
69public:
70
71 IOVSvcTool(const std::string& type, const std::string& name,
72 const IInterface* parent);
73
74
75 virtual StatusCode initialize() override;
76
77
79
80 // Incident handler
81 virtual void handle(const Incident&) override;
82
83 virtual
84 void setStoreName(const std::string& storeName) override {
85 m_storeName = storeName;
86 }
87 virtual const std::string& getStoreName() const override { return m_storeName; }
88
89 // Update Range from dB
90 virtual StatusCode setRange(const CLID& clid, const std::string& key,
91 IOVRange&) override;
92
93 virtual StatusCode getRange(const CLID& clid, const std::string& key,
94 IOVRange& iov) const override;
95
96 // Subscribe method for DataProxy. key StoreGate key
97 virtual StatusCode regProxy( SG::DataProxy *proxy,
98 const std::string& key ) override;
99 // Another way to subscribe
100 virtual StatusCode regProxy( const CLID& clid, const std::string& key ) override;
101
102 virtual StatusCode deregProxy( SG::DataProxy *proxy ) override;
103 virtual StatusCode deregProxy( const CLID& clid, const std::string& key ) override;
104
105 // replace method for DataProxy, to be used when an update is necessary
106 virtual StatusCode replaceProxy( SG::DataProxy *pOld,
107 SG::DataProxy *pNew) override;
108
109 // Get IOVRange from db for current event
110 virtual StatusCode getRangeFromDB(const CLID& clid, const std::string& key,
111 IOVRange& range, std::string &tag,
112 std::unique_ptr<IOpaqueAddress>& ioa,
113 const IOVTime& curTime) const override;
114
115 // Get IOVRange from db for a particular event
116 virtual StatusCode getRangeFromDB(const CLID& clid, const std::string& key,
117 const IOVTime& time,
118 IOVRange& range, std::string &tag,
119 std::unique_ptr<IOpaqueAddress>& ioa) const override;
120
121 // Set a particular IOVRange in db (and memory)
122 virtual StatusCode setRangeInDB(const CLID& clid, const std::string& key,
123 const IOVRange& range,
124 const std::string &tag) override;
125
126 // supply a list of TADs whose proxies will be preloaded
127 virtual StatusCode preLoadTAD( const SG::TransientAddress * ) override;
128
129 // supply a list of TADs whose data will be preloaded
130 virtual StatusCode preLoadDataTAD( const SG::TransientAddress * ) override;
131
132 virtual bool holdsProxy( SG::DataProxy* proxy ) const override;
133 virtual bool holdsProxy( const CLID& clid, const std::string& key ) const override;
134
135 virtual void resetAllProxies() override;
136
137 virtual
138 void ignoreProxy( const CLID& clid, const std::string& key ) override{
139 m_ignoredProxyNames.insert( std::make_pair(clid,key) );
140 }
141 virtual
142 void ignoreProxy(SG::DataProxy* proxy) override {
143 m_ignoredProxies.insert(proxy);
144 }
145
146private:
147
148 StatusCode preLoadProxies(const EventContext& ctx);
149 StatusCode preLoadData();
150 std::string fullProxyName( const SG::TransientAddress* ) const;
151 std::string fullProxyName( const SG::DataProxy* ) const;
152 std::string fullProxyName( const CLID&, const std::string& ) const;
153 void setRange_impl (SG::DataProxy* proxy, IOVRange& iovr);
154
155 std::string m_storeName;
156
162
163 std::map< const SG::DataProxy*, std::string> m_names;
164
165 mutable std::recursive_mutex m_handleMutex ATLAS_THREAD_SAFE;
166 // meant to protect: m_first, m_entries,
167 // m_startSet..., m_stopSet... .
168 // Locked by "handle" and "setRange", where setRange
169 // is called also via preLoadProxies which calls
170 // SG::DataProxy::updateAddress which then calls
171 // setRange. So, without refactoring a recursive
172 // mutex is needed.
173
174 std::set< SG::DataProxy*, SortDPptr > m_proxies;
175
176 std::set<SG::DataProxy*> m_ignoredProxies;
177 std::set< std::pair<CLID, std::string> > m_ignoredProxyNames;
178
179 std::map< const SG::DataProxy*, std::unique_ptr<IOVEntry> > m_entries;
180
183
186
187 std::set< std::unique_ptr<const SG::TransientAddress>, SortTADptr > m_preLoad;
188
189 typedef std::tuple <CLID, std::string> TADkey_t;
191 { return TADkey_t (p.clID(), p.name()); }
193 { return TADkey_t (t.clID(), t.name()); }
194 std::set< TADkey_t > m_partPreLoad;
195
196 std::atomic<bool> m_first{true};
197 bool m_checkOnce{false};
198 bool m_firstEventOfRun{false};
199 std::string m_checkTrigger;
200
201 Gaudi::Property<bool> m_preLoadRanges{this, "preLoadRanges", false};
202 Gaudi::Property<bool> m_preLoadData{this, "preLoadData", false};
203 Gaudi::Property<bool> m_partialPreLoadData{this, "partialPreLoadData", true};
204 Gaudi::Property<bool> m_preLoadExtensibleFolders{this, "preLoadExtensibleFolders", true};
205 Gaudi::Property<bool> m_sortKeys{this, "sortKeys", true};
206 Gaudi::Property<bool> m_forceReset{this, "forceResetAtBeginRun", false};
207 Gaudi::Property<std::string> m_updateInterval{this, "updateInterval", "Event"};
208
209
210 void scanStartSet(IOVEntry::StartSet_t &pSet, const std::string &type,
211 std::set<SG::DataProxy*, SortDPptr> &proxiesToReset,
212 const IOVTime& curTime) const;
213 void scanStopSet(IOVEntry::StopSet_t &pSet, const std::string &type,
214 std::set<SG::DataProxy*, SortDPptr> &proxiesToReset,
215 const IOVTime& curTime) const;
216
217 void PrintStartSet() const;
218 void PrintStopSet() const;
219 void PrintProxyMap() const;
220 void PrintProxyMap(const SG::DataProxy*) const;
221
222};
223
224#endif
uint32_t CLID
The Class ID type.
Basic time unit for IOVSvc.
#define y
#define x
std::multiset< IOVEntry *, IOVEntryStopCritereon > StopSet_t
Definition IOVEntry.h:52
std::multiset< IOVEntry *, IOVEntryStartCritereon > StartSet_t
Definition IOVEntry.h:51
Validity Range object.
Definition IOVRange.h:30
bool m_checkOnce
Definition IOVSvcTool.h:197
virtual StatusCode regProxy(SG::DataProxy *proxy, const std::string &key) override
Register a DataProxy with the service.
virtual const std::string & getStoreName() const override
Definition IOVSvcTool.h:87
void setRange_impl(SG::DataProxy *proxy, IOVRange &iovr)
Gaudi::Property< bool > m_forceReset
Definition IOVSvcTool.h:206
std::string fullProxyName(const SG::TransientAddress *) const
void scanStopSet(IOVEntry::StopSet_t &pSet, const std::string &type, std::set< SG::DataProxy *, SortDPptr > &proxiesToReset, const IOVTime &curTime) const
Gaudi::Property< bool > m_preLoadRanges
Definition IOVSvcTool.h:201
std::set< std::pair< CLID, std::string > > m_ignoredProxyNames
Definition IOVSvcTool.h:177
ServiceHandle< IClassIDSvc > p_CLIDSvc
Definition IOVSvcTool.h:160
virtual void ignoreProxy(SG::DataProxy *proxy) override
Definition IOVSvcTool.h:142
void PrintStopSet() const
virtual StatusCode replaceProxy(SG::DataProxy *pOld, SG::DataProxy *pNew) override
replace a registered DataProxy with a new version
Gaudi::Property< bool > m_partialPreLoadData
Definition IOVSvcTool.h:203
Gaudi::Property< bool > m_sortKeys
Definition IOVSvcTool.h:205
IOVEntry::StartSet_t * p_startSet
Definition IOVSvcTool.h:181
IOVEntry::StopSet_t m_stopSet_RE
Definition IOVSvcTool.h:185
StatusCode preLoadProxies(const EventContext &ctx)
std::recursive_mutex m_handleMutex ATLAS_THREAD_SAFE
Definition IOVSvcTool.h:165
std::string m_storeName
Definition IOVSvcTool.h:155
virtual StatusCode setRangeInDB(const CLID &clid, const std::string &key, const IOVRange &range, const std::string &tag) override
virtual void resetAllProxies() override
std::set< TADkey_t > m_partPreLoad
Definition IOVSvcTool.h:194
virtual StatusCode preLoadTAD(const SG::TransientAddress *) override
add to a set of TADs that will be registered at start of first event
IOVSvcTool(const std::string &type, const std::string &name, const IInterface *parent)
std::map< const SG::DataProxy *, std::unique_ptr< IOVEntry > > m_entries
Definition IOVSvcTool.h:179
std::set< SG::DataProxy * > m_ignoredProxies
Definition IOVSvcTool.h:176
ServiceHandle< IProxyProviderSvc > p_PPSvc
Definition IOVSvcTool.h:159
void PrintStartSet() const
std::atomic< bool > m_first
Definition IOVSvcTool.h:196
Gaudi::Property< std::string > m_updateInterval
Definition IOVSvcTool.h:207
Gaudi::Property< bool > m_preLoadData
Definition IOVSvcTool.h:202
virtual void ignoreProxy(const CLID &clid, const std::string &key) override
Definition IOVSvcTool.h:138
void scanStartSet(IOVEntry::StartSet_t &pSet, const std::string &type, std::set< SG::DataProxy *, SortDPptr > &proxiesToReset, const IOVTime &curTime) const
std::tuple< CLID, std::string > TADkey_t
Definition IOVSvcTool.h:189
IOVEntry::StopSet_t * p_stopSet
Definition IOVSvcTool.h:182
IOVEntry::StopSet_t m_stopSet_Clock
Definition IOVSvcTool.h:185
std::string m_checkTrigger
Definition IOVSvcTool.h:199
std::map< const SG::DataProxy *, std::string > m_names
Definition IOVSvcTool.h:163
virtual StatusCode initialize() override
TADkey_t TADkey(const SG::DataProxy &p)
Definition IOVSvcTool.h:190
std::set< std::unique_ptr< const SG::TransientAddress >, SortTADptr > m_preLoad
Definition IOVSvcTool.h:187
void PrintProxyMap() const
StatusCode preLoadData()
virtual StatusCode deregProxy(SG::DataProxy *proxy) override
Deregister a DataProxy with the service.
IOVEntry::StartSet_t m_startSet_RE
Definition IOVSvcTool.h:184
bool m_firstEventOfRun
Definition IOVSvcTool.h:198
Gaudi::Property< bool > m_preLoadExtensibleFolders
Definition IOVSvcTool.h:204
virtual StatusCode getRange(const CLID &clid, const std::string &key, IOVRange &iov) const override
virtual bool holdsProxy(SG::DataProxy *proxy) const override
ServiceHandle< IToolSvc > p_toolSvc
Definition IOVSvcTool.h:161
TADkey_t TADkey(const SG::TransientAddress &t)
Definition IOVSvcTool.h:192
virtual StatusCode getRangeFromDB(const CLID &clid, const std::string &key, IOVRange &range, std::string &tag, std::unique_ptr< IOpaqueAddress > &ioa, const IOVTime &curTime) const override
virtual StatusCode preLoadDataTAD(const SG::TransientAddress *) override
add to a set of TADs that who's data will be preLoaded
IOVEntry::StartSet_t m_startSet_Clock
Definition IOVSvcTool.h:184
ServiceHandle< StoreGateSvc > p_cndSvc
Definition IOVSvcTool.h:157
virtual void handle(const Incident &) override
ServiceHandle< IIncidentSvc > p_incSvc
Definition IOVSvcTool.h:158
std::set< SG::DataProxy *, SortDPptr > m_proxies
Definition IOVSvcTool.h:174
virtual StatusCode setRange(const CLID &clid, const std::string &key, IOVRange &) override
virtual void setStoreName(const std::string &storeName) override
Definition IOVSvcTool.h:84
Basic time unit for IOVSvc.
Definition IOVTime.h:33
The Athena Transient Store API.
Forward declaration.
bool operator()(const SG::DataProxy *, const SG::DataProxy *) const
bool operator()(X &&x, Y &&y) const
Definition IOVSvcTool.h:57
void is_transparent
Definition IOVSvcTool.h:54