![]() |
Belle II Software
release-05-02-19
|
Class to obtain payload metadata from the central database server via REST requests. More...
#include <CentralMetadataProvider.h>
Public Types | |
using | PayloadMap = std::unordered_map< std::string, PayloadMetadata > |
Type for the internal list of payloads. | |
Public Member Functions | |
CentralMetadataProvider (std::string baseUrl, const std::set< std::string > &usableTagStates) | |
Create using a base rest url to find the server endpoints. | |
virtual | ~CentralMetadataProvider ()=default |
default destructor | |
std::string | getGlobaltagStatus (const std::string &name) override |
Check the status of a given globaltag . More... | |
bool | updatePayloads (const std::string &globaltag, int exp, int run) override |
Update the list of known payloads for the given globaltag/exp/run. More... | |
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 | |
void | addPayload (PayloadMetadata &&payload, const std::string &messagePrefix="") |
Add a payload information to the internal list. More... | |
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) | |
Private Member Functions | |
nlohmann::json | get (const std::string &url) |
Downlad a given relative url (the baseUrl will be prependend) and return the json description. More... | |
Private Attributes | |
Downloader & | m_downloader {Downloader::getDefaultInstance()} |
Reference to the downloader instance for convenience. | |
std::string | m_baseUrl |
base url of the server | |
Class to obtain payload metadata from the central database server via REST requests.
Definition at line 26 of file CentralMetadataProvider.h.
|
protectedinherited |
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 101 of file MetadataProvider.cc.
|
private |
Downlad a given relative url (the baseUrl will be prependend) and return the json description.
Will raise exceptions on error
Definition at line 42 of file CentralMetadataProvider.cc.
|
overridevirtual |
Check the status of a given globaltag .
Implements MetadataProvider.
Definition at line 52 of file CentralMetadataProvider.cc.
|
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.
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 46 of file MetadataProvider.cc.
|
inherited |
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 25 of file MetadataProvider.cc.
|
inlineinherited |
Set the valid tag states for this provider when checking globaltag status.
Should be called before setTags() if necessary.
Definition at line 146 of file MetadataProvider.h.
|
overridevirtual |
Update the list of known payloads for the given globaltag/exp/run.
This basically just calls addPayload() for each payload it finds in the globaltag for the given exp/run.
Implements MetadataProvider.
Definition at line 70 of file CentralMetadataProvider.cc.