11#ifndef O2_CCDBDOWNLOADER_H_
12#define O2_CCDBDOWNLOADER_H_
14#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
26#include <condition_variable>
27#include <unordered_map>
41#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
43 std::multimap<std::string, std::string>
header;
54 std::map<std::string, std::string>*
headers;
64} DownloaderRequestData;
226 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;
231 std::string
trimHostUrl(std::string full_host_url)
const;
237 std::string prepareRedirectedURL(std::string
address, std::string potentialHost)
const;
246 void updateLocations(std::multimap<std::string, std::string>* headerMap, std::vector<std::string>*
locations,
int* locIndex)
const;
248 std::string mUserAgentId =
"CCDBDownloader";
252 void setupInternalUVLoop();
257 int mHandlesInUse = 0;
262 CURLM* mCurlMultiHandle =
nullptr;
272 std::vector<CURL*> mHandlesToBeAdded;
285 typedef struct curl_context_s {
287 curl_socket_t sockfd = -1;
294 typedef struct DataForSocket {
299 DataForSocket mSocketData;
301#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
305 typedef struct PerformData {
306 CURLcode* codeDestination;
307 size_t* requestsLeft;
311 DownloaderRequestData* requestData;
313 std::vector<curl_slist*>* options;
323 static void closesocketCallback(
void* clientp, curl_socket_t item);
325#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
327 std::string getNewLocation(PerformData* performData, std::vector<std::string>&
locations)
const;
330 void tryNewHost(PerformData* performData, CURL* easy_handle);
333 void getLocalContent(PerformData* performData, std::string& newLocation,
bool& contentRetrieved, std::vector<std::string>&
locations);
336 void httpRedirect(PerformData* performData, std::string& newLocation, CURL* easy_handle);
339 void followRedirect(PerformData* performData, CURL* easy_handle, std::vector<std::string>&
locations,
bool& rescheduled,
bool& contentRetrieved);
354 static int handleSocket(CURL* easy, curl_socket_t
s,
int action,
void* userp,
void* socketp);
382 static void destroyCurlContext(curl_context_t* context);
391 static int startTimeout(CURLM* multi,
long timeout_ms,
void* userp);
396 void initializeMultiHandle();
404 void transferFinished(CURL*
handle, CURLcode curlCode);
409 void checkMultiInfo();
411#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
415 void setHandleOptions(CURL*
handle, PerformData*
data);
423 curl_context_t* createCurlContext(curl_socket_t sockfd);
428 void checkHandleQueue();
437} DataForClosingSocket;
struct uv_timer_s uv_timer_t
struct uv_signal_s uv_signal_t
struct uv_async_s uv_async_t
struct uv_handle_s uv_handle_t
struct uv_poll_s uv_poll_t
struct uv_loop_s uv_loop_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char events
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error s
void setRequestTimeoutTime(int timeoutMS)
void setOfflineTimeoutSettings()
CURLcode perform(CURL *handle)
void asynchSchedule(CURL *handle, size_t *requestCounter)
std::string trimHostUrl(std::string full_host_url) const
void setKeepaliveTimeoutTime(int timeoutMS)
void runLoop(bool noWait)
std::vector< CURLcode > batchBlockingPerform(std::vector< CURL * > const &handleVector)
void setConnectionTimeoutTime(int timeoutMS)
void setHappyEyeballsHeadstartTime(int headstartMS)
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::unordered_map< uv_handle_t *, bool > mHandleMap
std::unordered_map< curl_socket_t, uv_timer_t * > mSocketTimerMap
int mHappyEyeballsHeadstartMS
void setMaxParallelConnections(int limit)
void setOnlineTimeoutSettings()
GLuint const GLint * locations
GLuint GLuint64EXT address
GLint GLint GLsizei GLint GLenum GLenum type
GLsizei const GLchar *const * path
information complementary to a CCDB object (path, metadata, startTimeValidity, endTimeValidity etc)
void closeHandles(uv_handle_t *handle, void *arg)
curl_socket_t opensocketCallback(void *clientp, curlsocktype purpose, struct curl_sockaddr *address)
void onUVClose(uv_handle_t *handle)
std::vector< T, fair::mq::pmr::polymorphic_allocator< T > > vector
std::function< bool(std::string)> localContentCallback
std::vector< curl_slist * > optionsLists
std::vector< std::string > locations
std::vector< std::string > hosts
std::map< std::string, std::string > * headers
HeaderObjectPair_t hoPair