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 StoreGateSvc * outputDataStore () 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 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< StoreGateSvc > m_inputDataStore
ServiceHandle< StoreGateSvc > m_outputDataStore
ServiceHandle< IAddressCreator > m_addrCrtr { this, "ConversionService", "AthenaPoolCnvSvc" }
ServiceHandle< IFileMgr > m_fileMgr
ServiceHandle< IIncidentSvc > m_incSvc
ServiceHandle< OutputStreamSequencerSvc > m_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, CLID > m_persToClid {}
std::set< CLID > m_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< IMetaDataTool > m_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 51 of file MetaDataSvc.cxx.

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

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

541{
542 const EventContext& ctx = Gaudi::Hive::currentContext();
543 return m_outSeqSvc.isValid()? m_outSeqSvc->currentRangeID(ctx) : "";
544}

◆ finalize()

StatusCode MetaDataSvc::finalize ( )
overridevirtual

finalize the metadata service at the end of the job

Definition at line 141 of file MetaDataSvc.cxx.

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

401 {
402 if (!m_streamKeys.contains(key)) {
403 return {key};
404 }
405 return m_streamKeys.at(key);
406}

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

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

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

473 {
474 ATH_MSG_DEBUG("initInputMetaDataStore: file name {}", fileName);
476 // Load proxies for InputMetaDataStore
477 if (m_metaDataCont.value().empty()) {
478 ATH_MSG_DEBUG("MetaDataSvc called without MetaDataContainer set.");
479 return(StatusCode::SUCCESS);
480 }
481 if (fileName.starts_with( "BSF:")) {
482 ATH_MSG_DEBUG("MetaDataSvc called for non ROOT file.");
483 } else if (fileName.compare(0, 3, "SHM")==0) {
484 ATH_MSG_DEBUG("MetaDataSvc called for shared memory.");
485 } else {
486 const std::string par[2] = {
487 fileName,
488 std::format("{}(DataHeader)", m_metaDataCont.value())
489 };
490 const std::string parOld[2] = {
491 fileName,
492 std::format("{}{}", m_metaDataCont.value(), "DataHeader")
493 };
494 if (m_inputDataStore->contains<DataHeader>(name())) {
495 ATH_MSG_DEBUG("initInputMetaDataStore: MetaData Store already contains DataHeader, key = {}", name());
496 } else {
497 const unsigned long ipar[2] = { 0 , 0 };
498 IOpaqueAddress* opqAddr = nullptr;
499 if (m_addrCrtr->createAddress(m_storageType, ClassID_traits<DataHeader>::ID(), par, ipar, opqAddr).isSuccess()
500 || m_addrCrtr->createAddress(m_storageType, ClassID_traits<DataHeader>::ID(), parOld, ipar, opqAddr).isSuccess()) {
501 if (m_inputDataStore->recordAddress(name(), opqAddr).isFailure()) {
502 ATH_MSG_WARNING("initInputMetaDataStore: Cannot create proxy for DataHeader, key = {}", name());
503 }
504 }
505 }
506 std::list<SG::TransientAddress*> tList;
508 for (SG::TransientAddress* tad : tList) {
509 CLID clid = tad->clID();
510 ATH_MSG_VERBOSE("initInputMetaDataStore: add proxy for clid = {}, key = {}",
511 clid, tad->name());
512 if (m_inputDataStore->contains(tad->clID(), tad->name())) {
513 ATH_MSG_DEBUG("initInputMetaDataStore: MetaData Store already contains clid = {}, key = {}",
514 clid, tad->name());
515 } else {
516 if (!m_inputDataStore->recordAddress(tad->name(), tad->address())) {
517 ATH_MSG_ERROR("initInputMetaDataStore: Cannot create proxy for clid = {}, key = {}",
518 clid, tad->name());
519 return StatusCode::FAILURE;
520 }
521 }
522
523 for (CLID tclid : tad->transientID()) {
524 if (tclid != clid) {
525 if (m_inputDataStore->symLink (clid, tad->name(), tclid).isFailure()) {
526 ATH_MSG_WARNING("Cannot make autosymlink from {}/{} to {}",
527 clid, tad->name(), tclid);
528 }
529 }
530 }
531 delete tad;
532 }
533 tList.clear();
534 }
535 ATH_MSG_DEBUG("Loaded input meta data store proxies");
536 return(StatusCode::SUCCESS);
537}
#define ATH_MSG_VERBOSE(x,...)
StatusCode loadAddresses(StoreID::type storeID, IAddressProvider::tadList &tads) override
loads addresses of 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 372 of file MetaDataSvc.cxx.

372 {
373 ATH_MSG_INFO("I/O reinitialization...");
374 ATH_MSG_DEBUG("Dumping InputMetaDataStore: {}", m_inputDataStore->dump());
375 ATH_MSG_DEBUG("Dumping OutputMetaDataStore: {}", m_outputDataStore->dump());
376 for (const auto& tool : m_metaDataTools) {
377 ATH_MSG_INFO("Attached MetaDataTool: {}", tool->name());
378 }
379 m_outputPrepared = false;
380 return(StatusCode::SUCCESS);
381}
bool m_outputPrepared

◆ loadAddresses()

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

loads addresses of metadata object.

loads the DataHeader and adds addresses of objects from DataHeaderElements to the tads

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

Definition at line 178 of file MetaDataSvc.cxx.

178 {
179 if (storeID != StoreID::METADATA_STORE) { // should this (also) run in the INPUT_METADATA_STORE?
180 return(StatusCode::SUCCESS);
181 }
182 if (!m_inputDataStore->contains<DataHeader>( name()) ) {
183 return(StatusCode::SUCCESS);
184 }
185 const DataHeader* dataHeader = nullptr;
186 ATH_CHECK( m_inputDataStore->retrieve( dataHeader, name()) );
187 for (const DataHeaderElement& dhe : *dataHeader) {
188 const CLID clid = dhe.getPrimaryClassID();
189 if (clid != ClassID_traits<DataHeader>::ID()) {
190 tads.push_back(dhe.getAddress(m_storageType, dhe.getKey()));
191 }
192 }
193 return(StatusCode::SUCCESS);
194}

◆ lockTools()

void MetaDataSvc::lockTools ( ) const

Definition at line 591 of file MetaDataSvc.cxx.

591 {
592 ATH_MSG_DEBUG("Locking metadata tools");
593 for(auto& tool : m_metaDataTools ) {
594 const ILockableTool *lockable = dynamic_cast<const ILockableTool*>( tool.get() );
595 if( lockable ) lockable->lock_shared();
596 }
597}
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 196 of file MetaDataSvc.cxx.

197{
198 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
199 if (fileInc == nullptr) {
200 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
201 return StatusCode::FAILURE;
202 }
203 const std::string guid = fileInc->fileGuid();
204 const std::string fileName = fileInc->fileName();
205 m_allowMetaDataStop = false;
207 if (!fileName.starts_with( "BSF:")) {
208 // the input file is _not_ bytestream
210 if (!m_inputDataStore->clearStore().isSuccess()) {
211 ATH_MSG_WARNING("Unable to clear input MetaData Proxies");
212 }
214 }
216 }
217 StatusCode rc{StatusCode::SUCCESS};
218 for (auto& tool : m_metaDataTools) {
219 ATH_MSG_DEBUG(" calling beginInputFile on {} for GUID \"{}\"",
220 tool->name(), guid);
221 if (tool->beginInputFile(guid).isFailure()) {
222 ATH_MSG_ERROR("Unable to call beginInputFile for {}", tool->name());
223 rc = StatusCode::FAILURE;
224 }
225 }
226 return rc;
227}
static Double_t rc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ outputDataStore()

virtual StoreGateSvc * MetaDataSvc::outputDataStore ( ) const
inlinefinaloverridevirtual

Definition at line 233 of file MetaDataSvc.h.

233 {
234 return &*m_outputDataStore;
235 }

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

248{
249 if (m_outputPrepared) {
250 return StatusCode::SUCCESS;
251 }
252
253 StatusCode rc{StatusCode::SUCCESS};
254 for (auto& tool : m_metaDataTools) {
255 ATH_MSG_DEBUG(" calling metaDataStop for {}", tool->name());
256 if (tool->metaDataStop().isFailure()) {
257 ATH_MSG_ERROR("Unable to call metaDataStop for {}", tool->name());
258 rc = StatusCode::FAILURE;
259 }
260 }
261 if (!m_metaDataTools.release().isSuccess()) {
262 ATH_MSG_WARNING("Cannot release " << m_metaDataTools);
263 }
264
265 m_outputPrepared = true;
266 return rc;
267}

◆ recordHook()

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

Definition at line 567 of file MetaDataSvc.cxx.

567 {
568 const std::string& typeName = System::typeinfoName(typeInfo);
569 ATH_MSG_VERBOSE("Handling record event of type {}", typeName);
570
571 CLID itemID = 0;
572 if (m_classIDSvc->getIDOfTypeInfoName(typeName, itemID).isSuccess()) {
573 auto result = m_handledClasses.insert(itemID);
574 if (result.second)
575 ATH_MSG_DEBUG("MetaDataSvc will handle {} ClassID: {}", typeName, itemID);
576 }
577}
std::set< CLID > m_handledClasses
ServiceHandle< IClassIDSvc > m_classIDSvc

◆ remapMetaContCLID()

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

Definition at line 547 of file MetaDataSvc.cxx.

548{
549 if (!m_handledClasses.contains(itemID)) {
550 ATH_MSG_DEBUG("Not translating metadata item ID #{}", itemID);
551 return itemID;
552 }
553
554 std::string itemName;
555 CLID contID = 0;
556 if (m_classIDSvc->getTypeNameOfID(itemID, itemName).isSuccess()) {
557 const std::string contName = std::format("MetaCont<{}>", itemName);
558 ATH_MSG_DEBUG("Transforming {} to {} for output",
559 contName, itemName);
560 if (m_classIDSvc->getIDOfTypeName(contName, contID).isSuccess())
561 return contID;
562 }
563
564 return itemID;
565}

◆ removeHook()

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

Definition at line 579 of file MetaDataSvc.cxx.

579 {
580 const std::string& typeName = System::typeinfoName(typeInfo);
581 ATH_MSG_VERBOSE("Handling removal event of type {}", typeName);
582
583 CLID itemID = 0;
584 if (m_classIDSvc->getIDOfTypeInfoName(typeName, itemID).isSuccess()) {
585 if (0 < m_handledClasses.erase(itemID))
586 ATH_MSG_DEBUG("MetaDataSvc will no longer handle {} ClassID: {}",
587 typeName, itemID);
588 }
589}

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

389 {
390 size_t pos = key.find(m_streamInKeyMark);
391 if( pos==std::string::npos ) return "";
392 size_t epos = key.find(']', pos);
393 size_t spos = pos + m_streamInKeyMark.size();
394 std::string stream = key.substr( spos, epos - spos );
395 //cppcheck-suppress uselessCallsSubstr
396 key = key.substr(0, pos) + key.substr(epos+1);
397 return stream;
398}

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

230{
231 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
232 if (fileInc == nullptr) {
233 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
234 return StatusCode::FAILURE;
235 }
236 const std::string guid = fileInc->fileGuid();
237 ATH_MSG_DEBUG("retireMetadataSource: {}", fileInc->fileName());
238 for (auto& tool : m_metaDataTools) {
239 ATH_MSG_DEBUG(" calling endInputFile on {} for GUID \"{}\"",
240 tool->name(), guid);
241 ATH_CHECK(tool->endInputFile(guid));
242 }
243 m_allowMetaDataStop = true;
244 return StatusCode::SUCCESS;
245}

◆ rootOpenAction()

StatusCode MetaDataSvc::rootOpenAction ( FILEMGR_CALLBACK_ARGS )

Definition at line 383 of file MetaDataSvc.cxx.

383 {
384 return(StatusCode::SUCCESS);
385}

◆ stop()

StatusCode MetaDataSvc::stop ( )
overridevirtual

stop the metadata service

Definition at line 169 of file MetaDataSvc.cxx.

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

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

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

◆ unlockTools()

void MetaDataSvc::unlockTools ( ) const

Definition at line 599 of file MetaDataSvc.cxx.

599 {
600 ATH_MSG_DEBUG("Unlocking metadata tools");
601 for(auto& tool : m_metaDataTools ) {
602 const ILockableTool *lockable = dynamic_cast<const ILockableTool*>( tool.get() );
603 if( lockable ) lockable->unlock_shared();
604 }
605}
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 206 of file MetaDataSvc.h.

208 {
209 return StatusCode::FAILURE;
210 }

Member Data Documentation

◆ m_addrCrtr

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

Definition at line 298 of file MetaDataSvc.h.

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

◆ m_allowMetaDataStop

bool MetaDataSvc::m_allowMetaDataStop {false}
private

Definition at line 307 of file MetaDataSvc.h.

307{false};

◆ m_beginInputFileSeen

bool MetaDataSvc::m_beginInputFileSeen {false}
private

Definition at line 308 of file MetaDataSvc.h.

308{false};

◆ m_classIDSvc

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

Definition at line 302 of file MetaDataSvc.h.

302{"ClassIDSvc", name()};

◆ m_clearedInputDataStore

bool MetaDataSvc::m_clearedInputDataStore {true}
private

Definition at line 305 of file MetaDataSvc.h.

305{true};

◆ m_clearedOutputDataStore

bool MetaDataSvc::m_clearedOutputDataStore {false}
private

Definition at line 306 of file MetaDataSvc.h.

306{false};

◆ m_fileMgr

ServiceHandle<IFileMgr> MetaDataSvc::m_fileMgr
private

Definition at line 299 of file MetaDataSvc.h.

◆ m_handledClasses

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

Definition at line 312 of file MetaDataSvc.h.

312{};

◆ m_incSvc

ServiceHandle<IIncidentSvc> MetaDataSvc::m_incSvc
private

Definition at line 300 of file MetaDataSvc.h.

◆ m_inputDataStore

ServiceHandle<StoreGateSvc> MetaDataSvc::m_inputDataStore
private

Definition at line 296 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 320 of file MetaDataSvc.h.

320{this, "MetaDataContainer", ""};

◆ m_metaDataTools

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

MetaDataTools, vector with the MetaData tools.

Definition at line 322 of file MetaDataSvc.h.

322{this, "MetaDataTools", {}};

◆ m_outputDataStore

ServiceHandle<StoreGateSvc> MetaDataSvc::m_outputDataStore
private

Definition at line 297 of file MetaDataSvc.h.

◆ m_outputPrepared

bool MetaDataSvc::m_outputPrepared {false}
private

Definition at line 309 of file MetaDataSvc.h.

309{false};

◆ m_outSeqSvc

ServiceHandle<OutputStreamSequencerSvc> MetaDataSvc::m_outSeqSvc
private

Definition at line 301 of file MetaDataSvc.h.

◆ m_persToClid

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

Definition at line 310 of file MetaDataSvc.h.

310{};

◆ m_storageType

long MetaDataSvc::m_storageType {0L}
private

Definition at line 304 of file MetaDataSvc.h.

304{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 314 of file MetaDataSvc.h.

314{"__STREAM["};

◆ m_streamKeys

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

Definition at line 316 of file MetaDataSvc.h.

316{};

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