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::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 53 of file MetaDataSvc.cxx.

54 : base_class( name, pSvcLocator )
55 , m_inputDataStore( "StoreGateSvc/InputMetaDataStore", name )
56 , m_outputDataStore( "StoreGateSvc/MetaDataStore", name )
57 , m_fileMgr( "FileMgr", name )
58 , m_incSvc( "IncidentSvc", name )
59 , m_outSeqSvc( "OutputStreamSequencerSvc", name )
60{}
ServiceHandle< OutputStreamSequencerSvc > m_outSeqSvc
ServiceHandle< StoreGateSvc > m_outputDataStore
ServiceHandle< StoreGateSvc > m_inputDataStore
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 388 of file MetaDataSvc.cxx.

388 {
389 std::string fileName = tokenStr.substr(tokenStr.find("[FILE=") + 6);
390 leftString(fileName, ']');
391 std::string className = tokenStr.substr(tokenStr.find("[PNAME=") + 7);
392 leftString(className, ']');
393 std::string contName = tokenStr.substr(tokenStr.find("[CONT=") + 6);
394 leftString(contName,']');
395 std::size_t pos1 = contName.find('(');
396 std::string keyName = contName.substr(pos1 + 1, contName.size() - pos1 - 2);
397 std::size_t pos2 = keyName.find('/');
398 if (pos2 != std::string::npos) keyName = keyName.substr(pos2 + 1);
399 std::string numName = tokenStr.substr(tokenStr.find("[NUM=") + 5);
400 leftString(numName,']');
401 unsigned long num = 0;
402 std::istringstream iss(numName);
403 iss >> num;
404 // className is the persistent class sent by the client ([PNAME=]). xAOD metadata is written by
405 // T_AthenaPoolxAODCnv / T_AthenaPoolAuxContainerCnv, whose persistent class is the transient
406 // class, known to ClassIDSvc by its type-info name. The T/P metadata classes (EventStreamInfo,
407 // IOVMetaDataContainer, ByteStreamMetadataContainer) are named <transient>_p<N>, and ClassIDSvc
408 // knows <transient>; that is a convention, not enforced (PyUtils/MetaReader.py relies on it too).
409 // A metadata class that fits neither fails here.
410 CLID clid = CLID_NULL;
411 if (m_classIDSvc->getIDOfTypeInfoName(className, clid).isFailure()) {
412 const std::size_t ppos = className.rfind("_p");
413 const bool isTP = ppos != std::string::npos && ppos + 2 < className.size()
414 && std::all_of(className.begin() + ppos + 2, className.end(), [](unsigned char c) { return std::isdigit(c); });
415 if (!isTP || m_classIDSvc->getIDOfTypeName(className.substr(0, ppos), clid).isFailure()) {
416 ATH_MSG_ERROR("addProxyToInputMetaDataStore: no CLID for persistent class {} in {}", className, tokenStr);
417 return StatusCode::FAILURE;
418 }
419 }
420
421 // make stream-unique keys for infile metadata objects
422 // AthenaOutputStream will use this to distribute objects to the right stream (and restore the original key)
423 if( clid == 178309087 ) { // FileMetaData
424 std::string newName = std::format("{}{}{}{}", keyName, m_streamInKeyMark, fileName, "]");
425 ATH_MSG_DEBUG("Recording {} as {}", keyName, newName);
426 m_streamKeys[keyName].insert(newName);
427 keyName = std::move(newName);
428 }
429 if( clid == 73252552 ) { // FileMetaDataAuxInfo
430 std::string newName = std::format("{}{}{}]{}",
433 fileName,
435 ATH_MSG_DEBUG("Recording {} as {}", keyName, newName);
436 m_streamKeys[keyName].insert(newName);
437 keyName = std::move(newName);
438 }
439 const std::string par[3] = { "SHM" , keyName , std::move(className) };
440 const unsigned long ipar[2] = { num , 0 };
441 IOpaqueAddress* opqAddr = nullptr;
442 SG::DataProxy* dp = m_inputDataStore->proxy(clid, keyName);
443 if (dp != nullptr) {
444 ATH_MSG_DEBUG("Resetting duplicate proxy for: {}#{} from file: {}",
445 clid, keyName, fileName);
446 dp->reset();
447 }
448 if (!m_addrCrtr->createAddress(m_storageType, clid, par, ipar, opqAddr).isSuccess()) {
449 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot create address for {}", tokenStr);
450 return(StatusCode::FAILURE);
451 }
452 if (m_inputDataStore->recordAddress(keyName, opqAddr).isFailure()) {
453 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot create proxy for {}", tokenStr);
454 return(StatusCode::FAILURE);
455 }
456 if (m_inputDataStore->accessData(clid, keyName) == nullptr) {
457 ATH_MSG_FATAL("addProxyToInputMetaDataStore: Cannot access data for {}", tokenStr);
458 return(StatusCode::FAILURE);
459 }
460 if (keyName.find(RootAuxDynIO::AUX_POSTFIX) != std::string::npos
461 && m_inputDataStore->symLink(clid, keyName, 187169987).isFailure()) {
462 ATH_MSG_WARNING("addProxyToInputMetaDataStore: Cannot symlink to AuxStore for {}", tokenStr);
463 }
464 return(StatusCode::SUCCESS);
465}
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(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
ServiceHandle< IClassIDSvc > m_classIDSvc
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 534 of file MetaDataSvc.cxx.

535{
536 const EventContext& ctx = Gaudi::Hive::currentContext();
537 return m_outSeqSvc.isValid()? m_outSeqSvc->currentRangeID(ctx) : "";
538}

◆ finalize()

StatusCode MetaDataSvc::finalize ( )
overridevirtual

finalize the metadata service at the end of the job

Definition at line 120 of file MetaDataSvc.cxx.

120 {
121 // Release IncidentService
122 if (!m_incSvc.release().isSuccess()) {
123 ATH_MSG_WARNING("Cannot release IncidentService.");
124 }
125 // Release FileMgr
126 if (!m_fileMgr.release().isSuccess()) {
127 ATH_MSG_WARNING("Cannot release FileMgr.");
128 }
129 // Release AddressCreator
130 if (!m_addrCrtr.release().isSuccess()) {
131 ATH_MSG_WARNING("Cannot release AddressCreator.");
132 }
133 // Release OutputMetaDataStore
134 if (!m_outputDataStore.release().isSuccess()) {
135 ATH_MSG_WARNING("Cannot release OutputMetaDataStore.");
136 }
137 // Release InputMetaDataStore
138 if (!m_inputDataStore.release().isSuccess()) {
139 ATH_MSG_WARNING("Cannot release InputMetaDataStore.");
140 }
142 ATH_MSG_WARNING("EndInputFile was not received before finalize");
143 }
144 return(StatusCode::SUCCESS);
145}
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 380 of file MetaDataSvc.cxx.

380 {
381 if (!m_streamKeys.contains(key)) {
382 return {key};
383 }
384 return m_streamKeys.at(key);
385}

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

292 {
293 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
294 if (fileInc == nullptr) {
295 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
296 return;
297 }
298 const std::string fileName = fileInc->fileName();
299 ATH_MSG_DEBUG("handle() {} for {}", inc.type(), fileName);
300
301 if (inc.type() == "FirstInputFile") {
302 // Register open/close callback actions
303 using namespace std::placeholders;
304 Io::bfcn_action_t boa = std::bind(&MetaDataSvc::rootOpenAction, this, _1, _2);
305 if (m_fileMgr->regAction(std::move(boa), Io::OPEN).isFailure()) {
306 ATH_MSG_FATAL("Cannot register ROOT file open action with FileMgr.");
307 }
308 if (!initInputMetaDataStore(fileName).isSuccess()) {
309 ATH_MSG_WARNING("Unable to initialize InputMetaDataStore");
310 }
311 } else if (inc.type() == "BeginInputFile" || inc.type() == "BeginInputMemFile") {
312 if(newMetadataSource(inc).isFailure()) {
313 ATH_MSG_ERROR("Could not process new metadata source {}", fileName);
314 }
315 } else if (inc.type() == "EndInputFile" || inc.type() == "EndInputMemFile") {
316 if(retireMetadataSource(inc).isFailure()) {
317 ATH_MSG_ERROR("Could not retire metadata source {}", fileName);
318 }
319 }
320}
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 66 of file MetaDataSvc.cxx.

66 {
67 ATH_MSG_INFO("Initializing {}", name());
68
69 // Retrieve InputMetaDataStore
70 ATH_CHECK( m_inputDataStore.retrieve() );
71 // Retrieve OutputMetaDataStore
72 ATH_CHECK( m_outputDataStore.retrieve() );
73 // Retrieve AddressCreator
74 ATH_CHECK( m_addrCrtr.retrieve() );
75
76 AthCnvSvc* cnvSvc = dynamic_cast<AthCnvSvc*>(m_addrCrtr.operator->());
77 if (cnvSvc) {
78 m_storageType = cnvSvc->repSvcType();
79 } else {
80 ATH_MSG_WARNING("Cannot get ConversionSvc Interface.");
81 }
82 // Get FileMgr
83 ATH_CHECK( m_fileMgr.retrieve() );
84
85 // Set to be listener for end of event
86 ATH_CHECK( m_incSvc.retrieve() );
87
88 ATH_CHECK( m_metaDataTools.retrieve() );
89 ATH_MSG_INFO("Found " << m_metaDataTools);
90
91 m_incSvc->addListener(this, "FirstInputFile", 80, true);
92 m_incSvc->addListener(this, "BeginInputFile", 80, true);
93 m_incSvc->addListener(this, "EndInputFile", 10, true);
94 m_incSvc->addListener(this, "BeginInputMemFile", 80, true);
95 m_incSvc->addListener(this, "EndInputMemFile", 10, true);
96
97 // Register this service for 'I/O' events
98 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", this->name());
99 ATH_CHECK( iomgr.retrieve() );
100 ATH_CHECK( iomgr->io_register(this) );
101
102 ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc", name());
103 if (!joSvc.retrieve().isSuccess()) {
104 ATH_MSG_WARNING("Cannot get JobOptionsSvc.");
105 } else {
106 if (joSvc->has("EventSelector.InputCollections")) {
107 // Get EventSelector to force in-time initialization and FirstInputFile incident
108 ServiceHandle<IEvtSelector> evtsel("EventSelector", this->name());
109 if (!evtsel.retrieve().isSuccess()) {
110 ATH_MSG_WARNING("Cannot get EventSelector.");
111 }
112 }
113 }
114 // retrieve the output sequences service (EventService) if available
115 m_outSeqSvc.retrieve().ignore();
116
117 return(StatusCode::SUCCESS);
118}
#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 467 of file MetaDataSvc.cxx.

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

351 {
352 ATH_MSG_INFO("I/O reinitialization...");
353 ATH_MSG_DEBUG("Dumping InputMetaDataStore: {}", m_inputDataStore->dump());
354 ATH_MSG_DEBUG("Dumping OutputMetaDataStore: {}", m_outputDataStore->dump());
355 for (const auto& tool : m_metaDataTools) {
356 ATH_MSG_INFO("Attached MetaDataTool: {}", tool->name());
357 }
358 m_outputPrepared = false;
359 return(StatusCode::SUCCESS);
360}
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 157 of file MetaDataSvc.cxx.

157 {
158 if (storeID != StoreID::METADATA_STORE) { // should this (also) run in the INPUT_METADATA_STORE?
159 return(StatusCode::SUCCESS);
160 }
161 if (!m_inputDataStore->contains<DataHeader>( name()) ) {
162 return(StatusCode::SUCCESS);
163 }
164 const DataHeader* dataHeader = nullptr;
165 ATH_CHECK( m_inputDataStore->retrieve( dataHeader, name()) );
166 for (const DataHeaderElement& dhe : *dataHeader) {
167 const CLID clid = dhe.getPrimaryClassID();
168 if (clid != ClassID_traits<DataHeader>::ID()) {
169 tads.push_back(dhe.getAddress(m_storageType, dhe.getKey()));
170 }
171 }
172 return(StatusCode::SUCCESS);
173}

◆ lockTools()

void MetaDataSvc::lockTools ( ) const

Definition at line 585 of file MetaDataSvc.cxx.

585 {
586 ATH_MSG_DEBUG("Locking metadata tools");
587 for(auto& tool : m_metaDataTools ) {
588 const ILockableTool *lockable = dynamic_cast<const ILockableTool*>( tool.get() );
589 if( lockable ) lockable->lock_shared();
590 }
591}
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 175 of file MetaDataSvc.cxx.

176{
177 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
178 if (fileInc == nullptr) {
179 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
180 return StatusCode::FAILURE;
181 }
182 const std::string guid = fileInc->fileGuid();
183 const std::string fileName = fileInc->fileName();
184 m_allowMetaDataStop = false;
186 if (!fileName.starts_with( "BSF:")) {
187 // the input file is _not_ bytestream
189 if (!m_inputDataStore->clearStore().isSuccess()) {
190 ATH_MSG_WARNING("Unable to clear input MetaData Proxies");
191 }
193 }
195 }
196 StatusCode rc{StatusCode::SUCCESS};
197 for (auto& tool : m_metaDataTools) {
198 ATH_MSG_DEBUG(" calling beginInputFile on {} for GUID \"{}\"",
199 tool->name(), guid);
200 if (tool->beginInputFile(guid).isFailure()) {
201 ATH_MSG_ERROR("Unable to call beginInputFile for {}", tool->name());
202 rc = StatusCode::FAILURE;
203 }
204 }
205 return rc;
206}
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 226 of file MetaDataSvc.cxx.

227{
228 if (m_outputPrepared) {
229 return StatusCode::SUCCESS;
230 }
231
232 StatusCode rc{StatusCode::SUCCESS};
233 for (auto& tool : m_metaDataTools) {
234 ATH_MSG_DEBUG(" calling metaDataStop for {}", tool->name());
235 if (tool->metaDataStop().isFailure()) {
236 ATH_MSG_ERROR("Unable to call metaDataStop for {}", tool->name());
237 rc = StatusCode::FAILURE;
238 }
239 }
240 if (!m_metaDataTools.release().isSuccess()) {
241 ATH_MSG_WARNING("Cannot release " << m_metaDataTools);
242 }
243
244 m_outputPrepared = true;
245 return rc;
246}

◆ recordHook()

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

Definition at line 561 of file MetaDataSvc.cxx.

561 {
562 const std::string& typeName = System::typeinfoName(typeInfo);
563 ATH_MSG_VERBOSE("Handling record event of type {}", typeName);
564
565 CLID itemID = 0;
566 if (m_classIDSvc->getIDOfTypeInfoName(typeName, itemID).isSuccess()) {
567 auto result = m_handledClasses.insert(itemID);
568 if (result.second)
569 ATH_MSG_DEBUG("MetaDataSvc will handle {} ClassID: {}", typeName, itemID);
570 }
571}
std::set< CLID > m_handledClasses

◆ remapMetaContCLID()

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

Definition at line 541 of file MetaDataSvc.cxx.

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

◆ removeHook()

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

Definition at line 573 of file MetaDataSvc.cxx.

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

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

368 {
369 size_t pos = key.find(m_streamInKeyMark);
370 if( pos==std::string::npos ) return "";
371 size_t epos = key.find(']', pos);
372 size_t spos = pos + m_streamInKeyMark.size();
373 std::string stream = key.substr( spos, epos - spos );
374 //cppcheck-suppress uselessCallsSubstr
375 key = key.substr(0, pos) + key.substr(epos+1);
376 return stream;
377}

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

209{
210 const FileIncident* fileInc = dynamic_cast<const FileIncident*>(&inc);
211 if (fileInc == nullptr) {
212 ATH_MSG_ERROR("Unable to get FileName from EndInputFile incident");
213 return StatusCode::FAILURE;
214 }
215 const std::string guid = fileInc->fileGuid();
216 ATH_MSG_DEBUG("retireMetadataSource: {}", fileInc->fileName());
217 for (auto& tool : m_metaDataTools) {
218 ATH_MSG_DEBUG(" calling endInputFile on {} for GUID \"{}\"",
219 tool->name(), guid);
220 ATH_CHECK(tool->endInputFile(guid));
221 }
222 m_allowMetaDataStop = true;
223 return StatusCode::SUCCESS;
224}

◆ rootOpenAction()

StatusCode MetaDataSvc::rootOpenAction ( FILEMGR_CALLBACK_ARGS )

Definition at line 362 of file MetaDataSvc.cxx.

362 {
363 return(StatusCode::SUCCESS);
364}

◆ stop()

StatusCode MetaDataSvc::stop ( )
overridevirtual

stop the metadata service

Definition at line 148 of file MetaDataSvc.cxx.

148 {
149 ATH_MSG_DEBUG("MetaDataSvc::stop()");
150 // Fire metaDataStopIncident
151 Incident metaDataStopIncident(name(), "MetaDataStop");
152 m_incSvc->fireIncident(metaDataStopIncident);
153 return(StatusCode::SUCCESS);
154}

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

325{
326 ATH_MSG_DEBUG("transitionMetaDataFile: {}", outputConn );
327
328 // this is normally called through EndInputFile inc, simulate it for EvSvc
329 FileIncident inc("transitionMetaDataFile", "EndInputFile", "dummyMetaInputFileName", "");
331
332 // Reset flag to allow calling prepareOutput again at next transition
333 m_outputPrepared = false;
334
335 Incident metaDataStopIncident(name(), "MetaDataStop");
336 m_incSvc->fireIncident(metaDataStopIncident);
337
338 if( disconnect ) {
339 AthCnvSvc* cnvSvc = dynamic_cast<AthCnvSvc*>(m_addrCrtr.operator->());
340 if (cnvSvc) {
341 if (!cnvSvc->disconnectOutput(outputConn).isSuccess()) {
342 ATH_MSG_WARNING("Cannot get disconnect Output Files");
343 }
344 }
345 }
346
347 return(StatusCode::SUCCESS);
348}
virtual StatusCode disconnectOutput(const std::string &output)
Disconnect output files from the service.

◆ unlockTools()

void MetaDataSvc::unlockTools ( ) const

Definition at line 593 of file MetaDataSvc.cxx.

593 {
594 ATH_MSG_DEBUG("Unlocking metadata tools");
595 for(auto& tool : m_metaDataTools ) {
596 const ILockableTool *lockable = dynamic_cast<const ILockableTool*>( tool.get() );
597 if( lockable ) lockable->unlock_shared();
598 }
599}
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 311 of file MetaDataSvc.h.

311{};

◆ 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 319 of file MetaDataSvc.h.

319{this, "MetaDataContainer", ""};

◆ m_metaDataTools

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

MetaDataTools, vector with the MetaData tools.

Definition at line 321 of file MetaDataSvc.h.

321{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_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 313 of file MetaDataSvc.h.

313{"__STREAM["};

◆ m_streamKeys

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

Definition at line 315 of file MetaDataSvc.h.

315{};

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