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 &filename) 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 54 of file MetaDataSvc.cxx.

55 : base_class( name, pSvcLocator )
56 , m_inputDataStore( "StoreGateSvc/InputMetaDataStore", name )
57 , m_outputDataStore( "StoreGateSvc/MetaDataStore", name )
58 , m_fileMgr( "FileMgr", name )
59 , m_incSvc( "IncidentSvc", name )
60 , m_outSeqSvc( "OutputStreamSequencerSvc", name )
61 , m_persToClid{ { "DataHeader_p5", 222376821 },
62 { "EventStreamInfo_p3", 167728019 },
63 { "ByteStreamMetadataContainer_p1", 1076128893 },
64 { "IOVMetaDataContainer_p1", 1316383046 },
65 { "xAOD::EventFormat_v1", 243004407 },
66 { "xAOD::CutBookkeeperContainer_v1", 1234982351 },
67 { "xAOD::CutBookkeeperAuxContainer_v1", 1147935274 },
68 { "xAOD::TriggerMenuContainer_v1", 1107011239 },
69 { "DataVector<xAOD::TriggerMenu_v1>", 1107011239 },
70 { "xAOD::TriggerMenuAuxContainer_v1", 1212409402 },
71 { "xAOD::TriggerMenuJsonContainer_v1", 1221262614 },
72 { "DataVector<xAOD::TriggerMenuJson_v1>", 1221262614 },
73 { "xAOD::TriggerMenuJsonAuxContainer_v1", 373045213 },
74 { "xAOD::LumiBlockRangeContainer_v1", 1115934851 },
75 { "DataVector<xAOD::LumiBlockRange_v1>", 1115934851 },
76 { "xAOD::LumiBlockRangeAuxContainer_v1", 1251061086 },
77 { "xAOD::FileMetaData_v1", 178309087 },
78 { "xAOD::FileMetaDataAuxInfo_v1", 73252552 },
79 { "xAOD::RingSetConfContainer_v1", 1157997427 },
80 { "DataVector<xAOD::RingSetConf_v1>", 1157997427 },
81 { "xAOD::RingSetConfAuxContainer_v1", 1307745126 },
82 { "xAOD::TruthMetaDataContainer_v1", 1188015687 },
83 { "DataVector<xAOD::TruthMetaData_v1>", 1188015687 },
84 { "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 420 of file MetaDataSvc.cxx.

420 {
421 std::string fileName = tokenStr.substr(tokenStr.find("[FILE=") + 6);
422 leftString(fileName, ']');
423 std::string className = tokenStr.substr(tokenStr.find("[PNAME=") + 7);
424 leftString(className, ']');
425 std::string contName = tokenStr.substr(tokenStr.find("[CONT=") + 6);
426 leftString(contName,']');
427 std::size_t pos1 = contName.find('(');
428 std::string keyName = contName.substr(pos1 + 1, contName.size() - pos1 - 2);
429 std::size_t pos2 = keyName.find('/');
430 if (pos2 != std::string::npos) keyName = keyName.substr(pos2 + 1);
431 std::string numName = tokenStr.substr(tokenStr.find("[NUM=") + 5);
432 leftString(numName,']');
433 unsigned long num = 0;
434 std::istringstream iss(numName);
435 iss >> num;
436 CLID clid = m_persToClid[className];
437
438 // make stream-unique keys for infile metadata objects
439 // AthenaOutputStream will use this to distribute objects to the right stream (and restore the original key)
440 if( clid == 178309087 ) { // FileMetaData
441 std::string newName = std::format("{}{}{}{}", keyName, m_streamInKeyMark, fileName, "]");
442 ATH_MSG_DEBUG("Recording " << keyName << " as " << newName);
443 m_streamKeys[keyName].insert(newName);
444 keyName = std::move(newName);
445 }
446 if( clid == 73252552 ) { // FileMetaDataAuxInfo
447 std::string newName = std::format("{}{}{}]{}",
450 fileName,
452 ATH_MSG_DEBUG("Recording " << keyName << " as " << newName);
453 m_streamKeys[keyName].insert(newName);
454 keyName = std::move(newName);
455 }
456 const std::string par[3] = { "SHM" , keyName , std::move(className) };
457 const unsigned long ipar[2] = { num , 0 };
458 IOpaqueAddress* opqAddr = nullptr;
459 SG::DataProxy* dp = m_inputDataStore->proxy(clid, keyName);
460 if (dp != nullptr) {
461 ATH_MSG_DEBUG("Resetting duplicate proxy for: " << clid << "#" << keyName << " from file: " << fileName);
462 dp->reset();
463 }
464 if (!m_addrCrtr->createAddress(m_storageType, clid, par, ipar, opqAddr).isSuccess()) {
465 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot create address for " << tokenStr);
466 return(StatusCode::FAILURE);
467 }
468 if (m_inputDataStore->recordAddress(keyName, opqAddr).isFailure()) {
469 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot create proxy for " << tokenStr);
470 return(StatusCode::FAILURE);
471 }
472 if (m_inputDataStore->accessData(clid, keyName) == nullptr) {
473 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot access data for " << tokenStr);
474 return(StatusCode::FAILURE);
475 }
476 if (keyName.find(RootAuxDynIO::AUX_POSTFIX) != std::string::npos
477 && m_inputDataStore->symLink(clid, keyName, 187169987).isFailure()) {
478 ATH_MSG_WARNING("addProxyToInputMetaDataStore: Cannot symlink to AuxStore for " << tokenStr);
479 }
480 return(StatusCode::SUCCESS);
481}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(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 552 of file MetaDataSvc.cxx.

553{
554 return m_outSeqSvc.isValid()? m_outSeqSvc->currentRangeID() : "";
555}

◆ finalize()

StatusCode MetaDataSvc::finalize ( )
overridevirtual

finalize the metadata service at the end of the job

Definition at line 144 of file MetaDataSvc.cxx.

144 {
145 // Release IncidentService
146 if (!m_incSvc.release().isSuccess()) {
147 ATH_MSG_WARNING("Cannot release IncidentService.");
148 }
149 // Release FileMgr
150 if (!m_fileMgr.release().isSuccess()) {
151 ATH_MSG_WARNING("Cannot release FileMgr.");
152 }
153 // Release AddressCreator
154 if (!m_addrCrtr.release().isSuccess()) {
155 ATH_MSG_WARNING("Cannot release AddressCreator.");
156 }
157 // Release OutputMetaDataStore
158 if (!m_outputDataStore.release().isSuccess()) {
159 ATH_MSG_WARNING("Cannot release OutputMetaDataStore.");
160 }
161 // Release InputMetaDataStore
162 if (!m_inputDataStore.release().isSuccess()) {
163 ATH_MSG_WARNING("Cannot release InputMetaDataStore.");
164 }
166 ATH_MSG_WARNING("EndInputFile was not received before finalize");
167 }
168 return(StatusCode::SUCCESS);
169}
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 412 of file MetaDataSvc.cxx.

412 {
413 if (!m_streamKeys.contains(key)) {
414 return {key};
415 }
416 return m_streamKeys.at(key);
417}

◆ 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 324 of file MetaDataSvc.cxx.

324 {
325 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
326 if (fileInc == nullptr) {
327 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
328 return;
329 }
330 const std::string fileName = fileInc->fileName();
331 ATH_MSG_DEBUG("handle() " << inc.type() << " for " << fileName);
332
333 if (inc.type() == "FirstInputFile") {
334 // Register open/close callback actions
335 using namespace boost::placeholders;
336 Io::bfcn_action_t boa = boost::bind(&MetaDataSvc::rootOpenAction, this, _1,_2);
337 if (m_fileMgr->regAction(std::move(boa), Io::OPEN).isFailure()) {
338 ATH_MSG_FATAL("Cannot register ROOT file open action with FileMgr.");
339 }
340 if (!initInputMetaDataStore(fileName).isSuccess()) {
341 ATH_MSG_WARNING("Unable to initialize InputMetaDataStore");
342 }
343 } else if (inc.type() == "BeginInputFile" || inc.type() == "BeginInputMemFile") {
344 if(newMetadataSource(inc).isFailure()) {
345 ATH_MSG_ERROR("Could not process new metadata source " << fileName);
346 }
347 } else if (inc.type() == "EndInputFile" || inc.type() == "EndInputMemFile") {
348 if(retireMetadataSource(inc).isFailure()) {
349 ATH_MSG_ERROR("Could not retire metadata source " << fileName);
350 }
351 }
352}
#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 90 of file MetaDataSvc.cxx.

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

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

383 {
384 ATH_MSG_INFO("I/O reinitialization...");
385 ATH_MSG_DEBUG("Dumping InputMetaDataStore: " << m_inputDataStore->dump());
386 ATH_MSG_DEBUG("Dumping OutputMetaDataStore: " << m_outputDataStore->dump());
387 for (const auto& tool : m_metaDataTools) {
388 ATH_MSG_INFO("Attached MetaDataTool: " << tool->name());
389 }
390 m_outputPrepared = false;
391 return(StatusCode::SUCCESS);
392}
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 181 of file MetaDataSvc.cxx.

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

◆ lockTools()

void MetaDataSvc::lockTools ( ) const

Definition at line 603 of file MetaDataSvc.cxx.

603 {
604 ATH_MSG_DEBUG("Locking metadata tools");
605 for(auto& tool : m_metaDataTools ) {
606 const ILockableTool *lockable = dynamic_cast<const ILockableTool*>( tool.get() );
607 if( lockable ) lockable->lock_shared();
608 }
609}
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 215 of file MetaDataSvc.cxx.

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

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

◆ recordHook()

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

Definition at line 578 of file MetaDataSvc.cxx.

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

◆ remapMetaContCLID()

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

Definition at line 558 of file MetaDataSvc.cxx.

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

◆ removeHook()

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

Definition at line 591 of file MetaDataSvc.cxx.

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

◆ 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 400 of file MetaDataSvc.cxx.

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

◆ 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 247 of file MetaDataSvc.cxx.

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

◆ rootOpenAction()

StatusCode MetaDataSvc::rootOpenAction ( FILEMGR_CALLBACK_ARGS )

Definition at line 394 of file MetaDataSvc.cxx.

394 {
395 return(StatusCode::SUCCESS);
396}

◆ stop()

StatusCode MetaDataSvc::stop ( )
overridevirtual

stop the metadata service

Definition at line 172 of file MetaDataSvc.cxx.

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

◆ 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 356 of file MetaDataSvc.cxx.

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

◆ unlockTools()

void MetaDataSvc::unlockTools ( ) const

Definition at line 611 of file MetaDataSvc.cxx.

611 {
612 ATH_MSG_DEBUG("Unlocking metadata tools");
613 for(auto& tool : m_metaDataTools ) {
614 const ILockableTool *lockable = dynamic_cast<const ILockableTool*>( tool.get() );
615 if( lockable ) lockable->unlock_shared();
616 }
617}
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: