Belle II Software light-2406-ragdoll
|
Class to obtain metadata of all valid payloads from a local SQLite file instead of the central server. More...
#include <LocalMetadataProvider.h>
Public Types | |
using | PayloadMap = std::unordered_map< std::string, PayloadMetadata > |
Type for the internal list of payloads. | |
Public Member Functions | |
LocalMetadataProvider (std::string filename, const std::set< std::string > &usableTagStates) | |
Construct with the name of the sqlite file. | |
LocalMetadataProvider (const LocalMetadataProvider &)=delete | |
copy constructor | |
LocalMetadataProvider (LocalMetadataProvider &&)=delete | |
move constructor | |
LocalMetadataProvider & | operator= (const LocalMetadataProvider &)=delete |
assignment operator | |
LocalMetadataProvider & | operator= (LocalMetadataProvider &&)=delete |
move assignment operator | |
virtual | ~LocalMetadataProvider ()=default |
default destructor | |
std::string | getGlobaltagStatus (const std::string &globaltag) override |
Return the status of the given globaltag. | |
bool | updatePayloads (const std::string &globaltag, int exp, int run) override |
Update the list of existing payloads from a given globaltag, exp and run combination. | |
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 | |
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) | |
Private Attributes | |
std::string | m_filename |
Filename for the sqlite database file. | |
sqlite::Connection | m_connection |
SQLite connection object. | |
sqlite::SimpleStatement< std::string > | m_globaltagStatus |
SQLite statement to return the status of a global tag. | |
sqlite::ObjectStatement< PayloadMetadata, std::string, std::string, std::string, std::string, std::string, int, int, int, int, int > | m_selectPayloads |
SQLite statement to return all payloads for a given globaltag, exp, run. | |
Class to obtain metadata of all valid payloads from a local SQLite file instead of the central server.
This is intended as a fallback in case the official server is not reachable or a way to download the conditions for use without internet connection.
In contrast to a LocalDatabase this class just provides local access to payload information previously downloaded from the central server. There's no method nor is it intended to put custom payloads for testing into such a downloaded file. It is always assumed that the content in these files is identical to the central database server
The requirements for the sqlite file are
Definition at line 46 of file LocalMetadataProvider.h.
|
inherited |
Type for the internal list of payloads.
Definition at line 30 of file MetadataProvider.h.
LocalMetadataProvider | ( | std::string | filename, |
const std::set< std::string > & | usableTagStates | ||
) |
Construct with the name of the sqlite file.
Definition at line 15 of file LocalMetadataProvider.cc.
|
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 91 of file MetadataProvider.cc.
|
overridevirtual |
Return the status of the given globaltag.
globaltag | name of the globaltag |
Implements MetadataProvider.
Definition at line 31 of file LocalMetadataProvider.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 36 of file MetadataProvider.cc.
|
inlineinherited |
Get the valid tag states when checking globaltag status.
Definition at line 122 of file MetadataProvider.h.
|
protectedinherited |
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.
|
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 15 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 128 of file MetadataProvider.h.
|
overridevirtual |
Update the list of existing payloads from a given globaltag, exp and run combination.
Calls addPayload() for each payload it finds
Implements MetadataProvider.
Definition at line 46 of file LocalMetadataProvider.cc.
|
protectedinherited |
Map of globaltag->known metadata.
Definition at line 172 of file MetadataProvider.h.
|
private |
SQLite connection object.
Definition at line 78 of file LocalMetadataProvider.h.
|
private |
Filename for the sqlite database file.
Definition at line 76 of file LocalMetadataProvider.h.
|
private |
SQLite statement to return the status of a global tag.
Definition at line 80 of file LocalMetadataProvider.h.
|
protectedinherited |
Map of known payloads for current conditions.
Definition at line 174 of file MetadataProvider.h.
|
private |
SQLite statement to return all payloads for a given globaltag, exp, run.
Definition at line 84 of file LocalMetadataProvider.h.
|
protectedinherited |
List of globaltags to consider.
Definition at line 170 of file MetadataProvider.h.
|
protectedinherited |
Set of global tag states to consider valid (except for 'INVALID' which is always considered invalid)
Definition at line 176 of file MetadataProvider.h.