![]() |
Project
|
#include <CCDBDownloader.h>
Public Member Functions | |
CCDBDownloader (uv_loop_t *uv_loop=nullptr) | |
~CCDBDownloader () | |
CURLcode | perform (CURL *handle) |
std::vector< CURLcode > | batchBlockingPerform (std::vector< CURL * > const &handleVector) |
void | asynchSchedule (CURL *handle, size_t *requestCounter) |
void | setMaxParallelConnections (int limit) |
void | setKeepaliveTimeoutTime (int timeoutMS) |
void | setConnectionTimeoutTime (int timeoutMS) |
void | setRequestTimeoutTime (int timeoutMS) |
void | setHappyEyeballsHeadstartTime (int headstartMS) |
void | setOfflineTimeoutSettings () |
void | setOnlineTimeoutSettings () |
void | runLoop (bool noWait) |
std::string | prepareLogMessage (std::string host_url, std::string userAgent, const std::string &path, long ts, const std::map< std::string, std::string > *headers, long httpCode) const |
std::string | trimHostUrl (std::string full_host_url) const |
Public Attributes | |
std::unordered_map< curl_socket_t, uv_timer_t * > | mSocketTimerMap |
uv_loop_t * | mUVLoop |
std::unordered_map< uv_handle_t *, bool > | mHandleMap |
int | mKeepaliveTimeoutMS = 100 |
int | mConnectionTimeoutMS = 60000 |
int | mRequestTimeoutMS = 300000 |
int | mHappyEyeballsHeadstartMS = 500 |
int | mMaxHandlesInUse = 3 |
bool | mExternalLoop |
A class encapsulating and performing simple CURL requests in terms of a so-called CURL multi-handle. A multi-handle allows to use a connection pool (connection cache) in the CURL layer even with short-lived CURL easy-handles. Thereby the overhead of connection to servers can be significantly reduced. For more info, see for instance https://everything.curl.dev/libcurl/connectionreuse.
Further, this class adds functionality on top of simple CURL (aysync requests, timeout handling, event loop, etc).
Definition at line 102 of file CCDBDownloader.h.
o2::ccdb::CCDBDownloader::CCDBDownloader | ( | uv_loop_t * | uv_loop = nullptr | ) |
Definition at line 81 of file CCDBDownloader.cxx.
o2::ccdb::CCDBDownloader::~CCDBDownloader | ( | ) |
Definition at line 120 of file CCDBDownloader.cxx.
void o2::ccdb::CCDBDownloader::asynchSchedule | ( | CURL * | handle, |
size_t * | requestCounter | ||
) |
Schedules an asynchronous transfer but doesn't perform it.
handle | Handle to be performed on. |
requestCounter | Counter shared by a batch of CURL handles. |
Definition at line 696 of file CCDBDownloader.cxx.
std::vector< CURLcode > o2::ccdb::CCDBDownloader::batchBlockingPerform | ( | std::vector< CURL * > const & | handleVector | ) |
Perform on a batch of handles in a blocking manner. Has the same effect as calling curl_easy_perform() on all handles in the vector.
handleVector | Handles to be performed on. |
Definition at line 673 of file CCDBDownloader.cxx.
CURLcode o2::ccdb::CCDBDownloader::perform | ( | CURL * | handle | ) |
Perform on a single handle in a blocking manner. Has the same effect as curl_easy_perform().
handle | Handle to be performed on. It can be reused or cleaned after perform finishes. |
Definition at line 646 of file CCDBDownloader.cxx.
std::string o2::ccdb::CCDBDownloader::prepareLogMessage | ( | std::string | host_url, |
std::string | userAgent, | ||
const std::string & | path, | ||
long | ts, | ||
const std::map< std::string, std::string > * | headers, | ||
long | httpCode | ||
) | const |
Returns a message describing the transfer an it's result.
Definition at line 732 of file CCDBDownloader.cxx.
void o2::ccdb::CCDBDownloader::runLoop | ( | bool | noWait | ) |
Run the uvLoop once.
noWait | Using this flag will cause the loop to run only if sockets have pendind data. |
Definition at line 641 of file CCDBDownloader.cxx.
Setter for the connection timeout.
Definition at line 304 of file CCDBDownloader.cxx.
Setter for the happy eyeballs headstart.
Definition at line 314 of file CCDBDownloader.cxx.
Limits the time a socket and its connection will be opened after transfer finishes.
Definition at line 299 of file CCDBDownloader.cxx.
Limits the number of parallel connections. Should be used only if no transfers are happening.
Definition at line 294 of file CCDBDownloader.cxx.
void o2::ccdb::CCDBDownloader::setOfflineTimeoutSettings | ( | ) |
Sets the timeout values selected for the offline environment.
Definition at line 319 of file CCDBDownloader.cxx.
void o2::ccdb::CCDBDownloader::setOnlineTimeoutSettings | ( | ) |
Sets the timeout values selected for the online environment.
Definition at line 326 of file CCDBDownloader.cxx.
Setter for the request timeout.
Definition at line 309 of file CCDBDownloader.cxx.
std::string o2::ccdb::CCDBDownloader::trimHostUrl | ( | std::string | full_host_url | ) | const |
Leaves only the protocol and host part of the url, discrading path and metadata.
Definition at line 416 of file CCDBDownloader.cxx.
int o2::ccdb::CCDBDownloader::mConnectionTimeoutMS = 60000 |
Time for connection to start before it times out.
Definition at line 129 of file CCDBDownloader.h.
bool o2::ccdb::CCDBDownloader::mExternalLoop |
Variable denoting whether an external or internal uv_loop is being used.
Definition at line 149 of file CCDBDownloader.h.
std::unordered_map<uv_handle_t*, bool> o2::ccdb::CCDBDownloader::mHandleMap |
Map used to store active uv_handles belonging to the CcdbDownloader. If internal uv_loop is used, then all uv_handles should be marked in this map.
Definition at line 119 of file CCDBDownloader.h.
int o2::ccdb::CCDBDownloader::mHappyEyeballsHeadstartMS = 500 |
Head start of IPv6 in regards to IPv4.
Definition at line 139 of file CCDBDownloader.h.
int o2::ccdb::CCDBDownloader::mKeepaliveTimeoutMS = 100 |
Time for which sockets will stay open after last download finishes
Definition at line 124 of file CCDBDownloader.h.
int o2::ccdb::CCDBDownloader::mMaxHandlesInUse = 3 |
Max number of handles that can be used at the same time
Definition at line 144 of file CCDBDownloader.h.
int o2::ccdb::CCDBDownloader::mRequestTimeoutMS = 300000 |
Time for request to finish before it times out.
Definition at line 134 of file CCDBDownloader.h.
std::unordered_map<curl_socket_t, uv_timer_t*> o2::ccdb::CCDBDownloader::mSocketTimerMap |
Timer starts for each socket when its respective transfer finishes, and is stopped when another transfer starts for that handle. When the timer runs out it closes the socket. The period for which socket stays open is defined by socketTimeoutMS.
Definition at line 109 of file CCDBDownloader.h.
uv_loop_t* o2::ccdb::CCDBDownloader::mUVLoop |
The UV loop which handles transfers. Can be created internally or provided through a constructor.
Definition at line 114 of file CCDBDownloader.h.