|
ATLAS Offline Software
|
Go to the documentation of this file.
12 #include "Gaudi/Interfaces/IOptionsSvc.h"
13 #include "GaudiKernel/IIncidentSvc.h"
14 #include "GaudiKernel/Guards.h"
15 #include "GaudiKernel/IOpaqueAddress.h"
16 #include "GaudiKernel/IProperty.h"
17 #include "GaudiKernel/IIoComponentMgr.h"
38 return thisPair.first.front() ==
'/';
44 :
public cool::IDatabase
47 LockedDatabase (cool::IDatabasePtr dbptr,
49 virtual ~LockedDatabase();
51 virtual const cool::DatabaseId& databaseId()
const override
52 {
return m_dbptr->databaseId(); }
54 virtual const cool::IRecord& databaseAttributes()
const override
55 {
return m_dbptr->databaseAttributes(); }
57 virtual cool::IFolderSetPtr createFolderSet
60 bool createParents =
false )
override
63 virtual bool existsFolderSet(
const std::string& folderSetName )
override
64 {
return m_dbptr->existsFolderSet (folderSetName); }
66 virtual cool::IFolderSetPtr getFolderSet(
const std::string&
fullPath )
override
67 {
return m_dbptr->getFolderSet (
fullPath); }
73 bool createParents =
false )
override
76 virtual bool existsFolder(
const std::string&
fullPath )
override
77 {
return m_dbptr->existsFolder (
fullPath); }
79 virtual cool::IFolderPtr getFolder(
const std::string&
fullPath )
override
80 {
return m_dbptr->getFolder (
fullPath); }
82 virtual const std::vector<std::string> listAllNodes(
bool ascending =
true )
override
83 {
return m_dbptr->listAllNodes (
ascending); }
85 virtual bool dropNode(
const std::string&
fullPath )
override
86 {
return m_dbptr->dropNode (
fullPath); }
88 virtual bool existsTag(
const std::string& tagName )
const override
89 {
return m_dbptr->existsTag (tagName); }
92 {
return m_dbptr->tagNameScope (tagName); }
94 virtual const std::vector<std::string>
95 taggedNodes(
const std::string& tagName )
const override
96 {
return m_dbptr->taggedNodes (tagName); }
98 virtual bool isOpen()
const override
99 {
return m_dbptr->isOpen(); }
102 {
return m_dbptr->openDatabase(); }
104 virtual void closeDatabase()
override
105 {
return m_dbptr->closeDatabase(); }
107 virtual const std::string& databaseName()
const override
108 {
return m_dbptr->databaseName(); }
111 virtual ITransactionPtr startTransaction()
override
113 {
return m_dbptr->startTransaction(); }
118 cool::IDatabasePtr m_dbptr;
123 LockedDatabase::LockedDatabase (cool::IDatabasePtr dbptr,
125 : m_dbptr (std::move(dbptr)),
131 LockedDatabase::~LockedDatabase()
150 ATH_MSG_INFO(
"Opened read transaction for POOL PersistencySvc");
153 ATH_MSG_INFO(
"Cannot connect to POOL PersistencySvc" );
163 if (StatusCode::SUCCESS!=incSvc.retrieve()) {
165 return StatusCode::FAILURE;
168 incSvc->addListener(
this,
"BeginEvent", pri );
169 incSvc->addListener(
this,
"StoreCleared", pri );
170 incSvc->addListener(
this, IncidentType::EndProcessing, pri );
174 if (!iomgr.retrieve().isSuccess()) {
176 return(StatusCode::FAILURE);
178 if (!iomgr->io_register(
this).isSuccess()) {
179 ATH_MSG_FATAL(
"Could not register myself with the IoComponentMgr !");
180 return(StatusCode::FAILURE);
184 ATH_MSG_INFO(
"COOL connection management disabled - connections kept open throughout job" );
186 ATH_MSG_INFO(
"POOL file connection management disabled - files kept open throught job" );
196 ATH_MSG_INFO(
"Run-LB data will be cached in groups of " <<
203 ATH_MSG_INFO(
"Online mode ignoring potential missing channels outside cache" );
211 if (StatusCode::SUCCESS!=
checkEventSel())
return StatusCode::FAILURE;
230 if (StatusCode::SUCCESS!=
setupFolders())
return StatusCode::FAILURE;
235 " connections and " <<
m_foldermap.size() <<
" folders" );
239 ATH_MSG_INFO(
"Service IOVDbSvc initialised successfully" );
242 return StatusCode::SUCCESS;
250 return(StatusCode::SUCCESS);
255 return(StatusCode::SUCCESS);
262 typedef std::map<IOVDbConn*,float> CTMap;
267 const float& fread=
folder->readTime();
271 if (citr!=ctmap.end()) {
272 (citr->second)+=fread;
274 ctmap.insert(CTMap::value_type(cptr,fread));
278 ATH_MSG_INFO(
" bytes in (( " << std::fixed << std::setw(9) << std::setprecision(2) <<
279 readtime <<
" ))s" );
285 if (citr!=ctmap.end()) fread=citr->second;
286 pThisConnection->setInactive();
287 pThisConnection->summary(fread);
288 delete pThisConnection;
297 cool::IDatabasePtr
dbconn;
299 ATH_MSG_INFO(
"No default COOL database connection is available");
304 ATH_MSG_INFO(
"Changing state of default connection to readonly=" << readOnly );
325 unsigned int ncontainers=0;
326 unsigned int nused=0;
327 for (;cont!=contEnd; ++cont) {
329 const std::string&
fname=cont->folderName();
333 if (thisNamePtrPair.second->folderName()==
fname && !(thisNamePtrPair.second->tagOverride())) {
335 thisNamePtrPair.second->useFileMetaData();
336 thisNamePtrPair.second->setFolderDescription( cont->folderDescription() );
342 ATH_MSG_INFO(
"Found " << ncontainers <<
" metadata containers in input file, " << nused <<
" will be used");
344 ATH_MSG_DEBUG(
"Could not retrieve IOVMetaDataContainer objects from MetaDataStore" );
353 std::vector<std::string> keysToDelete;
355 if (thisNamePtrPair.second->fromMetaDataOnly() && !thisNamePtrPair.second->readMeta()) {
356 ATH_MSG_INFO(
"preLoadAddresses: Removing folder " << thisNamePtrPair.second->folderName() <<
357 ". It should only be in the file meta data and was not found." );
358 keysToDelete.push_back(thisNamePtrPair.first);
362 for (
auto & thisKey : keysToDelete) {
365 fitr->second->conn()->decUsage();
366 delete (fitr->second);
369 ATH_MSG_ERROR(
"preLoadAddresses: Could not find folder " << thisKey <<
" for removal" );
382 if (pThisConnection->nFolders()>0 || doMeta) {
386 if (
folder->conn()==pThisConnection || (
folder->conn()==
nullptr && doMeta)) {
387 std::unique_ptr<SG::TransientAddress> tad =
390 if (oldconn!=pThisConnection) {
393 oldconn=pThisConnection;
397 return StatusCode::FAILURE;
400 if (
folder->writeMeta()) {
401 if (StatusCode::SUCCESS!=
m_h_IOVSvc->preLoadDataTAD(tad.get(),
folder->eventStore())) {
402 ATH_MSG_ERROR(
"Could not request IOVSvc to preload metadata for " <<
folder->folderName() );
403 return StatusCode::FAILURE;
407 if (StatusCode::SUCCESS!=
m_h_IOVSvc->preLoadTAD(tad.get(),
folder->eventStore())) {
408 ATH_MSG_ERROR(
"Could not request IOVSvc to preload metadata for " <<
folder->folderName() );
409 return StatusCode::FAILURE;
413 tlist.push_back(tad.release());
430 newmap[thisNamePtrPair.second->key()]=thisNamePtrPair.second;
435 ATH_MSG_ERROR(
"Could not fill TagInfo object from preLoadAddresses" );
436 return StatusCode::SUCCESS;
441 return StatusCode::SUCCESS;
446 const EventContext& )
452 Gaudi::Guards::AuditorGuard auditor(std::string(
"UpdateAddr::")+(tad->
name().empty() ?
"anonymous" : tad->
name()),
453 auditorSvc(),
"preLoadProxy");
457 std::unique_ptr<IOpaqueAddress>
address;
462 const std::string&
key=tad->
name();
466 "updateAddress cannot find description for TAD " <<
key );
467 return StatusCode::FAILURE;
472 <<
" but expecting " <<
folder->clid() );
474 return StatusCode::FAILURE;
480 ATH_MSG_DEBUG(
"updateAddress: in initialisation phase and no iovTime defined" );
481 return::StatusCode::SUCCESS;
487 iovTime.setRunEvent( evid->run_number(), evid->lumi_block()) ;
489 uint64_t nsTime = evid->time_stamp() *1000000000LL;
490 nsTime += evid->time_stamp_ns_offset();
491 iovTime.setTimestamp(nsTime);
493 ATH_MSG_DEBUG(
"updateAddress - using iovTime from EventInfo: " << iovTime);
497 return StatusCode::SUCCESS;
500 ATH_MSG_DEBUG(
"updateAddress: using iovTime from init/beginRun: " << iovTime);
506 cool::ValidityKey vkey=
folder->iovTime(iovTime);
520 folder->setDropped(
false);
525 <<
". You may see errors from other folders sharing the same connection." );
526 return StatusCode::FAILURE;
533 Gaudi::Guards::AuditorGuard auditor(std::string(
"FldrSetup:")+(tad->
name().empty() ?
"anonymous" : tad->
name()),
534 auditorSvc(),
"preLoadProxy");
538 return StatusCode::FAILURE;
543 if (
folder->timeStamp()) {
544 cool::ValidityKey
start=
range.start().timestamp();
554 return StatusCode::FAILURE;
557 return StatusCode::SUCCESS;
563 const std::string& dbKey,
567 std::unique_ptr<IOpaqueAddress>&
address) {
571 ATH_MSG_DEBUG(
"getRange clid: " << clid <<
" key: \""<< dbKey <<
"\" t: " <<
time );
572 const std::string&
key=dbKey;
576 return StatusCode::FAILURE;
579 if (
folder->clid()!=clid) {
582 <<
" but expecting " <<
folder->clid() );
584 return StatusCode::FAILURE;
593 folder->setDropped(
false);
598 <<
". You may see errors from other folders sharing the same connection." );
599 return StatusCode::FAILURE;
607 Gaudi::Guards::AuditorGuard auditor(std::string(
"FldrSetup:")+(
key.empty() ?
"anonymous" :
key),
608 auditorSvc(),
"preLoadProxy");
612 return StatusCode::FAILURE;
617 if (
folder->extensible()) {
620 if (
folder->timeStamp()) {
630 if (
folder->iovOverridden()) {
631 if (
folder->timeStamp()) {
641 return StatusCode::SUCCESS;
649 const std::string& ) {
651 return StatusCode::SUCCESS;
655 const EventContext& ctx)
670 if (conditionsRun != EventIDBase::UNDEFNUM) {
676 return StatusCode::SUCCESS;
681 ATH_MSG_DEBUG(
"Same run as previous signalBeginRun call. Skipping re-loading of folders..." );
682 return StatusCode::SUCCESS;
698 if (pThisConnection->nFolders()>0) {
700 cool::IDatabasePtr
dbconn=pThisConnection->getCoolDb();
701 if (
dbconn.get()==
nullptr) {
702 ATH_MSG_FATAL(
"Conditions database connection " << pThisConnection->name() <<
" cannot be opened - STOP" );
703 return StatusCode::FAILURE;
707 if (
folder->conn()!=pThisConnection)
continue;
711 Gaudi::Guards::AuditorGuard auditor(std::string(
"FldrCache:")+
folder->folderName(), auditorSvc(),
"preLoadProxy");
714 return StatusCode::FAILURE;
722 return StatusCode::SUCCESS;
740 ATH_MSG_DEBUG(
"Successfully closed input POOL connections");
746 ATH_MSG_DEBUG(
"Reopend read transaction for POOL conditions input files" );
748 ATH_MSG_WARNING(
"Cannot reopen read transaction for POOL conditions input files");
758 ATH_MSG_VERBOSE(
"entering handle(), incident type " << inc.type() <<
" from " << inc.source() );
759 if (inc.type()==
"BeginEvent") {
765 if( (inc.type()==
"StoreCleared" && sinc!=
nullptr && sinc->
store()==&*
m_h_sgSvc)
766 or inc.type()==IncidentType::EndProcessing )
791 for (
const auto & thisNameTagPair: nameTagPairs) {
793 if (not refersToConditionsFolder(thisNameTagPair))
continue;
797 const std::string& ifname=
folder->folderName();
798 if (ifname!=thisNameTagPair.first)
continue;
802 const auto &
theTag{thisNameTagPair.second};
807 const std::string_view tagTypeString=(
folder->joTag().empty()) ?
"hierarchical" :
"jobOption";
808 ATH_MSG_INFO(
"Ignoring inputfile TagInfo request for tag " <<
theTag <<
" in folder " << ifname<<
" in favour of "<<tagTypeString);
812 return StatusCode::SUCCESS;
815 std::vector<std::string>
818 std::vector<std::string>
keys;
830 info.folderName =
f->folderName();
831 info.tag =
f->resolvedTag();
832 info.range =
f->currentRange();
833 info.retrieved =
f->retrieved();
834 info.bytesRead =
f->bytesRead();
835 info.readTime =
f->readTime();
836 info.extensible =
f->extensible();
839 info.retrieved =
false;
851 if (
proxy!=
nullptr) {
880 if (!joSvc->has(
"EventSelector.OverrideRunNumber")) {
883 ATH_MSG_DEBUG(
"No EventSelector.OverrideRunNumber property found" );
884 return StatusCode::SUCCESS;
887 BooleanProperty bprop(
"OverrideRunNumber",
false);
888 ATH_CHECK( bprop.fromString(joSvc->get(
"EventSelector.OverrideRunNumber")) );
891 ATH_MSG_INFO(
"Setting run/LB/time from EventSelector override in initialize" );
898 IntegerProperty iprop1(
"RunNumber",0);
899 if (iprop1.fromString(joSvc->get(
"EventSelector.RunNumber",
"INVALID"))) {
902 ATH_MSG_ERROR(
"Unable to get RunNumber from EventSelector");
905 IntegerProperty iprop2(
"FirstLB",0);
906 if (iprop2.fromString(joSvc->get(
"EventSelector.FirstLB",
"INVALID"))) {
907 lumib=iprop2.value();
912 IntegerProperty iprop3(
"InitialTimeStamp",0);
913 if (iprop3.fromString(joSvc->get(
"EventSelector.InitialTimeStamp",
"INVALID"))) {
916 ATH_MSG_ERROR(
"Unable to get InitialTimeStamp from EventSelector" );
923 ATH_MSG_INFO(
"run/LB/time set to [" <<
run <<
"," << lumib <<
" : " << nsTime <<
"]" );
929 return StatusCode::SUCCESS;
944 std::list<IOVDbParser> allFolderdata;
949 ATH_MSG_FATAL(
"setupFolders: Folder setup string is invalid: " <<thisFolder);
950 return StatusCode::FAILURE;
953 allFolderdata.push_back(folderdata);
964 if (not
keys.isValid()){
965 ATH_MSG_ERROR(
"An override tag was invalid: " << thisOverrideTag);
966 return StatusCode::FAILURE;
970 ATH_MSG_ERROR(
"Problem in overrideTag specification " <<thisOverrideTag );
971 return StatusCode::FAILURE;
974 for (
auto& folderdata : allFolderdata) {
975 const std::string& ifname=folderdata.folderName();
977 (ifname.size()==
prefix.size() || ifname[
prefix.size()]==
'/')) {
979 folderdata.applyOverrides(
keys,
msg());
994 it2=allFolderdata.erase(it2);
1009 for (
const auto& folderdata : allFolderdata) {
1014 if (folderdata.getKey(
"db",
"",
connstr) ||
1015 folderdata.getKey(
"dbConnection",
"",
connstr)) {
1019 if (pThisConnection->name()==
connstr) {
1021 conn=pThisConnection;
1025 if (
conn==
nullptr) {
1035 ATH_MSG_FATAL(
"Folder request " << folderdata.folderName() <<
1036 " gives no DB connection information and no default set" );
1037 return StatusCode::FAILURE;
1044 std::string crestTag =
"";
1058 " associated to already requested Storegate key " <<
key );
1066 std::string_view
match=folderToWrite;
1067 std::string::size_type
idx=folderToWrite.find(
'*');
1068 if (
idx!=std::string::npos) {
1069 match=std::string_view(folderToWrite).substr(0,
idx);
1074 fptr->setWriteMeta();
1075 ATH_MSG_INFO(
"Folder " <<
fptr->folderName() <<
" will be written to file metadata" );
1079 return StatusCode::SUCCESS;
1086 return StatusCode::FAILURE;
1092 if (!
folder->joTag().empty()) {
1095 return StatusCode::FAILURE;
1104 if (StatusCode::SUCCESS!=
1107 <<
folder->folderName() );
1114 return StatusCode::SUCCESS;
1121 Gaudi::Guards::AuditorGuard auditor(std::string(
"loadCachesOverhead:")+
conn->name(), auditorSvc(),
"preLoadProxy");
1125 if (
m_abort)
return StatusCode::FAILURE;
1128 for (
const auto & thisNamePtrPair :
m_foldermap) {
1133 if (vkey>cool::ValidityKeyMax) {
1134 ATH_MSG_WARNING(
"Requested validity key " << vkey <<
" is out of range, reset to 0" );
1140 Gaudi::Guards::AuditorGuard auditor(std::string(
"FldrCache:")+
folder->folderName(), auditorSvc(),
"preLoadProxy");
1145 sc=StatusCode::FAILURE;
1154 if (
conn->aborted()) {
1155 ATH_MSG_FATAL(
"Connection " <<
conn->name() <<
" was aborted, set global abort" );
1169 const std::string_view tagstub=std::string_view(
m_globalTag).substr(0,7);
1172 (tagstub!=
"COMCOND" && tagstub!=
"CONDBR2")) ||
1173 (
m_par_dbinst==
"OFLP200" && (tagstub!=
"OFLCOND" && tagstub!=
"CMCCOND"))) {
1174 ATH_MSG_FATAL(
"Likely incorrect conditions DB configuration! "
1176 " but global tag begins " << tagstub );
1177 ATH_MSG_FATAL(
"See Atlas/CoolTroubles wiki for details," <<
1178 " or set IOVDbSvc.DBInstance=\"\" to disable check" );
1179 return StatusCode::FAILURE;
1182 return StatusCode::SUCCESS;
virtual void postConditionsLoad() override
May be called once conditions are loaded to let IOVDbSvc release resources.
JetConstituentVector::iterator iterator
virtual StatusCode initialize() override
Service init.
virtual StatusCode preLoadAddresses(StoreID::type storeID, tadList &list) override
Get all addresses that the provider wants to preload in SG maps.
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.
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Validity Range object. Holds two IOVTimes (start and stop)
static constexpr uint32_t MAXRUN
BooleanProperty m_crestCoolToFile
Validity Range object. Holds two IOVTime instances (start and stop)
uint32_t event() const noexcept
EventIDBase::number_type conditionsRun() const
virtual cool::IDatabasePtr getDatabase(bool readOnly) override
Access to COOL database for a given folder.
IntegerProperty m_par_maxNumPoolFiles
int run(int argc, char *argv[])
virtual void signalEndProxyPreload() override
Signal that callback has been fired.
ServiceHandle< IPoolSvc > m_h_poolSvc
void commit()
Save catalog to file.
FloatProperty m_par_timeStampSlop
virtual bool dropObject(const std::string &key, const bool resetCache=false) override
StatusCode io_reinit() override final
IAddressProvider::tadList tadList
BooleanProperty m_par_manageConnections
#define ATH_MSG_VERBOSE(x)
bool isValid() const noexcept
BooleanProperty m_crestToFile
ServiceHandle< StoreGateSvc > m_h_metaDataStore
ServiceHandle< IClassIDSvc > m_h_clidSvc
static constexpr uint32_t MINRUN
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
const std::string & name() const
Get the primary (hashed) SG key.
IntegerProperty m_par_forceRunNumber
Basic time unit for IOVSvc. Hold time as a combination of run and event numbers.
Athena service for Interval Of Validity database.
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.
IntegerProperty m_par_forceLumiblockNumber
virtual StatusCode processTagInfo() override
Process TagInfo.
std::vector< NameTagPair > NameTagPairVec
std::vector< HWIdentifier >::iterator it1
::StatusCode StatusCode
StatusCode definition for legacy code.
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
Update a transient Address.
UnsignedIntegerProperty m_par_cacheAlign
StringProperty m_par_crestServer
CLID clID() const
Retrieve string key:
StatusCode checkEventSel()
std::pair< std::string, std::string > NameTagPair
static constexpr uint64_t MAXTIMESTAMP
std::map< std::string, std::string > m_cresttagmap
BooleanProperty m_par_managePoolConnections
Gaudi::Property< std::string > m_par_defaultConnection
void setRETime(uint64_t time) noexcept
virtual std::vector< std::string > getKeyList() override
def openDatabase(dbstring)
std::vector< TFile * > fptr
void setTimestamp(uint64_t timestamp) noexcept
ServiceHandle< ITagInfoMgr > m_h_tagInfoMgr
uint32_t CLID
The Class ID type.
def access(filename, mode)
bool allGood
Loop over the SDOs & Digits.
BooleanProperty m_par_onlineMode
static constexpr uint32_t MAXEVENT
std::map< std::string, IOVDbFolder * > FolderMap
BooleanProperty m_par_checklock
virtual void handle(const Incident &incident) override
Incident service handle for EndEvent.
StatusCode io_finalize() override final
uint32_t run() const noexcept
const StoreGateSvc * store() const
Return the store that was cleared.
Gaudi::Property< std::vector< std::string > > m_par_overrideTags
BooleanProperty m_outputToFile
Incident sent after a store is cleared.
ServiceHandle< IAddressCreator > m_h_persSvc
static constexpr uint32_t MINEVENT
IntegerProperty m_par_cacheRun
void setAddress(IOpaqueAddress *pAddress)
Retrieve primary clid.
def createFolder(db, name)
Gaudi::Property< std::string > m_par_globalTag
Gaudi::Property< std::string > m_par_dbinst
bool m_poolPayloadRequested
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.
def time(flags, cells_name, *args, **kw)
#define ATH_MSG_WARNING(x)
Gaudi::Property< std::vector< std::string > > m_par_folders
virtual StatusCode finalize() override
Service finalize.
void setRunEvent(uint32_t run, uint32_t event) noexcept
const EventIDBase * EventIDFromStore(IProxyDict *store)
Retrieve the EventID from EventContext saved in store STORE.
Filled by IIOVDbSvc::getKeyInfo.
static constexpr uint64_t MINTIMESTAMP
#define ATLAS_THREAD_SAFE
ServiceHandle< StoreGateSvc > m_h_detStore
cool::ValidityKey m_iovslop
StatusCode loadCaches(IOVDbConn *conn, const IOVTime *time=nullptr)
Define macros for attributes used to control the static checker.
StatusCode setupFolders()
ServiceHandle< IIOVSvc > m_h_IOVSvc
virtual StatusCode signalBeginRun(const IOVTime &beginRunTime, const EventContext &ctx) override
Set time for begin run.
StringProperty m_par_source
ServiceHandle< StoreGateSvc > m_h_sgSvc
Gaudi::Property< std::vector< std::string > > m_par_foldersToWrite
std::map< std::string, std::string > getGlobalTagMap(const std::string &globaltag)
virtual StatusCode loadAddresses(StoreID::type storeID, tadList &list) override
Get all new addresses from Provider for this Event.
bool match(std::string s1, std::string s2)
match the individual directories of two strings
PublicToolHandle< IIOVDbMetaDataTool > m_h_metaDataTool
IntegerProperty m_par_forceTimestamp
StatusCode checkConfigConsistency() const
std::string description
glabal timer - how long have I taken so far?
IntegerProperty m_par_cacheTime
Incident sent after a store is cleared.