![]() |
Belle II Software development
|
Base class for a payload metadata provider. More...
#include <MetadataProvider.h>
Classes | |
class | PayloadMetadataCache |
Simple caching structure to keep the payload information for this and the last exp/run. More... | |
Public Types | |
using | PayloadMap = std::unordered_map< std::string, PayloadMetadata > |
Type for the internal list of payloads. | |
Public Member Functions | |
MetadataProvider ()=default | |
Default constructible. | |
MetadataProvider (const std::set< std::string > &usableTagStates) | |
Construct with a known set of usable global tag states. | |
virtual | ~MetadataProvider ()=default |
Default destructible. | |
bool | setTags (const std::vector< std::string > &tags) |
Set the list of globaltag names to be considered for payloads. | |
bool | getPayloads (int exp, int run, std::vector< PayloadMetadata > &info) |
Update the information in the vector of metadata instances with the actual values. | |
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. | |
Protected Member Functions | |
virtual std::string | getGlobaltagStatus (const std::string &name)=0 |
Check the status of a global tag with the given name. | |
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. | |
void | addPayload (PayloadMetadata &&payload, const std::string &messagePrefix="") |
Add a payload information to the internal list. | |
void | printInfoMessage (const std::string &provider) |
Print an INFO message about the used metadata provider. | |
Protected Attributes | |
std::vector< std::string > | m_tags |
List of globaltags to consider. | |
std::unordered_map< std::string, PayloadMetadataCache > | m_cache |
Map of globaltag->known metadata. | |
PayloadMap * | m_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) | |
Base class for a payload metadata provider.
This class is supposed to know what payloads exist and if asked will update a given list of PayloadMetadata instances with the actual values valid for the given exp/run.
It will keep an internal cache of all valid payload metadata so that requesting new metadata should be as cheap as possible.
Definition at line 27 of file MetadataProvider.h.
using PayloadMap = std::unordered_map<std::string, PayloadMetadata> |
Type for the internal list of payloads.
Definition at line 30 of file MetadataProvider.h.
|
inlineexplicit |
Construct with a known set of usable global tag states.
Definition at line 77 of file MetadataProvider.h.
|
protected |
Add a payload information to the internal list.
This should be called by implementations during updatePayloads() for each payload found.
payload | payload information filled from the globaltag |
messagePrefix | a message prefix to be shown for possible log messages to indicate the correct metadata provider |
Definition at line 91 of file MetadataProvider.cc.
|
protectedpure virtual |
Check the status of a global tag with the given name.
Returns "" if the tag doesn't exist or any other error occured
Implemented in LocalMetadataProvider, CentralMetadataProvider, and NullMetadataProvider.
bool getPayloads | ( | int | exp, |
int | run, | ||
std::vector< PayloadMetadata > & | info | ||
) |
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.
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.
exp | the experiment number | |
run | the run number | |
[in,out] | info | a list of metadata instances which we try to find the missing metadata for. |
Definition at line 36 of file MetadataProvider.cc.
|
inline |
Get the valid tag states when checking globaltag status.
Definition at line 122 of file MetadataProvider.h.
|
protected |
Print an INFO message about the used metadata provider.
provider | the actual metadata provider used for the job |
Definition at line 114 of file MetadataProvider.cc.
bool setTags | ( | const std::vector< std::string > & | tags | ) |
Set the list of globaltag names to be considered for payloads.
This should be called before requesting any payloads but after calling setValidTagStates().
Definition at line 15 of file MetadataProvider.cc.
|
inline |
Set the valid tag states for this provider when checking globaltag status.
Should be called before setTags() if necessary.
Definition at line 128 of file MetadataProvider.h.
|
protectedpure virtual |
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.
Implemented in CentralMetadataProvider, LocalMetadataProvider, and NullMetadataProvider.
|
protected |
Map of globaltag->known metadata.
Definition at line 172 of file MetadataProvider.h.
|
protected |
Map of known payloads for current conditions.
Definition at line 174 of file MetadataProvider.h.
|
protected |
List of globaltags to consider.
Definition at line 170 of file MetadataProvider.h.
|
protected |
Set of global tag states to consider valid (except for 'INVALID' which is always considered invalid)
Definition at line 176 of file MetadataProvider.h.