ATLAS Offline Software
Loading...
Searching...
No Matches
MetaDataSvc Class Reference

Manages the content of the metadata stores. More...

#include <MetaDataSvc.h>

Inheritance diagram for MetaDataSvc:

Classes

class  ToolLockGuard

Public Member Functions

 MetaDataSvc (const std::string &name, ISvcLocator *pSvcLocator)
 Standard Service Constructor.
virtual ~MetaDataSvc ()
 Destructor.
virtual StatusCode prepareOutput ()
 Makes the metadata store ready for output.
virtual void handle (const Incident &incident) override
 react to file incidents.
StatusCode transitionMetaDataFile (const std::string &outputConn, bool disconnect)
 Transition output metadata file - fire MeteDataStop incident to transition OutputStream and disconnect now if requested.
virtual StatusCode io_reinit () override
 Implements IIoComponent interface sets m_outputPrepared to false and prints some information.
StatusCode rootOpenAction (FILEMGR_CALLBACK_ARGS)
virtual StoreGateSvcoutputDataStore () const override final
virtual const std::string currentRangeID () const override final
CLID remapMetaContCLID (const CLID &item_id) const
void lockTools () const
void unlockTools () const
void recordHook (const std::type_info &) override
void removeHook (const std::type_info &) override
std::string removeStreamFromKey (std::string &key)
 check if the metadata object key contains Stream name (added by SharedWriter in MetaDataSvc) remove stream part from the key (i.e.
virtual std::set< std::string > getPerStreamKeysFor (const std::string &key) const override final
 Get all per-stream Key variants created for in-file metadata object with original key If no stream-specific keys are found, it returns the original key.
virtual StatusCode initialize () override
 initialize the metadata service at the beginning of the job
virtual StatusCode stop () override
 stop the metadata service
virtual StatusCode finalize () override
 finalize the metadata service at the end of the job
virtual StatusCode newMetadataSource (const Incident &)
 Fills the input metadata store with the content of the new input file.
virtual StatusCode retireMetadataSource (const Incident &)
 Allows metadata tools to act before an input file is closed.
virtual StatusCode prepareOutput (const std::string &outputName)
 Makes the metadata store ready for output with SharedWriter Calls the metaDataStop method of all MetaDataTool interfaces in m_metaDataTool.
virtual StatusCode shmProxy (const std::string &tokenStr) override
 Loads file metadata from memory shared between streams in SharedWriter This function clears the input and output metadata stores.
StatusCode preLoadAddresses (StoreID::type, IAddressProvider::tadList &) override
 does nothing.
StatusCode loadAddresses (StoreID::type storeID, IAddressProvider::tadList &tads) override
 loads addresses of versioned metadata object.
StatusCode updateAddress (StoreID::type, SG::TransientAddress *, const EventContext &) override
 always fails

Private Member Functions

StatusCode addProxyToInputMetaDataStore (const std::string &tokenStr)
StatusCode initInputMetaDataStore (const std::string &fileName)
 Initialize input metadata store - can be called directly or via BeginInputFile incident.

Private Attributes

ServiceHandle< StoreGateSvcm_inputDataStore
ServiceHandle< StoreGateSvcm_outputDataStore
ServiceHandle< IAddressCreator > m_addrCrtr { this, "ConversionService", "AthenaPoolCnvSvc" }
ServiceHandle< IFileMgr > m_fileMgr
ServiceHandle< IIncidentSvc > m_incSvc
ServiceHandle< OutputStreamSequencerSvcm_outSeqSvc
ServiceHandle< IClassIDSvc > m_classIDSvc {"ClassIDSvc", name()}
long m_storageType {0L}
bool m_clearedInputDataStore {true}
bool m_clearedOutputDataStore {false}
bool m_allowMetaDataStop {false}
bool m_beginInputFileSeen {false}
bool m_outputPrepared {false}
std::map< std::string_view, CLIDm_persToClid {}
std::set< CLIDm_handledClasses {}
std::map< std::string, std::set< std::string > > m_streamKeys {}
Gaudi::Property< std::string > m_metaDataCont {this, "MetaDataContainer", ""}
 MetaDataContainer, POOL container name for MetaData.
PublicToolHandleArray< IMetaDataToolm_metaDataTools {this, "MetaDataTools", {}}
 MetaDataTools, vector with the MetaData tools.

Static Private Attributes

static constexpr std::string_view m_streamInKeyMark {"__STREAM["}
 marker string for embedding stream name in MetaData object keys for SharedWriter server

Detailed Description

Manages the content of the metadata stores.

This service orchestrates the reading of metadata from input files and its propagation to the output with the help of the IMetaDataTool interfaces in m_metaDataTools. The MetaDataSvc reacts to BeginInputFile and EndInputFile incidents. It relies on the AthenaPoolCnvSvc (or whatever persistency service) to call the the appropriate prepareOutput method when committing the MetaDataStore content to the output file.

On BeginInputFile it clears the InputMetaDataStore and populates it with content from the new input file. The beginInputFile methods of all tools are called to allow required actions on the metadata objects.

On EndInputFile the MetaDataSvc calls the endInputFile methods of all the interfaces in m_metaDataTools .

In jobs with multiple parallel output streams (SharedWriter) the metadata content from multiple streams is put into the output MetaDataStore. To do this the The MetaDataSvc accesses the memory shared with the output streams, and adds the content of their MetaDataStore to the shared InputMetaDataStore. This is done by the client calling shmProxy for each object to be added to the MetaDataStore. Afterwards the client must also fire BeginInputFile and EndInputFile incidents to allow the MetaDataTools to move their objects from the InputMetaDataStore to the MetaDataStore taking care of possible merges.

Example configuration:

ca = ComponentAccumulator()
ca.addService(CompFactory.StoreGateSvc("MetaDataStore"))
ca.addService(CompFactory.StoreGateSvc("InputMetaDataStore"))
metaDataSvc = CompFactory.MetaDataSvc("MetaDataSvc")
ca.addService(
CompFactory.ProxyProviderSvc(ProviderNames=["MetaDataSvc"]))
metaDataSvc.MetaDataTools += [someMetaDataTool]
See also
IMetaDataTool
AthenaPoolCnvSvc

Definition at line 84 of file MetaDataSvc.h.

Constructor & Destructor Documentation

◆ MetaDataSvc()

MetaDataSvc::MetaDataSvc ( const std::string & name,
ISvcLocator * pSvcLocator )

Standard Service Constructor.

Definition at line 52 of file MetaDataSvc.cxx.

53 : base_class( name, pSvcLocator )
54 , m_inputDataStore( "StoreGateSvc/InputMetaDataStore", name )
55 , m_outputDataStore( "StoreGateSvc/MetaDataStore", name )
56 , m_fileMgr( "FileMgr", name )
57 , m_incSvc( "IncidentSvc", name )
58 , m_outSeqSvc( "OutputStreamSequencerSvc", name )
59 , m_persToClid{ { "DataHeader_p5", 222376821 },
60 { "EventStreamInfo_p3", 167728019 },
61 { "ByteStreamMetadataContainer_p1", 1076128893 },
62 { "IOVMetaDataContainer_p1", 1316383046 },
63 { "xAOD::EventFormat_v1", 243004407 },
64 { "xAOD::CutBookkeeperContainer_v1", 1234982351 },
65 { "xAOD::CutBookkeeperAuxContainer_v1", 1147935274 },
66 { "xAOD::TriggerMenuContainer_v1", 1107011239 },
67 { "DataVector<xAOD::TriggerMenu_v1>", 1107011239 },
68 { "xAOD::TriggerMenuAuxContainer_v1", 1212409402 },
69 { "xAOD::TriggerMenuJsonContainer_v1", 1221262614 },
70 { "DataVector<xAOD::TriggerMenuJson_v1>", 1221262614 },
71 { "xAOD::TriggerMenuJsonAuxContainer_v1", 373045213 },
72 { "xAOD::LumiBlockRangeContainer_v1", 1115934851 },
73 { "DataVector<xAOD::LumiBlockRange_v1>", 1115934851 },
74 { "xAOD::LumiBlockRangeAuxContainer_v1", 1251061086 },
75 { "xAOD::FileMetaData_v1", 178309087 },
76 { "xAOD::FileMetaDataAuxInfo_v1", 73252552 },
77 { "xAOD::RingSetConfContainer_v1", 1157997427 },
78 { "DataVector<xAOD::RingSetConf_v1>", 1157997427 },
79 { "xAOD::RingSetConfAuxContainer_v1", 1307745126 },
80 { "xAOD::TruthMetaDataContainer_v1", 1188015687 },
81 { "DataVector<xAOD::TruthMetaData_v1>", 1188015687 },
82 { "xAOD::TruthMetaDataAuxContainer_v1", 1094306618 } } {}
ServiceHandle< OutputStreamSequencerSvc > m_outSeqSvc
ServiceHandle< StoreGateSvc > m_outputDataStore
ServiceHandle< StoreGateSvc > m_inputDataStore
std::map< std::string_view, CLID > m_persToClid
ServiceHandle< IIncidentSvc > m_incSvc
ServiceHandle< IFileMgr > m_fileMgr

◆ ~MetaDataSvc()

MetaDataSvc::~MetaDataSvc ( )
virtualdefault

Destructor.

Member Function Documentation

◆ addProxyToInputMetaDataStore()

StatusCode MetaDataSvc::addProxyToInputMetaDataStore ( const std::string & tokenStr)
private

Definition at line 424 of file MetaDataSvc.cxx.

424 {
425 std::string fileName = tokenStr.substr(tokenStr.find("[FILE=") + 6);
426 leftString(fileName, ']');
427 std::string className = tokenStr.substr(tokenStr.find("[PNAME=") + 7);
428 leftString(className, ']');
429 std::string contName = tokenStr.substr(tokenStr.find("[CONT=") + 6);
430 leftString(contName,']');
431 std::size_t pos1 = contName.find('(');
432 std::string keyName = contName.substr(pos1 + 1, contName.size() - pos1 - 2);
433 std::size_t pos2 = keyName.find('/');
434 if (pos2 != std::string::npos) keyName = keyName.substr(pos2 + 1);
435 std::string numName = tokenStr.substr(tokenStr.find("[NUM=") + 5);
436 leftString(numName,']');
437 unsigned long num = 0;
438 std::istringstream iss(numName);
439 iss >> num;
440 CLID clid = m_persToClid[className];
441
442 // make stream-unique keys for infile metadata objects
443 // AthenaOutputStream will use this to distribute objects to the right stream (and restore the original key)
444 if( clid == 178309087 ) { // FileMetaData
445 std::string newName = std::format("{}{}{}{}", keyName, m_streamInKeyMark, fileName, "]");
446 ATH_MSG_DEBUG("Recording " << keyName << " as " << newName);
447 m_streamKeys[keyName].insert(newName);
448 keyName = std::move(newName);
449 }
450 if( clid == 73252552 ) { // FileMetaDataAuxInfo
451 std::string newName = std::format("{}{}{}]{}",
454 fileName,
456 ATH_MSG_DEBUG("Recording " << keyName << " as " << newName);
457 m_streamKeys[keyName].insert(newName);
458 keyName = std::move(newName);
459 }
460 const std::string par[3] = { "SHM" , keyName , std::move(className) };
461 const unsigned long ipar[2] = { num , 0 };
462 IOpaqueAddress* opqAddr = nullptr;
463 SG::DataProxy* dp = m_inputDataStore->proxy(clid, keyName);
464 if (dp != nullptr) {
465 ATH_MSG_DEBUG("Resetting duplicate proxy for: " << clid << "#" << keyName << " from file: " << fileName);
466 dp->reset();
467 }
468 if (!m_addrCrtr->createAddress(m_storageType, clid, par, ipar, opqAddr).isSuccess()) {
469 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot create address for " << tokenStr);
470 return(StatusCode::FAILURE);
471 }
472 if (m_inputDataStore->recordAddress(keyName, opqAddr).isFailure()) {
473 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot create proxy for " << tokenStr);
474 return(StatusCode::FAILURE);
475 }
476 if (m_inputDataStore->accessData(clid, keyName) == nullptr) {
477 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot access data for " << tokenStr);
478 return(StatusCode::FAILURE);
479 }
480 if (keyName.find(RootAuxDynIO::AUX_POSTFIX) != std::string::npos
481 && m_inputDataStore->symLink(clid, keyName, 187169987).isFailure()) {
482 ATH_MSG_WARNING("addProxyToInputMetaDataStore: Cannot symlink to AuxStore for " << tokenStr);
483 }
484 return(StatusCode::SUCCESS);
485}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_FATAL(x,...)
uint32_t CLID
The Class ID type.
long m_storageType
std::map< std::string, std::set< std::string > > m_streamKeys
static constexpr std::string_view m_streamInKeyMark
marker string for embedding stream name in MetaData object keys for SharedWriter server
ServiceHandle< IAddressCreator > m_addrCrtr
constexpr char AUX_POSTFIX[]
Common post-fix for the names of auxiliary containers in StoreGate.

◆ currentRangeID()

const std::string MetaDataSvc::currentRangeID ( ) const
finaloverridevirtual

Definition at line 556 of file MetaDataSvc.cxx.

557{
558 const EventContext& ctx = Gaudi::Hive::currentContext();
559 return m_outSeqSvc.isValid()? m_outSeqSvc->currentRangeID(ctx) : "";
560}

◆ finalize()

StatusCode MetaDataSvc::finalize ( )
overridevirtual

finalize the metadata service at the end of the job

Definition at line 142 of file MetaDataSvc.cxx.

142 {
143 // Release IncidentService
144 if (!m_incSvc.release().isSuccess()) {
145 ATH_MSG_WARNING("Cannot release IncidentService.");
146 }
147 // Release FileMgr
148 if (!m_fileMgr.release().isSuccess()) {
149 ATH_MSG_WARNING("Cannot release FileMgr.");
150 }
151 // Release AddressCreator
152 if (!m_addrCrtr.release().isSuccess()) {
153 ATH_MSG_WARNING("Cannot release AddressCreator.");
154 }
155 // Release OutputMetaDataStore
156 if (!m_outputDataStore.release().isSuccess()) {
157 ATH_MSG_WARNING("Cannot release OutputMetaDataStore.");
158 }
159 // Release InputMetaDataStore
160 if (!m_inputDataStore.release().isSuccess()) {
161 ATH_MSG_WARNING("Cannot release InputMetaDataStore.");
162 }
164 ATH_MSG_WARNING("EndInputFile was not received before finalize");
165 }
166 return(StatusCode::SUCCESS);
167}
bool m_beginInputFileSeen
bool m_allowMetaDataStop

◆ getPerStreamKeysFor()

std::set< std::string > MetaDataSvc::getPerStreamKeysFor ( const std::string & key) const
nodiscardfinaloverridevirtual

Get all per-stream Key variants created for in-file metadata object with original key If no stream-specific keys are found, it returns the original key.

Definition at line 416 of file MetaDataSvc.cxx.

416 {
417 if (!m_streamKeys.contains(key)) {
418 return {key};
419 }
420 return m_streamKeys.at(key);
421}

◆ handle()

void MetaDataSvc::handle ( const Incident & incident)
overridevirtual

react to file incidents.

calls newMetadataSource on BeginInputFile and retireMetadataSource on EndInputFile. Does

Parameters
incidentis expected to be BeginInputFile or EndInputFile

Definition at line 328 of file MetaDataSvc.cxx.

328 {
329 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
330 if (fileInc == nullptr) {
331 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
332 return;
333 }
334 const std::string fileName = fileInc->fileName();
335 ATH_MSG_DEBUG("handle() " << inc.type() << " for " << fileName);
336
337 if (inc.type() == "FirstInputFile") {
338 // Register open/close callback actions
339 using namespace std::placeholders;
340 Io::bfcn_action_t boa = std::bind(&MetaDataSvc::rootOpenAction, this, _1, _2);
341 if (m_fileMgr->regAction(std::move(boa), Io::OPEN).isFailure()) {
342 ATH_MSG_FATAL("Cannot register ROOT file open action with FileMgr.");
343 }
344 if (!initInputMetaDataStore(fileName).isSuccess()) {
345 ATH_MSG_WARNING("Unable to initialize InputMetaDataStore");
346 }
347 } else if (inc.type() == "BeginInputFile" || inc.type() == "BeginInputMemFile") {
348 if(newMetadataSource(inc).isFailure()) {
349 ATH_MSG_ERROR("Could not process new metadata source " << fileName);
350 }
351 } else if (inc.type() == "EndInputFile" || inc.type() == "EndInputMemFile") {
352 if(retireMetadataSource(inc).isFailure()) {
353 ATH_MSG_ERROR("Could not retire metadata source " << fileName);
354 }
355 }
356}
#define ATH_MSG_ERROR(x,...)
virtual StatusCode newMetadataSource(const Incident &)
Fills the input metadata store with the content of the new input file.
StatusCode rootOpenAction(FILEMGR_CALLBACK_ARGS)
virtual StatusCode retireMetadataSource(const Incident &)
Allows metadata tools to act before an input file is closed.
StatusCode initInputMetaDataStore(const std::string &fileName)
Initialize input metadata store - can be called directly or via BeginInputFile incident.

◆ initialize()

StatusCode MetaDataSvc::initialize ( )
overridevirtual

initialize the metadata service at the beginning of the job

Definition at line 88 of file MetaDataSvc.cxx.

88 {
89 ATH_MSG_INFO("Initializing " << name());
90
91 // Retrieve InputMetaDataStore
92 ATH_CHECK( m_inputDataStore.retrieve() );
93 // Retrieve OutputMetaDataStore
94 ATH_CHECK( m_outputDataStore.retrieve() );
95 // Retrieve AddressCreator
96 ATH_CHECK( m_addrCrtr.retrieve() );
97
98 AthCnvSvc* cnvSvc = dynamic_cast<AthCnvSvc*>(m_addrCrtr.operator->());
99 if (cnvSvc) {
100 m_storageType = cnvSvc->repSvcType();
101 } else {
102 ATH_MSG_WARNING("Cannot get ConversionSvc Interface.");
103 }
104 // Get FileMgr
105 ATH_CHECK( m_fileMgr.retrieve() );
106
107 // Set to be listener for end of event
108 ATH_CHECK( m_incSvc.retrieve() );
109
110 ATH_CHECK( m_metaDataTools.retrieve() );
111 ATH_MSG_INFO("Found " << m_metaDataTools);
112
113 m_incSvc->addListener(this, "FirstInputFile", 80, true);
114 m_incSvc->addListener(this, "BeginInputFile", 80, true);
115 m_incSvc->addListener(this, "EndInputFile", 10, true);
116 m_incSvc->addListener(this, "BeginInputMemFile", 80, true);
117 m_incSvc->addListener(this, "EndInputMemFile", 10, true);
118
119 // Register this service for 'I/O' events
120 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", this->name());
121 ATH_CHECK( iomgr.retrieve() );
122 ATH_CHECK( iomgr->io_register(this) );
123
124 ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc", name());
125 if (!joSvc.retrieve().isSuccess()) {
126 ATH_MSG_WARNING("Cannot get JobOptionsSvc.");
127 } else {
128 if (joSvc->has("EventSelector.InputCollections")) {
129 // Get EventSelector to force in-time initialization and FirstInputFile incident
130 ServiceHandle<IEvtSelector> evtsel("EventSelector", this->name());
131 if (!evtsel.retrieve().isSuccess()) {
132 ATH_MSG_WARNING("Cannot get EventSelector.");
133 }
134 }
135 }
136 // retrieve the output sequences service (EventService) if available
137 m_outSeqSvc.retrieve().ignore();
138
139 return(StatusCode::SUCCESS);
140}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x,...)
virtual long repSvcType() const override
Retrieve the class type of the data store the converter uses.
PublicToolHandleArray< IMetaDataTool > m_metaDataTools
MetaDataTools, vector with the MetaData tools.

◆ initInputMetaDataStore()

StatusCode MetaDataSvc::initInputMetaDataStore ( const std::string & fileName)
private

Initialize input metadata store - can be called directly or via BeginInputFile incident.

Definition at line 487 of file MetaDataSvc.cxx.

487 {
488 ATH_MSG_DEBUG("initInputMetaDataStore: file name " << fileName);
490 // Load proxies for InputMetaDataStore
491 if (m_metaDataCont.value().empty()) {
492 ATH_MSG_DEBUG("MetaDataSvc called without MetaDataContainer set.");
493 return(StatusCode::SUCCESS);
494 }
495 if (fileName.starts_with( "BSF:")) {
496 ATH_MSG_DEBUG("MetaDataSvc called for non ROOT file.");
497 } else if (fileName.compare(0, 3, "SHM")==0) {
498 ATH_MSG_DEBUG("MetaDataSvc called for shared memory.");
499 } else {
500 const std::string par[2] = {
501 fileName,
502 std::format("{}(DataHeader)", m_metaDataCont.value())
503 };
504 const std::string parOld[2] = {
505 fileName,
506 std::format("{}{}", m_metaDataCont.value(), "DataHeader")
507 };
508 for (int verNumber = 0; verNumber < 100; verNumber++) {
509 SG::VersionedKey myVersKey(name(), verNumber);
510 if (m_inputDataStore->contains<DataHeader>(myVersKey)) {
511 ATH_MSG_DEBUG("initInputMetaDataStore: MetaData Store already contains DataHeader, key = " << myVersKey);
512 } else {
513 const unsigned long ipar[2] = { (unsigned long)verNumber , 0 };
514 IOpaqueAddress* opqAddr = nullptr;
515 if (!m_addrCrtr->createAddress(m_storageType, ClassID_traits<DataHeader>::ID(), par, ipar, opqAddr).isSuccess()) {
516 if (!m_addrCrtr->createAddress(m_storageType, ClassID_traits<DataHeader>::ID(), parOld, ipar, opqAddr).isSuccess()) {
517 break;
518 }
519 }
520 if (m_inputDataStore->recordAddress(myVersKey, opqAddr).isFailure()) {
521 ATH_MSG_WARNING("initInputMetaDataStore: Cannot create proxy for DataHeader, key = " << myVersKey);
522 }
523 }
524 }
525 std::list<SG::TransientAddress*> tList;
527 for (SG::TransientAddress* tad : tList) {
528 CLID clid = tad->clID();
529 ATH_MSG_VERBOSE("initInputMetaDataStore: add proxy for clid = " << clid << ", key = " << tad->name());
530 if (m_inputDataStore->contains(tad->clID(), tad->name())) {
531 ATH_MSG_DEBUG("initInputMetaDataStore: MetaData Store already contains clid = " << clid << ", key = " << tad->name());
532 } else {
533 if (!m_inputDataStore->recordAddress(tad->name(), tad->address())) {
534 ATH_MSG_ERROR("initInputMetaDataStore: Cannot create proxy for clid = " << clid << ", key = " << tad->name());
535 return StatusCode::FAILURE;
536 }
537 }
538
539 for (CLID tclid : tad->transientID()) {
540 if (tclid != clid) {
541 if (m_inputDataStore->symLink (clid, tad->name(), tclid).isFailure()) {
542 ATH_MSG_WARNING("Cannot make autosymlink from " <<
543 clid << "/" << tad->name() << " to " << tclid);
544 }
545 }
546 }
547 delete tad;
548 }
549 tList.clear();
550 }
551 ATH_MSG_DEBUG("Loaded input meta data store proxies");
552 return(StatusCode::SUCCESS);
553}
#define ATH_MSG_VERBOSE(x,...)
StatusCode loadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
loads addresses of versioned metadata object.
Gaudi::Property< std::string > m_metaDataCont
MetaDataContainer, POOL container name for MetaData.
bool m_clearedInputDataStore
@ METADATA_STORE
Definition StoreID.h:29

◆ io_reinit()

StatusCode MetaDataSvc::io_reinit ( )
overridevirtual

Implements IIoComponent interface sets m_outputPrepared to false and prints some information.

Returns
SUCCESS
See also
IIoComponent

Definition at line 387 of file MetaDataSvc.cxx.

387 {
388 ATH_MSG_INFO("I/O reinitialization...");
389 ATH_MSG_DEBUG("Dumping InputMetaDataStore: " << m_inputDataStore->dump());
390 ATH_MSG_DEBUG("Dumping OutputMetaDataStore: " << m_outputDataStore->dump());
391 for (const auto& tool : m_metaDataTools) {
392 ATH_MSG_INFO("Attached MetaDataTool: " << tool->name());
393 }
394 m_outputPrepared = false;
395 return(StatusCode::SUCCESS);
396}
bool m_outputPrepared

◆ loadAddresses()

StatusCode MetaDataSvc::loadAddresses ( StoreID::type storeID,
IAddressProvider::tadList & tads )
override

loads addresses of versioned metadata object.

loops over all versions of the DataHeader and adds addresses of objects from DataHeaderElements to the tads with a version corresponding to version number of the DataHeader that contained them.

See also
ObjectWithVersion
DataHeader
Parameters
storeID[IN] the identity of the store
tads[OUT] list of addresses to objects from versions keys
Returns
FAILURE the DataHeader could not be retrieved, else SUCCESS

Definition at line 179 of file MetaDataSvc.cxx.

179 {
180 if (storeID != StoreID::METADATA_STORE) { // should this (also) run in the INPUT_METADATA_STORE?
181 return(StatusCode::SUCCESS);
182 }
183 // Put Additional MetaData objects into Input MetaData Store using VersionedKey
184 std::list<SG::ObjectWithVersion<DataHeader> > allVersions;
185 StatusCode sc = m_inputDataStore->retrieveAllVersions(allVersions, name());
186 if (!sc.isSuccess()) {
187 ATH_MSG_WARNING("Could not retrieve all versions for DataHeader, will not read Metadata");
188 } else {
189 int verNumber = -1;
190 for (SG::ObjectWithVersion<DataHeader>& obj : allVersions) {
191 ++verNumber;
192 const DataHeader* dataHeader = obj.dataObject.cptr();
193 if (dataHeader == nullptr) {
194 ATH_MSG_ERROR("Could not get DataHeader, will not read Metadata");
195 return(StatusCode::FAILURE);
196 }
197 for (const DataHeaderElement& dhe : *dataHeader) {
198 const CLID clid = dhe.getPrimaryClassID();
199 if (clid != ClassID_traits<DataHeader>::ID()) {
200 SG::VersionedKey myVersObjKey(dhe.getKey(), verNumber);
201 std::string key = dhe.getKey();
202 if (verNumber != 0) {
203 key = myVersObjKey;
204 }
205 tads.push_back(dhe.getAddress(m_storageType, key));
206 }
207 }
208 }
209 }
210 return(StatusCode::SUCCESS);
211}
static Double_t sc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ lockTools()

void MetaDataSvc::lockTools ( ) const

Definition at line 608 of file MetaDataSvc.cxx.

608 {
609 ATH_MSG_DEBUG("Locking metadata tools");
610 for(auto& tool : m_metaDataTools ) {
611 const ILockableTool *lockable = dynamic_cast<const ILockableTool*>( tool.get() );
612 if( lockable ) lockable->lock_shared();
613 }
614}
virtual void lock_shared() const =0
Lock the tool.

◆ newMetadataSource()

StatusCode MetaDataSvc::newMetadataSource ( const Incident & inc)
virtual

Fills the input metadata store with the content of the new input file.

Once the GUID and name of the input file are determined from the incident this function blocks stopping the MetaDataSvc by setting m_allowMetaDataStop to false. Then attempts first to clear the input metadata store and prepare it for the metadata tools by calling initInputMetaDataStore. The loops over all MetaDataTool interfaces in m_metaDataTools and calls their beginInputFile implementations.

See also
initInputMetaDataStore()
m_metaDataTools
Parameters
incThe BeginInputFile incident fired on opening a new file
Returns
FAILURE when inc is not a file incident, the input metadata store cannot be set up, or a MetaDataTool fails. Otherwise SUCCESS.

Definition at line 213 of file MetaDataSvc.cxx.

214{
215 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
216 if (fileInc == nullptr) {
217 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
218 return StatusCode::FAILURE;
219 }
220 const std::string guid = fileInc->fileGuid();
221 const std::string fileName = fileInc->fileName();
222 m_allowMetaDataStop = false;
224 if (!fileName.starts_with( "BSF:")) {
225 // the input file is _not_ bytestream
227 if (!m_inputDataStore->clearStore().isSuccess()) {
228 ATH_MSG_WARNING("Unable to clear input MetaData Proxies");
229 }
231 }
233 }
234 StatusCode rc{StatusCode::SUCCESS};
235 for (auto& tool : m_metaDataTools) {
236 ATH_MSG_DEBUG(" calling beginInputFile on " << tool->name() << " for GUID \"" << guid << "\"");
237 if (tool->beginInputFile(guid).isFailure()) {
238 ATH_MSG_ERROR("Unable to call beginInputFile for " << tool->name());
239 rc = StatusCode::FAILURE;
240 }
241 }
242 return rc;
243}
static Double_t rc

◆ outputDataStore()

virtual StoreGateSvc * MetaDataSvc::outputDataStore ( ) const
inlinefinaloverridevirtual

Definition at line 235 of file MetaDataSvc.h.

235 {
236 return &*m_outputDataStore;
237 }

◆ preLoadAddresses()

StatusCode MetaDataSvc::preLoadAddresses ( StoreID::type ,
IAddressProvider::tadList &  )
inlineoverride

does nothing.

Parameters
storeID[IN] store ID, this function only preloads detector store addresses.
tads[OUT] list of the transient addresses which were preloaded.
Returns
SUCCESS

Definition at line 184 of file MetaDataSvc.h.

185 {
186 return StatusCode::SUCCESS;
187 }

◆ prepareOutput()

StatusCode MetaDataSvc::prepareOutput ( )
virtual

Makes the metadata store ready for output.

Calls the metaDataStop method of all MetaDataTool interfaces in m_metaDataTool. Then release the metadata tools. This implementation assumes SharedWriter is not being used.

Returns
SUCCESS unless a MetaDataTool fails, then FAILURE

Definition at line 262 of file MetaDataSvc.cxx.

263{
264 if (m_outputPrepared) {
265 return StatusCode::SUCCESS;
266 }
267
268 StatusCode rc{StatusCode::SUCCESS};
269 for (auto& tool : m_metaDataTools) {
270 ATH_MSG_DEBUG(" calling metaDataStop for " << tool->name());
271 if (tool->metaDataStop().isFailure()) {
272 ATH_MSG_ERROR("Unable to call metaDataStop for " << tool->name());
273 rc = StatusCode::FAILURE;
274 }
275 }
276 if (!m_metaDataTools.release().isSuccess()) {
277 ATH_MSG_WARNING("Cannot release " << m_metaDataTools);
278 }
279
280 m_outputPrepared = true;
281 return rc;
282}

◆ recordHook()

void MetaDataSvc::recordHook ( const std::type_info & typeInfo)
override

Definition at line 583 of file MetaDataSvc.cxx.

583 {
584 const std::string& typeName = System::typeinfoName(typeInfo);
585 ATH_MSG_VERBOSE("Handling record event of type " << typeName);
586
587 CLID itemID = 0;
588 if (m_classIDSvc->getIDOfTypeInfoName(typeName, itemID).isSuccess()) {
589 auto result = m_handledClasses.insert(itemID);
590 if (result.second)
591 ATH_MSG_DEBUG("MetaDataSvc will handle " << typeName
592 << " ClassID: " << itemID);
593 }
594}
std::set< CLID > m_handledClasses
ServiceHandle< IClassIDSvc > m_classIDSvc

◆ remapMetaContCLID()

CLID MetaDataSvc::remapMetaContCLID ( const CLID & item_id) const

Definition at line 563 of file MetaDataSvc.cxx.

564{
565 if (!m_handledClasses.contains(itemID)) {
566 ATH_MSG_DEBUG("Not translating metadata item ID #" << itemID);
567 return itemID;
568 }
569
570 std::string itemName;
571 CLID contID = 0;
572 if (m_classIDSvc->getTypeNameOfID(itemID, itemName).isSuccess()) {
573 const std::string contName = std::format("MetaCont<{}>", itemName);
574 ATH_MSG_DEBUG("Transforming " << contName << " to " << itemName
575 << " for output");
576 if (m_classIDSvc->getIDOfTypeName(contName, contID).isSuccess())
577 return contID;
578 }
579
580 return itemID;
581}

◆ removeHook()

void MetaDataSvc::removeHook ( const std::type_info & typeInfo)
override

Definition at line 596 of file MetaDataSvc.cxx.

596 {
597 const std::string& typeName = System::typeinfoName(typeInfo);
598 ATH_MSG_VERBOSE("Handling removal event of type " << typeName);
599
600 CLID itemID = 0;
601 if (m_classIDSvc->getIDOfTypeInfoName(typeName, itemID).isSuccess()) {
602 if (0 < m_handledClasses.erase(itemID))
603 ATH_MSG_DEBUG("MetaDataSvc will no longer handle " << typeName
604 << " ClassID: " << itemID);
605 }
606}

◆ removeStreamFromKey()

std::string MetaDataSvc::removeStreamFromKey ( std::string & key)

check if the metadata object key contains Stream name (added by SharedWriter in MetaDataSvc) remove stream part from the key (i.e.

modify the parameter) and return it

Definition at line 404 of file MetaDataSvc.cxx.

404 {
405 size_t pos = key.find(m_streamInKeyMark);
406 if( pos==std::string::npos ) return "";
407 size_t epos = key.find(']', pos);
408 size_t spos = pos + m_streamInKeyMark.size();
409 std::string stream = key.substr( spos, epos - spos );
410 //cppcheck-suppress uselessCallsSubstr
411 key = key.substr(0, pos) + key.substr(epos+1);
412 return stream;
413}

◆ retireMetadataSource()

StatusCode MetaDataSvc::retireMetadataSource ( const Incident & inc)
virtual

Allows metadata tools to act before an input file is closed.

Grabs the file GUID then calls the the endInputFile method of all metadata tools in m_metaDataTools providing the GUID as argument.

Parameters
incis a file incident fired before closing an input file
Returns
SUCCESS unless a MetaDataTool fails, then FAILURE

Definition at line 245 of file MetaDataSvc.cxx.

246{
247 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
248 if (fileInc == nullptr) {
249 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
250 return StatusCode::FAILURE;
251 }
252 const std::string guid = fileInc->fileGuid();
253 ATH_MSG_DEBUG("retireMetadataSource: " << fileInc->fileName());
254 for (auto& tool : m_metaDataTools) {
255 ATH_MSG_DEBUG(" calling endInputFile on " << tool->name() << " for GUID \"" << guid << "\"");
256 ATH_CHECK(tool->endInputFile(guid));
257 }
258 m_allowMetaDataStop = true;
259 return StatusCode::SUCCESS;
260}

◆ rootOpenAction()

StatusCode MetaDataSvc::rootOpenAction ( FILEMGR_CALLBACK_ARGS )

Definition at line 398 of file MetaDataSvc.cxx.

398 {
399 return(StatusCode::SUCCESS);
400}

◆ stop()

StatusCode MetaDataSvc::stop ( )
overridevirtual

stop the metadata service

Definition at line 170 of file MetaDataSvc.cxx.

170 {
171 ATH_MSG_DEBUG("MetaDataSvc::stop()");
172 // Fire metaDataStopIncident
173 Incident metaDataStopIncident(name(), "MetaDataStop");
174 m_incSvc->fireIncident(metaDataStopIncident);
175 return(StatusCode::SUCCESS);
176}

◆ transitionMetaDataFile()

StatusCode MetaDataSvc::transitionMetaDataFile ( const std::string & outputConn,
bool disconnect )

Transition output metadata file - fire MeteDataStop incident to transition OutputStream and disconnect now if requested.

Definition at line 360 of file MetaDataSvc.cxx.

361{
362 ATH_MSG_DEBUG("transitionMetaDataFile: " << outputConn );
363
364 // this is normally called through EndInputFile inc, simulate it for EvSvc
365 FileIncident inc("transitionMetaDataFile", "EndInputFile", "dummyMetaInputFileName", "");
367
368 // Reset flag to allow calling prepareOutput again at next transition
369 m_outputPrepared = false;
370
371 Incident metaDataStopIncident(name(), "MetaDataStop");
372 m_incSvc->fireIncident(metaDataStopIncident);
373
374 if( disconnect ) {
375 AthCnvSvc* cnvSvc = dynamic_cast<AthCnvSvc*>(m_addrCrtr.operator->());
376 if (cnvSvc) {
377 if (!cnvSvc->disconnectOutput(outputConn).isSuccess()) {
378 ATH_MSG_WARNING("Cannot get disconnect Output Files");
379 }
380 }
381 }
382
383 return(StatusCode::SUCCESS);
384}
virtual StatusCode disconnectOutput(const std::string &output)
Disconnect output files from the service.

◆ unlockTools()

void MetaDataSvc::unlockTools ( ) const

Definition at line 616 of file MetaDataSvc.cxx.

616 {
617 ATH_MSG_DEBUG("Unlocking metadata tools");
618 for(auto& tool : m_metaDataTools ) {
619 const ILockableTool *lockable = dynamic_cast<const ILockableTool*>( tool.get() );
620 if( lockable ) lockable->unlock_shared();
621 }
622}
virtual void unlock_shared() const =0
Unlock the tool.

◆ updateAddress()

StatusCode MetaDataSvc::updateAddress ( StoreID::type ,
SG::TransientAddress * ,
const EventContext &  )
inlineoverride

always fails

Parameters
storeID[IN] the identity of the store
tad[IN] transient address to be updated
ctx[IN] current event's context information
Returns
FAILURE

Definition at line 208 of file MetaDataSvc.h.

210 {
211 return StatusCode::FAILURE;
212 }

Member Data Documentation

◆ m_addrCrtr

ServiceHandle<IAddressCreator> MetaDataSvc::m_addrCrtr { this, "ConversionService", "AthenaPoolCnvSvc" }
private

Definition at line 300 of file MetaDataSvc.h.

300{ this, "ConversionService", "AthenaPoolCnvSvc" };

◆ m_allowMetaDataStop

bool MetaDataSvc::m_allowMetaDataStop {false}
private

Definition at line 309 of file MetaDataSvc.h.

309{false};

◆ m_beginInputFileSeen

bool MetaDataSvc::m_beginInputFileSeen {false}
private

Definition at line 310 of file MetaDataSvc.h.

310{false};

◆ m_classIDSvc

ServiceHandle<IClassIDSvc> MetaDataSvc::m_classIDSvc {"ClassIDSvc", name()}
private

Definition at line 304 of file MetaDataSvc.h.

304{"ClassIDSvc", name()};

◆ m_clearedInputDataStore

bool MetaDataSvc::m_clearedInputDataStore {true}
private

Definition at line 307 of file MetaDataSvc.h.

307{true};

◆ m_clearedOutputDataStore

bool MetaDataSvc::m_clearedOutputDataStore {false}
private

Definition at line 308 of file MetaDataSvc.h.

308{false};

◆ m_fileMgr

ServiceHandle<IFileMgr> MetaDataSvc::m_fileMgr
private

Definition at line 301 of file MetaDataSvc.h.

◆ m_handledClasses

std::set<CLID> MetaDataSvc::m_handledClasses {}
private

Definition at line 314 of file MetaDataSvc.h.

314{};

◆ m_incSvc

ServiceHandle<IIncidentSvc> MetaDataSvc::m_incSvc
private

Definition at line 302 of file MetaDataSvc.h.

◆ m_inputDataStore

ServiceHandle<StoreGateSvc> MetaDataSvc::m_inputDataStore
private

Definition at line 298 of file MetaDataSvc.h.

◆ m_metaDataCont

Gaudi::Property<std::string> MetaDataSvc::m_metaDataCont {this, "MetaDataContainer", ""}
private

MetaDataContainer, POOL container name for MetaData.

Definition at line 322 of file MetaDataSvc.h.

322{this, "MetaDataContainer", ""};

◆ m_metaDataTools

PublicToolHandleArray<IMetaDataTool> MetaDataSvc::m_metaDataTools {this, "MetaDataTools", {}}
private

MetaDataTools, vector with the MetaData tools.

Definition at line 324 of file MetaDataSvc.h.

324{this, "MetaDataTools", {}};

◆ m_outputDataStore

ServiceHandle<StoreGateSvc> MetaDataSvc::m_outputDataStore
private

Definition at line 299 of file MetaDataSvc.h.

◆ m_outputPrepared

bool MetaDataSvc::m_outputPrepared {false}
private

Definition at line 311 of file MetaDataSvc.h.

311{false};

◆ m_outSeqSvc

ServiceHandle<OutputStreamSequencerSvc> MetaDataSvc::m_outSeqSvc
private

Definition at line 303 of file MetaDataSvc.h.

◆ m_persToClid

std::map<std::string_view, CLID> MetaDataSvc::m_persToClid {}
private

Definition at line 312 of file MetaDataSvc.h.

312{};

◆ m_storageType

long MetaDataSvc::m_storageType {0L}
private

Definition at line 306 of file MetaDataSvc.h.

306{0L};

◆ m_streamInKeyMark

std::string_view MetaDataSvc::m_streamInKeyMark {"__STREAM["}
staticconstexprprivate

marker string for embedding stream name in MetaData object keys for SharedWriter server

Definition at line 316 of file MetaDataSvc.h.

316{"__STREAM["};

◆ m_streamKeys

std::map< std::string, std::set<std::string> > MetaDataSvc::m_streamKeys {}
private

Definition at line 318 of file MetaDataSvc.h.

318{};

The documentation for this class was generated from the following files: