Belle II Software light-2406-ragdoll
|
Class to find payload files in a list of locations. More...
#include <PayloadProvider.h>
Classes | |
struct | PayloadLocation |
Simple struct to represent a lookup location. More... | |
Public Types | |
enum class | EDirectoryLayout { c_flat , c_hashed } |
Enumeration of different directory layouts. More... | |
Public Member Functions | |
PayloadProvider (const std::vector< std::string > &locations, const std::string &cachedir="", int timeout=60) | |
Constructor for a given list of locations and optionally the location where downloaded payloads should be cached Each location can either be a path to a directory or a http/https url of a server where the payloads can be downloaded (starting with http(s):// ). | |
bool | find (PayloadMetadata &meta) |
Try to find a payload, return true on success, false if it cannot be found. | |
Private Member Functions | |
bool | getLocalFile (const PayloadLocation &loc, PayloadMetadata &meta) const |
Look for a payload in the local directory location, set the filename member of the metadata instance and return true on succes. | |
bool | getRemoteFile (const PayloadLocation &loc, PayloadMetadata &meta) |
Look for a payload on a remote server and download if possible, set the filename member of the metadata instance and return true on succes. | |
bool | getTemporaryFile (const std::string &url, PayloadMetadata &meta, bool silentOnMissing) |
Try to download url into a temporary file, if successful set the filename member of the metadata and return true. | |
std::string | getFilename (EDirectoryLayout structure, const PayloadMetadata &payload) const |
Return the filename of a payload to look for given a directory structure and some metadata. | |
Private Attributes | |
std::vector< PayloadLocation > | m_locations |
List of configured lookup locations: The first one will always be the cache directory and the last one will always be fallback url included in the payload metadata. | |
PayloadLocation | m_cacheDir |
Location of the cache directory where/how we want to store downloaded payloads. | |
Downloader & | m_downloader {Downloader::getDefaultInstance()} |
Instance to the database file downloading instance. | |
std::unordered_map< std::string, std::unique_ptr< FileSystem::TemporaryFile > > | m_temporaryFiles |
Map of all active temporary files we downloaded and keep around until they can be closed. | |
int | m_timeout |
Timeout to wait for a write look when trying to download payloads. | |
Class to find payload files in a list of locations.
Definition at line 20 of file PayloadProvider.h.
|
strong |
Enumeration of different directory layouts.
Definition at line 32 of file PayloadProvider.h.
|
explicit |
Constructor for a given list of locations and optionally the location where downloaded payloads should be cached Each location can either be a path to a directory or a http/https url of a server where the payloads can be downloaded (starting with http(s)://
).
For remote locations starting with http(s) we require that the payloads follow the same layout as on the central server. That is the location plus the value returned by the metadata for payloadUrl
should point to the correct file.
For local locations we support two different layouts which will be auto detected and can be mixed:
dbstore_{NAME}_rev_{REVISION}.root
/AB/{NAME}_r{REVISION}.root
where A and B are the first two characters of the md5 checksum of the payload file.If cachedir is empty a default value of $TMPDIR/basf2-conditions
is assumed. Downloaded payloads will be placed in the cachedir using the hashed directory structure.
Definition at line 21 of file PayloadProvider.cc.
bool find | ( | PayloadMetadata & | meta | ) |
Try to find a payload, return true on success, false if it cannot be found.
This will go through all configured payloads locations and if it can find the payload will set the filename member of the metadata instance and return true.
Definition at line 64 of file PayloadProvider.cc.
|
private |
Return the filename of a payload to look for given a directory structure and some metadata.
Definition at line 168 of file PayloadProvider.cc.
|
private |
Look for a payload in the local directory location, set the filename member of the metadata instance and return true on succes.
Definition at line 72 of file PayloadProvider.cc.
|
private |
Look for a payload on a remote server and download if possible, set the filename member of the metadata instance and return true on succes.
Definition at line 93 of file PayloadProvider.cc.
|
private |
Try to download url into a temporary file, if successful set the filename member of the metadata and return true.
Otherwise return false. If silentOnMissing is true a 404 error will not be treated as worthy of a message
Definition at line 184 of file PayloadProvider.cc.
|
private |
Location of the cache directory where/how we want to store downloaded payloads.
Definition at line 93 of file PayloadProvider.h.
|
private |
Instance to the database file downloading instance.
Definition at line 95 of file PayloadProvider.h.
|
private |
List of configured lookup locations: The first one will always be the cache directory and the last one will always be fallback url included in the payload metadata.
Definition at line 91 of file PayloadProvider.h.
|
private |
Map of all active temporary files we downloaded and keep around until they can be closed.
Definition at line 97 of file PayloadProvider.h.
|
private |
Timeout to wait for a write look when trying to download payloads.
Definition at line 99 of file PayloadProvider.h.