Belle II Software  release-08-01-10
NullMetadataProvider Class Referenceabstract

Fallback provider if no providers are given: Will raise an error if used but allows processing if no payloads are requested or all are taken locally from testing payload storage. More...

#include <MetadataProvider.h>

Inheritance diagram for NullMetadataProvider:
Collaboration diagram for NullMetadataProvider:

Public Types

using PayloadMap = std::unordered_map< std::string, PayloadMetadata >
 Type for the internal list of payloads.
 

Public Member Functions

bool setTags (const std::vector< std::string > &tags)
 Set the list of globaltag names to be considered for payloads. More...
 
bool getPayloads (int exp, int run, std::vector< PayloadMetadata > &info)
 Update the information in the vector of metadata instances with the actual values. More...
 
std::set< std::string > getUsableTagStates ()
 Get the valid tag states when checking globaltag status.
 
void setUsableTagStates (const std::set< std::string > &states)
 Set the valid tag states for this provider when checking globaltag status. More...
 

Protected Member Functions

virtual bool updatePayloads (const std::string &globaltag, int exp, int run)=0
 Update the list of existing payloads from a given globaltag, exp and run combination. More...
 
void addPayload (PayloadMetadata &&payload, const std::string &messagePrefix="")
 Add a payload information to the internal list. More...
 
void printInfoMessage (const std::string &provider)
 Print an INFO message about the used metadata provider. More...
 

Protected Attributes

std::vector< std::string > m_tags
 List of globaltags to consider.
 
std::unordered_map< std::string, PayloadMetadataCachem_cache
 Map of globaltag->known metadata.
 
PayloadMapm_payloads {nullptr}
 Map of known payloads for current conditions.
 
std::set< std::string > m_usableTagStates {"TESTING", "VALIDATED", "RUNNING", "PUBLISHED"}
 Set of global tag states to consider valid (except for 'INVALID' which is always considered invalid)
 

Private Member Functions

bool updatePayloads ([[maybe_unused]] const std::string &globaltag, [[maybe_unused]] int exp, [[maybe_unused]] int run) override
 Nope, no update.
 
std::string getGlobaltagStatus (const std::string &name) override
 When we get asked to check a global tag we raise an error ... More...
 

Private Attributes

bool m_errorShown {false}
 Have we already shown the error?
 

Detailed Description

Fallback provider if no providers are given: Will raise an error if used but allows processing if no payloads are requested or all are taken locally from testing payload storage.

Definition at line 182 of file MetadataProvider.h.

Member Function Documentation

◆ addPayload()

void addPayload ( PayloadMetadata &&  payload,
const std::string &  messagePrefix = "" 
)
protectedinherited

Add a payload information to the internal list.

This should be called by implementations during updatePayloads() for each payload found.

Parameters
payloadpayload information filled from the globaltag
messagePrefixa message prefix to be shown for possible log messages to indicate the correct metadata provider

Definition at line 91 of file MetadataProvider.cc.

◆ getGlobaltagStatus()

std::string getGlobaltagStatus ( const std::string &  name)
overrideprivatevirtual

When we get asked to check a global tag we raise an error ...

but only once

Implements MetadataProvider.

Definition at line 120 of file MetadataProvider.cc.

◆ getPayloads()

bool getPayloads ( int  exp,
int  run,
std::vector< PayloadMetadata > &  info 
)
inherited

Update the information in the vector of metadata instances with the actual values.

The input is a list of metadata instances and the metadata provider will try to modify them in place and add all the missing information it can find.

  • It will try to find iov, revision, checksum, url for each entry which doesn't have a valid revision number (revision=0)
  • It will ignore any entries with a valid revision number (revision>0)
  • any payload which cannot be found in any globaltag will raise an error as long as required=true
  • the modified list can still contain payloads without a valid revision some payloads could not be found.

This function will call updatePayloads() if necessary to update the list of known payloads for a given run but it will try to cache these results so incrementally asking for new payloads as they get requested is perfectly fine.

updatePayloads() will only called for globaltags if we still need to find payload information. If all payloads are found no further queries will be made so adding additional globaltags that are not used at the end is not expensive.

Parameters
expthe experiment number
runthe run number
[in,out]infoa list of metadata instances which we try to find the missing metadata for.
Returns
true if all required payloads could be found, false if at least one payload which still didn't have a valid revision number and is required could not be found.

Definition at line 36 of file MetadataProvider.cc.

◆ printInfoMessage()

void printInfoMessage ( const std::string &  provider = "")
protectedinherited

Print an INFO message about the used metadata provider.

Parameters
providerthe actual metadata provider used for the job

Definition at line 114 of file MetadataProvider.cc.

◆ setTags()

bool setTags ( const std::vector< std::string > &  tags)
inherited

Set the list of globaltag names to be considered for payloads.

This should be called before requesting any payloads but after calling setValidTagStates().

Returns
true if all globaltags can be found and are in a valid state

Definition at line 15 of file MetadataProvider.cc.

◆ setUsableTagStates()

void setUsableTagStates ( const std::set< std::string > &  states)
inlineinherited

Set the valid tag states for this provider when checking globaltag status.

Should be called before setTags() if necessary.

Warning
The state "INVALID" will never be accepted and removed from the given set if present

Definition at line 128 of file MetadataProvider.h.

◆ updatePayloads()

virtual bool updatePayloads ( const std::string &  globaltag,
int  exp,
int  run 
)
protectedpure virtualinherited

Update the list of existing payloads from a given globaltag, exp and run combination.

This function has to be implemented by specializations. It will be called whenever we need to know the list of payloads available for a given globaltag, exp, run combination. The base class will make sure to call this class only if necessary, so hopefully only once per combination but could be more often if processing jumps between runs.

The implementation should then obtain all metadata valid for this globaltag, exp, run combination and call addPayload() once for each payload to add it to the internal cache.

Returns
true on success, false on failure (e.g. network or file problems)

Implemented in LocalMetadataProvider, and CentralMetadataProvider.


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