ATLAS Offline Software
Loading...
Searching...
No Matches
IOVSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5/*****************************************************************************
6 *
7 * IOVSvc.cxx
8 * IOVSvc
9 *
10 * Author: Charles Leggett
11 *
12 * Provides automatic updating and callbacks for time dependent data
13 *
14 *****************************************************************************/
15
16#include "IOVSvc.h"
17
18#include "GaudiKernel/ISvcLocator.h"
19#include "GaudiKernel/IAlgTool.h"
20#include "GaudiKernel/IToolSvc.h"
21#include "GaudiKernel/IClassIDSvc.h"
22#include "GaudiKernel/IConversionSvc.h"
23
28#include "IOVSvc/IIOVSvcTool.h"
29
30using SG::DataProxy;
32
33const std::string defaultStore = "StoreGateSvc";
34
35
36namespace {
37
38
44bool eventIDMatch (const EventIDBase& e1, const EventIDBase& e2)
45{
46 if (e1.isRunLumi()) {
47 if (e1.run_number() != e2.run_number()) return false;
48 if (e1.lumi_block() != e2.lumi_block()) return false;
49 }
50 if (e1.isTimeStamp()) {
51 if (e1.time_stamp() != e2.time_stamp()) return false;
52 if (e1.time_stamp_ns_offset() != e2.time_stamp_ns_offset()) return false;
53 }
54 return true;
55}
56
57
58} // anonymous namespace
59
60
61
62//
64//
65
66IOVSvc::IOVSvc( const std::string& name, ISvcLocator* svc )
67 : base_class( name, svc ),
68 p_toolSvc("ToolSvc",name),
69 p_CLIDSvc("ClassIDSvc",name),
70 p_sgs("StoreGateSvc",name),
71 p_detStore("StoreGateSvc/DetectorStore",name),
72 p_condSvc("CondSvc",name)
73{
74
75 declareProperty("preLoadRanges",m_preLoadRanges=false);
76 declareProperty("preLoadData",m_preLoadData=false);
77 declareProperty("partialPreLoadData",m_partialPreLoadData=true);
78 declareProperty("preLoadExtensibleFolders", m_preLoadExtensibleFolders=true);
79 declareProperty("updateInterval", m_updateInterval="Event");
80 declareProperty("sortKeys",m_sortKeys=true);
81 declareProperty("forceResetAtBeginRun", m_forceReset=false);
82
83}
84
85/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
86
88
89}
90
91/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
92
93StatusCode IOVSvc::initialize() {
94
95 msg().setLevel( m_outputLevel.value() );
96 ATH_MSG_DEBUG( "Initializing IOVSvc" );
97
98 if (!p_sgs.isValid()) {
99 ATH_MSG_ERROR("could not get the Event Store");
100 return StatusCode::FAILURE;
101 }
102
103 if (!p_detStore.isValid()) {
104 ATH_MSG_ERROR("could not get the Detector Store");
105 return StatusCode::FAILURE;
106 }
107
108 if (!p_condSvc.isValid()) {
109 ATH_MSG_ERROR("could not get the ConditionSvc");
110 return StatusCode::FAILURE;
111 }
112
113 return StatusCode::SUCCESS;
114}
115
116/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
117
119{
120 ATH_MSG_DEBUG( "Service finalised successfully" );
121 return StatusCode::SUCCESS;
122}
123
124/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
125
129StatusCode
130IOVSvc::regProxy( DataProxy *proxy, const std::string& key,
131 const std::string& storeName ) {
132
133 std::lock_guard<std::recursive_mutex> lock(m_lock);
134 IIOVSvcTool *ist = getTool( storeName );
135 if (ist == 0) {
136 ATH_MSG_ERROR( "regProxy: no IOVSvcTool associated with store \""
137 << storeName << "\" and failed to create one" );
138 return (StatusCode::FAILURE);
139 }
140
141 IIOVSvcTool *ist2 = getTool( proxy );
142 if (ist2 != 0) {
143 if (ist2 != ist) {
144 ATH_MSG_ERROR( "regProxy: when registering proxy for "
145 << fullProxyName(proxy) << " with store \"" << storeName
146 << "\", it is already registered with store \""
147 << ist2->getStoreName() << "\"" );
148 return StatusCode::FAILURE;
149 } else {
150 ATH_MSG_DEBUG( "regProxy: proxy for " << fullProxyName(proxy)
151 << " already registered with store \"" << storeName << "\""
152 );
153 return StatusCode::SUCCESS;
154 }
155 }
156
157 return ist->regProxy( proxy, key );
158
159}
160
161/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
162
166StatusCode
167IOVSvc::regProxy( const CLID& clid, const std::string& key,
168 const std::string& storeName ) {
169
170 std::lock_guard<std::recursive_mutex> lock(m_lock);
171 IIOVSvcTool *ist = getTool( storeName );
172 if (ist == 0) {
173 ATH_MSG_ERROR( "regProxy: no IOVSvcTool associated with store \""
174 << storeName << "\" and failed to create one." );
175 return (StatusCode::FAILURE);
176 }
177
178 IIOVSvcTool *ist2 = getTool( clid, key );
179 if (ist2 != 0) {
180 if (ist2 != ist) {
181 ATH_MSG_ERROR( "regProxy: when registering proxy for "
182 << fullProxyName(clid,key)
183 << " with store " << storeName
184 << ", it is already registered with store \""
185 << ist2->getStoreName() << "\"" );
186 return StatusCode::FAILURE;
187 } else {
188 ATH_MSG_DEBUG( "regProxy: proxy for " << fullProxyName(clid,key)
189 << " already registered with store \"" << storeName << "\""
190 );
191 return StatusCode::SUCCESS;
192 }
193 }
194
195 return ist->regProxy( clid, key );
196
197}
198
199/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
200
204StatusCode
206
207
208 std::lock_guard<std::recursive_mutex> lock(m_lock);
209 IIOVSvcTool *ist = getTool( proxy );
210 if (ist == 0) {
211 ATH_MSG_ERROR( "deregProxy: no IOVSvcTool found for proxy "
212 << fullProxyName( proxy ) );
213 return (StatusCode::FAILURE);
214 }
215
216 return ist->deregProxy( proxy );
217
218}
219
220/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
221
225StatusCode
226IOVSvc::deregProxy( const CLID& clid, const std::string& key ) {
227
228
229 std::lock_guard<std::recursive_mutex> lock(m_lock);
230 IIOVSvcTool *ist = getTool( clid, key );
231 if (ist == 0) {
232 ATH_MSG_ERROR( "deregProxy: no IOVSvcTool found for proxy "
233 << fullProxyName(clid,key) );
234 return StatusCode::FAILURE;
235 }
236
237 return ist->deregProxy( clid, key );
238
239}
240
241/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
242
246void
247IOVSvc::ignoreProxy( const CLID& clid, const std::string& key,
248 const std::string& storeName ) {
249
250
251 IIOVSvcTool *ist = getTool( storeName );
252 if (ist == 0) {
253 ATH_MSG_ERROR( "ignoreProxy: no IOVSvcTool found for store "
254 << storeName << " and failed to create one" );
255 return;
256 }
257
258 return ist->ignoreProxy( clid, key );
259}
260
261
262/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
263
267StatusCode
269 const std::string& storeName ) {
270
271 StatusCode sc(StatusCode::FAILURE);
272 IIOVSvcTool *ist = getTool( storeName );
273 if (0 != ist) {
274 sc = ist->replaceProxy(pOld, pNew);
275 } else {
276 ATH_MSG_ERROR( "regProxy: no IOVSvcTool associated with store \""
277 << storeName << "\" and failed to create one." );
278 }
279 return sc;
280}
281
282
283/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
284
288
289StatusCode
291 const std::string& storeName ) {
292
293
294 IIOVSvcTool *ist = getTool( storeName );
295 if (ist == 0) {
296 ATH_MSG_ERROR( "preLoadTAD: no IOVSvcTool associated with store \""
297 << storeName << "\" and failed to create one." );
298 return StatusCode::FAILURE;
299 } else {
300 return ist->preLoadTAD( tad );
301 }
302
303}
304
305/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
306
310StatusCode
312 const std::string& storeName ) {
313
314 IIOVSvcTool *ist = getTool( storeName );
315 if (ist == 0) {
316 ATH_MSG_ERROR( "preLoadDataTAD: no IOVSvcTool associated with store \""
317 << storeName << "\" and failed to create one." );
318 return StatusCode::FAILURE;
319 } else {
320 return ist->preLoadDataTAD( tad );
321 }
322
323}
324
325/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
326
327StatusCode
328IOVSvc::setRange(const CLID& clid, const std::string& key,
329 IOVRange& iovr) {
330
331 std::lock_guard<std::recursive_mutex> lock(m_lock);
332
333 IIOVSvcTool *ist = getTool( clid, key );
334 if (ist == 0) {
335
336 // FIXME - this should be eliminated once the IOVDbSvc is set up to
337 // use store names. There should be no default store for setRange
338
339 ATH_MSG_WARNING( "setRange(CLID,key,range) for unregistered proxies "
340 << "is deprecated - you need to specify a store! "
341 << "This will be an ERROR soon!" );
342
343 return setRange(clid,key,iovr, defaultStore );
344
345 } else {
346 return ist->setRange( clid, key, iovr );
347 }
348
349}
350
351/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
352
353StatusCode
354IOVSvc::setRange(const CLID& clid, const std::string& key,
355 IOVRange& iovr, const std::string& storeName) {
356
357 std::lock_guard<std::recursive_mutex> lock(m_lock);
358
359 IIOVSvcTool *ist = getTool( storeName );
360 if (ist == 0) {
361 ATH_MSG_ERROR( "setRange: no IOVSvcTool associated with store \""
362 << storeName << "\" and failed to create one." );
363 return StatusCode::FAILURE;
364 }
365
366 IIOVSvcTool *ist2 = getTool( clid, key );
367 if (ist2 == 0) {
368 ATH_MSG_INFO( "setRange: proxy for " << fullProxyName(clid,key)
369 << " not registered with store \"" << storeName << "\". Doing it now"
370 );
371 if (ist->regProxy(clid, key).isFailure()) {
372 return StatusCode::FAILURE;
373 }
374 } else if (ist2 != ist) {
375 ATH_MSG_INFO( "setRange: when registering proxy (clid: "
376 << clid << " key: " << key << ") with store \"" << storeName
377 << "\" --> already registered with store \"" << ist2->getStoreName()
378 << "\"" );
379 return StatusCode::FAILURE;
380 }
381
382 return ist->setRange( clid, key, iovr );
383
384}
385
386/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
387
388StatusCode
389IOVSvc::dropObjectFromDB(const CLID& clid, const std::string& key,
390 const std::string& storeName) {
391
392 std::lock_guard<std::recursive_mutex> lock(m_lock);
393
394 IIOVSvcTool *ist = getTool( clid, key );
395 if (ist == nullptr) {
396 ATH_MSG_ERROR( "dropObjectFromDB: no IOVSvcTool associated with store "
397 << storeName << " and failed to create one." );
398 return StatusCode::FAILURE;
399 }
400
401 DataProxy* proxy = p_detStore->proxy(clid, key);
402 if (proxy == nullptr) {
403 ATH_MSG_DEBUG("Proxy for (clid: " << clid << " key: " << key << ") in store " << storeName
404 << " does not exist. Cannot drop associated object.");
405 return StatusCode::SUCCESS;
406 }
407
408 // Set IOV in the past to trigger reload on next range check
409 IOVRange iovr(IOVTime(0, 0), IOVTime(0, 0));
410 ATH_CHECK( ist->setRange(clid, key, iovr) );
411
412 IIOVDbSvc *iovDB = dynamic_cast<IIOVDbSvc*>(proxy->provider());
413 if (iovDB != nullptr) {
414 ATH_MSG_DEBUG("Dropping " << key << "via IOVDBSvc");
415 ATH_CHECK( iovDB->dropObject(key, /*resetCache=*/true) );
416 } else {
417 ATH_MSG_ERROR("dropObjectFromDB: Provider for " << key << " is not an IIOVDbSvc.");
418 return StatusCode::FAILURE;
419 }
420
421 return StatusCode::SUCCESS;
422}
423
424
425/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
426
427StatusCode
428IOVSvc::getRange(const CLID& clid, const std::string& key,
429 IOVRange& iov) const {
430
431
432 IIOVSvcTool *ist = getTool( clid, key );
433 if (ist == 0) {
434 ATH_MSG_ERROR( "getRange: proxy for " << fullProxyName(clid,key)
435 << " not registered" );
436 return StatusCode::FAILURE;
437 } else {
438 return ist->getRange( clid, key, iov );
439 }
440
441}
442
443/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
444
445StatusCode
446IOVSvc::getRangeFromDB(const CLID& clid, const std::string& key,
447 IOVRange& range, std::string& tag,
448 std::unique_ptr<IOpaqueAddress>& ioa,
449 const EventIDBase& now) const {
450
451 std::lock_guard<std::recursive_mutex> lock(m_lock);
452
453 IIOVSvcTool *ist = getTool( clid, key );
454 if (ist == 0) {
455 ATH_MSG_ERROR( "getRangeFromDB: proxy for "
456 << fullProxyName(clid,key) << " not registered" );
457 return StatusCode::FAILURE;
458 } else {
459
460 uint32_t event = now.lumi_block();
461 uint32_t run = now.run_number();
462 IOVTime curTime;
463 curTime.setRunEvent(run,event);
464 // get ns timestamp from event
465 curTime.setTimestamp(1000000000L*static_cast<uint64_t>(now.time_stamp()) + now.time_stamp_ns_offset());
466
467
468 return ist->getRangeFromDB( clid, key, range, tag, ioa, curTime );
469 }
470
471}
472
473/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
474
475StatusCode
476IOVSvc::getRangeFromDB(const CLID& clid, const std::string& key,
477 const IOVTime& time, IOVRange& range,
478 std::string& tag,
479 std::unique_ptr<IOpaqueAddress>& ioa) const {
480
481 std::lock_guard<std::recursive_mutex> lock(m_lock);
482
483 IIOVSvcTool *ist = getTool( clid, key );
484 if (ist == 0) {
485 ATH_MSG_ERROR( "getRangeFromDB: proxy for "
486 << fullProxyName(clid, key) << " not registered" );
487 return StatusCode::FAILURE;
488 } else {
489 return ist->getRangeFromDB( clid, key, time, range, tag, ioa );
490 }
491
492}
493
494/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
495
496StatusCode
497IOVSvc::setRangeInDB(const CLID& clid, const std::string& key,
498 const IOVRange& range, const std::string &tag) {
499
500 IIOVSvcTool *ist = getTool( clid, key );
501 if (ist == 0) {
502 ATH_MSG_ERROR( "setRangeInDB: proxy for "
503 << fullProxyName(clid,key) << " not registered" );
504 return StatusCode::FAILURE;
505 } else {
506 return ist->setRangeInDB( clid, key, range, tag );
507 }
508
509}
510
511/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
512
513StatusCode
515 const CallBackID& c,
516 const IOVSvcCallBackFcn& fcn,
517 bool trigger) {
518
519 IIOVSvcTool *ist = getTool( dp );
520 if (ist == 0) {
521 ATH_MSG_ERROR( "regFcn: no IOVSvcTool found containing DataProxy "
522 << fullProxyName( dp )
523 << "-> Need to bind DataHandle first" );
524 return StatusCode::FAILURE;
525 } else {
526 return ist->regFcn( dp, c, fcn, trigger );
527 }
528
529}
530/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
531
532StatusCode
534 const CallBackID& c2, const IOVSvcCallBackFcn& fcn2,
535 bool trigger) {
536
537
538 if (c1 == c2) {
539 ATH_MSG_ERROR( "Cannot register 2nd callback function and assocaited"
540 << " object with itself" );
541 return StatusCode::FAILURE;
542 }
543
544
545 IIOVSvcTool *ist = getTool( c1 );
546 if (ist == 0) {
547 ATH_MSG_ERROR( "CallBack function \"" << c2.name()
548 << "\" cannot be registered since function \"" << c1.name()
549 << "\" has not been registered first" );
550 return StatusCode::FAILURE;
551 } else {
552 return ist->regFcn(c1, c2, fcn2, trigger);
553 }
554
555}
556
557/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
558
559StatusCode
560IOVSvc::regFcn(const std::string& toolName,
561 const CallBackID& c2, const IOVSvcCallBackFcn& fcn2,
562 bool trigger) {
563
564 IAlgTool *ia;
565 if ( p_toolSvc->retrieveTool(toolName, ia, 0, false).isFailure() ) {
566 ATH_MSG_ERROR( "AlgTool " << toolName << " has not yet been created"
567 << " and thus cannot be registered" );
568 return StatusCode::FAILURE;
569 }
570
571 IIOVSvcTool *ist = getTool( ia );
572 if (ist == 0) {
573 ATH_MSG_ERROR( "No callback registered with AlgTool " << toolName );
574 return StatusCode::FAILURE;
575 } else {
576 return ist->regFcn(ia, c2, fcn2, trigger);
577 }
578
579}
580
581/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
582
583StatusCode
584IOVSvc::getTriggeredTools(const std::string& key,
585 std::set<std::string>& tools,
586 const std::string& storeName) {
587
588 IIOVSvcTool *ist = getTool( storeName, false );
589 if (ist == 0) {
590 ATH_MSG_ERROR( "getTriggeredTools: no store \"" << storeName
591 << "\" associated with any IOVSvcTool" );
592 return StatusCode::FAILURE;
593 } else {
594 return ist->getTriggeredTools(key, tools);
595 }
596
597}
598
599
600/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
601
602StatusCode
604{
605 // Set flag to reset all proxies
606 StatusCode sc;
607 toolMap::iterator itr = m_toolMap.begin();
608 for ( ; itr!=m_toolMap.end(); ++itr) {
609 sc &= itr->second->reinitialize();
610 }
611 return sc;
612
613}
614
615
616
617/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
618
619StatusCode
620IOVSvc::createIOVTool( const std::string& storeName, IIOVSvcTool*& ist ) {
621
622 std::string store(storeName);
623 std::string toolName("IOVSvcTool");
624 if (storeName == "default") store = defaultStore;
625
626 // Append the store name if not default
627 if (store != defaultStore) {
628 toolName += '_';
629 toolName += store;
630 }
631
632 ATH_MSG_DEBUG( "Creating " << toolName << " associated with store \"" << store
633 << "\"" );
634
635 toolMap::iterator itr = m_toolMap.find( store );
636 if ( itr == m_toolMap.end() ) {
637 ist = nullptr;
638 if (p_toolSvc->retrieveTool( "IOVSvcTool/" + toolName, ist, this ).isFailure()) {
639 ATH_MSG_ERROR( "Unable to create IOVSvcTool associated with store \""
640 << store << "\"" );
641 return StatusCode::FAILURE;
642 } else {
643 m_toolMap[ store ] = ist;
644 ist->setStoreName( store );
645 return StatusCode::SUCCESS;
646 }
647 } else {
648 ATH_MSG_INFO( "an IOVSvcTool already exists associated with store \""
649 << store << "\"" );
650 ist = itr->second;
651 return StatusCode::SUCCESS;
652 }
653
654}
655 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
656
657StatusCode
658IOVSvc::createIOVTool( const std::string& storeName )
659{
660 IIOVSvcTool* ist = nullptr;
661 return createIOVTool (storeName, ist);
662}
663
664
665/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
666
668IOVSvc::getTool( const std::string& storeName, bool createIF ) {
669
670 std::string store(storeName);
671 if (storeName == "default") {
672 store = defaultStore;
673 }
674
675 toolMap::const_iterator itr = m_toolMap.find( store );
676 IIOVSvcTool *ist(0);
677 if ( itr == m_toolMap.end() ) {
678 ATH_MSG_INFO( "No IOVSvcTool associated with store \"" << store
679 << "\"" );
680
681 if (createIF) {
682 createIOVTool(store, ist).ignore();
683 }
684
685 } else {
686 ist = itr->second;
687 }
688
689 return ist;
690}
691
692/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
693
695IOVSvc::getTool( DataProxy* proxy ) const {
696
697
698 IIOVSvcTool *ist(0);
699 toolMap::const_iterator itr = m_toolMap.begin();
700 for (; itr != m_toolMap.end(); ++itr) {
701 if (itr->second->holdsProxy( proxy )) {
702 ist = itr->second;
703 return ist;
704 }
705 }
706
707 return ist;
708
709}
710
711/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
712
714IOVSvc::getTool( const CLID& clid, const std::string& key ) const {
715
716 IIOVSvcTool *ist(0);
717 toolMap::const_iterator itr = m_toolMap.begin();
718 for (; itr != m_toolMap.end(); ++itr) {
719 if (itr->second->holdsProxy( clid, key )) {
720 ist = itr->second;
721 return ist;
722 }
723 }
724
725 return ist;
726
727}
728
729/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
730
732IOVSvc::getTool( const CallBackID& c1 ) const {
733
734 IIOVSvcTool *ist(0);
735 toolMap::const_iterator itr = m_toolMap.begin();
736 for (; itr != m_toolMap.end(); ++itr) {
737 if (itr->second->holdsCallback( c1 )) {
738 ist = itr->second;
739 return ist;
740 }
741 }
742
743 return ist;
744
745}
746/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
747
749IOVSvc::getTool( const IAlgTool* ia ) const {
750
751 IIOVSvcTool *ist(0);
752 toolMap::const_iterator itr = m_toolMap.begin();
753 for (; itr != m_toolMap.end(); ++itr) {
754 if (itr->second->holdsAlgTool( ia )) {
755 ist = itr->second;
756 return ist;
757 }
758 }
759
760 return ist;
761
762}
763
764/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
765
766std::string
768
769 return fullProxyName(dp->clID(), dp->name());
770
771}
772
773/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
774
775std::string
776IOVSvc::fullProxyName( const CLID& clid, const std::string& key ) const {
777
778 std::string fullname, tname;
779 if (p_CLIDSvc->getTypeNameOfID( clid, tname ).isFailure()) {
780 fullname = "[";
781 fullname += std::to_string(clid);
782 fullname += '/';
783 fullname += key;
784 fullname += ']';
785 } else {
786 fullname = "[";
787 fullname += tname;
788 fullname += ':';
789 fullname += std::to_string(clid);
790 fullname += '/';
791 fullname += key;
792 fullname += ']';
793 }
794
795 return fullname;
796}
797
798/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
799
800std::vector<std::string>
802
803 std::vector<std::string> stores;
804
805 toolMap::const_iterator itr = m_toolMap.begin();
806 for( ; itr!=m_toolMap.end(); ++itr) {
807 stores.push_back( itr->first );
808 }
809
810 return stores;
811
812}
813
814/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
815
816void
818
819 toolMap::iterator itr = m_toolMap.begin();
820 for (; itr!= m_toolMap.end(); ++itr) {
821 IIOVSvcTool* ist = itr->second;
822 ATH_MSG_DEBUG( "resetting all proxies for store \""
823 << ist->getStoreName() << "\"" );
824 ist->resetAllProxies();
825 }
826
827}
828
829/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
830
831StatusCode
832IOVSvc::createCondObj(CondContBase* ccb, const DataObjID& id,
833 const EventIDBase& now) {
834
835 ATH_MSG_DEBUG("createCondObj: id: " << id << " t: " << now << " valid: "
836 << ccb->valid(now));
837
838 if (ccb->valid(now)) {
839 if (msgLvl(MSG::DEBUG)) {
840 EventIDRange r;
841 ccb->range(now,r);
842 ATH_MSG_DEBUG( " range " << r << " for " << id
843 << " is still valid at " << now );
844 }
845 return StatusCode::SUCCESS;
846 }
847
848 IOVTime t(now.run_number(), now.lumi_block(), (long long)now.time_stamp()*1000000000+now.time_stamp_ns_offset());
849 IOVRange range;
850 std::string tag;
851 // remove storename from key
852 std::string sgKey = id.key();
853 auto sep = sgKey.find('+');
854 if (sep != std::string::npos) {
855 sgKey.erase(0,sep+1);
856 }
857
858 std::unique_ptr<IOpaqueAddress> ioa;
859 if (getRangeFromDB(id.clid(), sgKey, t, range, tag, ioa).isFailure()) {
860 ATH_MSG_ERROR( "unable to get range from db for time " << t << " clid "
861 << id.clid() << " " << sgKey );
862 return StatusCode::FAILURE;
863 }
864
865 //In case the conditons-container is a 'mixed' type, we need both run/lb and time-stamps in the range.
866 //Assume infinite IOV in the other dimension
867 EventIDRange eidRange(range);
869 eidRange=EventIDRange::intersect(IOVInfiniteRange::infiniteMixed(),eidRange);
870 }
871 ATH_MSG_DEBUG( " new range for ID " << id << " : " << range
872 << " IOA: " << ioa.get());
873
874 // If the start of the new range matches the start of the last range, then
875 // extend the last range rather than trying to insert a new range.
876 // This can happen when a folder is tagged as `extensible' in IOVDbSvc.
877 EventIDRange r;
878 if (ccb->range (eidRange.start(), r) &&
879 eventIDMatch (r.start(), eidRange.start()))
880 {
881 if (ccb->extendLastRange (eidRange).isSuccess()) {
882 return StatusCode::SUCCESS;
883 }
884 }
885
886 if (ccb->proxy() == nullptr) {
887 // nb. We don't want to be holding the IOVSvc lock here,
888 // as SGImplSvc can call to IOVSvc with the store lock held.
889 SG::DataProxy* dp = p_detStore->proxy (id.clid(), sgKey);
890 ATH_MSG_DEBUG( " found DataProxy " << dp << " for " << id );
891 ccb->setProxy(dp);
892 }
893
894 // this will talk to the IOVDbSvc, get current run/event from EventInfo
895 // object, load
896 SG::DataProxy* dp = ccb->proxy();
897 DataObject* dobj(0);
898 void* v(0);
899
900 if (dp->store()->createObj(dp->loader(), ioa.get(), dobj).isFailure()) {
901 ATH_MSG_ERROR(" could not create a new DataObject ");
902 return StatusCode::FAILURE;
903 } else {
904 ATH_MSG_DEBUG(" created new obj at " << dobj );
905
906 v = SG::Storable_cast(dobj, id.clid());
907 }
908
909 // Free the DataBucket that was created along with the object we read.
910 if (DataBucketBase* dbb = dynamic_cast<DataBucketBase*> (dobj)) {
911 dbb->relinquish();
912 delete dobj;
913 dobj = 0;
914 }
915
916 // Some data objects may be reference counted by the address.
917 // CondCont will take ownership of the object, but doesn't
918 // do refcounting. We'll have gotten a reference via the Storable_cast
919 // above, so it should be ok ... unless CondCont deletes
920 // the new object immediately instead of inserting.
921 // In that case, when we delete the address, it will
922 // follow an invalid pointer. So be sure to delete
923 // the address before the object is added to CondCont.
924 ioa.reset();
925
926 // DataObject *d2 = static_cast<DataObject*>(v);
927
928 ATH_MSG_DEBUG( " SG::Storable_cast to obj: " << v );
929
930 StatusCode sc = ccb->typelessInsert (eidRange, v);
931 if (!sc.isSuccess()) {
932 ATH_MSG_ERROR("unable to insert Object at " << v << " into CondCont "
933 << ccb->id() << " for range " << eidRange );
934 return StatusCode::FAILURE;
935 }
937 // Disable this for now... IOVDbSvc can sometimes produce overlapping
938 // ranges.
939 //ATH_MSG_ERROR ("IOV range overlap.");
940 //return StatusCode::FAILURE;
941 }
942
943 return sc;
944
945}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
uint32_t CLID
The Class ID type.
Abstract interface to IOVDbSvc to access IOVRange and tag information.
boost::function< StatusCode(IOVSVC_CALLBACK_ARGS) > IOVSvcCallBackFcn
the type of an IOVSvc call back: it wraps both the method and the object the method is called on
Definition IOVSvcDefs.h:58
const std::string defaultStore
Definition IOVSvc.cxx:33
static Double_t sc
static bool isOverlap(code_t code)
Helper to test whether a code is OVERLAP.
Definition CondCont.cxx:242
Base class for all conditions containers.
Definition CondCont.h:140
void setProxy(SG::DataProxy *)
Set the associated DataProxy.
Definition CondCont.cxx:276
@ MIXED
Mixed Run+lbn / timestamp container.
Definition CondCont.h:192
virtual StatusCode typelessInsert(const EventIDRange &r, void *obj, const EventContext &ctx=Gaudi::Hive::currentContext())=0
Insert a new conditions object.
virtual StatusCode extendLastRange(const EventIDRange &newRange, const EventContext &ctx=Gaudi::Hive::currentContext())=0
Extend the range of the last IOV.
virtual bool valid(const EventIDBase &t) const =0
Test to see if a given IOV time is mapped in the container.
KeyType keyType() const
Return the key type for this container.
virtual bool range(const EventIDBase &t, EventIDRange &r) const =0
Return the mapped validity range for an IOV time.
SG::DataProxy * proxy()
Return the associated DataProxy, if any.
const DataObjID & id() const
Return CLID/key corresponding to this container.
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
Abstract interface to IOVDbSvc to access IOVRange and tag information.
Definition IIOVDbSvc.h:38
virtual bool dropObject(const std::string &key, const bool resetCache=false)=0
virtual StatusCode getRangeFromDB(const CLID &clid, const std::string &key, IOVRange &range, std::string &tag, std::unique_ptr< IOpaqueAddress > &ioa, const IOVTime &curTime) const =0
virtual void setStoreName(const std::string &storeName)=0
virtual StatusCode regFcn(SG::DataProxy *dp, const CallBackID &c, const IOVSvcCallBackFcn &fcn, bool trigger)=0
virtual StatusCode setRangeInDB(const CLID &clid, const std::string &key, const IOVRange &range, const std::string &tag)=0
virtual void resetAllProxies()=0
virtual StatusCode setRange(const CLID &clid, const std::string &key, IOVRange &)=0
virtual StatusCode preLoadTAD(const SG::TransientAddress *)=0
virtual StatusCode preLoadDataTAD(const SG::TransientAddress *)=0
virtual StatusCode replaceProxy(SG::DataProxy *pOld, SG::DataProxy *pNew)=0
virtual StatusCode regProxy(SG::DataProxy *proxy, const std::string &key)=0
virtual const std::string & getStoreName() const =0
virtual void ignoreProxy(SG::DataProxy *proxy)=0
virtual StatusCode getTriggeredTools(const std::string &key, std::set< std::string > &tools)=0
virtual StatusCode deregProxy(SG::DataProxy *proxy)=0
virtual StatusCode getRange(const CLID &clid, const std::string &key, IOVRange &iov) const =0
static EventIDRange infiniteMixed()
Produces an mixed EventIDRange that is infinite in Time and RunLumi.
Validity Range object.
Definition IOVRange.h:30
virtual StatusCode preLoadDataTAD(const SG::TransientAddress *, const std::string &storeName) override
supply a list of TADs whose data will be preloaded
Definition IOVSvc.cxx:311
virtual ~IOVSvc()
Definition IOVSvc.cxx:87
virtual std::vector< std::string > getStoreNames() const override
Definition IOVSvc.cxx:801
virtual StatusCode createIOVTool(const std::string &storeName) override
Definition IOVSvc.cxx:658
ServiceHandle< StoreGateSvc > p_detStore
Definition IOVSvc.h:180
virtual StatusCode preLoadTAD(const SG::TransientAddress *, const std::string &storeName) override
supply a list of TADs whose proxies will be preloaded
Definition IOVSvc.cxx:290
std::string m_updateInterval
Definition IOVSvc.h:176
virtual StatusCode finalize() override
Definition IOVSvc.cxx:118
IOVSvc(const std::string &name, ISvcLocator *svc)
Definition IOVSvc.cxx:66
toolMap m_toolMap
Definition IOVSvc.h:171
virtual StatusCode getRange(const CLID &clid, const std::string &key, IOVRange &io) const override
Definition IOVSvc.cxx:428
BooleanProperty m_sortKeys
Definition IOVSvc.h:175
BooleanProperty m_preLoadData
Definition IOVSvc.h:174
virtual StatusCode replaceProxy(SG::DataProxy *pOld, SG::DataProxy *pNew, const std::string &storeName) override
replace a registered DataProxy with a new version
Definition IOVSvc.cxx:268
BooleanProperty m_partialPreLoadData
Definition IOVSvc.h:174
ServiceHandle< IClassIDSvc > p_CLIDSvc
Definition IOVSvc.h:179
virtual void resetAllProxies() override
Definition IOVSvc.cxx:817
virtual StatusCode deregProxy(SG::DataProxy *proxy) override
Deregister a DataProxy with the service.
Definition IOVSvc.cxx:205
virtual StatusCode setRange(const CLID &clid, const std::string &key, IOVRange &) override
Update Range from dB.
Definition IOVSvc.cxx:328
std::recursive_mutex m_lock
Definition IOVSvc.h:185
IIOVSvcTool * getTool(const std::string &storeName, bool createIF=true)
Definition IOVSvc.cxx:668
virtual StatusCode regFcn(SG::DataProxy *dp, const CallBackID &c, const IOVSvcCallBackFcn &fcn, bool trigger=false) override
register callback functions
Definition IOVSvc.cxx:514
virtual StatusCode getRangeFromDB(const CLID &clid, const std::string &key, IOVRange &range, std::string &tag, std::unique_ptr< IOpaqueAddress > &ioa, const EventIDBase &now) const override
Get IOVRange from db for current event.
Definition IOVSvc.cxx:446
ServiceHandle< StoreGateSvc > p_sgs
Definition IOVSvc.h:180
virtual StatusCode setRangeInDB(const CLID &clid, const std::string &key, const IOVRange &range, const std::string &tag) override
Set a particular IOVRange in db (and memory)
Definition IOVSvc.cxx:497
virtual StatusCode regProxy(SG::DataProxy *proxy, const std::string &key, const std::string &storeName) override
Subscribe method for DataProxy. key StoreGate key.
Definition IOVSvc.cxx:130
virtual StatusCode getTriggeredTools(const std::string &key, std::set< std::string > &tools, const std::string &storeName) override
return list of tools (or functions) that have been triggered by key will return FAILURE if no tools f...
Definition IOVSvc.cxx:584
virtual StatusCode createCondObj(CondContBase *, const DataObjID &, const EventIDBase &) override
Definition IOVSvc.cxx:832
BooleanProperty m_forceReset
Definition IOVSvc.h:175
ServiceHandle< IToolSvc > p_toolSvc
Definition IOVSvc.h:178
virtual void ignoreProxy(const CLID &clid, const std::string &key, const std::string &storeName) override
ignore proxy
Definition IOVSvc.cxx:247
virtual StatusCode reinitialize() override
Definition IOVSvc.cxx:603
BooleanProperty m_preLoadRanges
Definition IOVSvc.h:174
virtual StatusCode initialize() override
Definition IOVSvc.cxx:93
std::string fullProxyName(const SG::DataProxy *proxy) const
Definition IOVSvc.cxx:767
virtual StatusCode dropObjectFromDB(const CLID &clid, const std::string &key, const std::string &storeName) override
Drop the associated object from the db and trigger reload.
Definition IOVSvc.cxx:389
BooleanProperty m_preLoadExtensibleFolders
Definition IOVSvc.h:174
ServiceHandle< ICondSvc > p_condSvc
Definition IOVSvc.h:181
Basic time unit for IOVSvc.
Definition IOVTime.h:33
void setRunEvent(uint32_t run, uint32_t event) noexcept
Definition IOVTime.cxx:96
void setTimestamp(uint64_t timestamp) noexcept
Definition IOVTime.cxx:72
int r
Definition globals.cxx:22
T * Storable_cast(DataObject *pDObj, bool quiet=true, IRegisterTransient *irt=0, bool isConst=true)
Definition run.py:1
MsgStream & msg
Definition testRead.cxx:32