5 #ifndef CVMFS_NETWORK_DOWNLOAD_H_
6 #define CVMFS_NETWORK_DOWNLOAD_H_
19 #include "gtest/gtest_prod.h"
52 "Number of transferred bytes");
54 "Transfer time (milliseconds)");
56 "Number of requests");
59 "Number of proxy failovers");
61 "Number of host failovers");
78 curl_slist *
GetList(
const char *header);
80 void AppendHeader(curl_slist *slist,
const char *header);
81 void CutHeader(
const char *header, curl_slist **slist);
82 void PutList(curl_slist *slist);
83 std::string
Print(curl_slist *slist);
86 static const unsigned kBlockSize = 4096/
sizeof(curl_slist);
88 bool IsUsed(curl_slist *slist) {
return slist->data != NULL; }
89 curl_slist *
Get(
const char *header);
90 void Put(curl_slist *slist);
107 void **info_data) = 0;
160 const std::string &name =
"standard");
167 const std::string &cloned_name);
174 void SetDnsTtlLimits(
const unsigned min_seconds,
const unsigned max_seconds);
176 void SetTimeout(
const unsigned seconds_proxy,
const unsigned seconds_direct);
177 void GetTimeout(
unsigned *seconds_proxy,
unsigned *seconds_direct);
180 void SetHostChain(
const std::vector<std::string> &host_list);
181 void GetHostInfo(std::vector<std::string> *host_chain,
182 std::vector<int> *rtt,
unsigned *current_host);
190 std::vector<uint64_t> *output_order = NULL);
193 const std::string &fallback_proxy_list,
195 void GetProxyInfo(std::vector< std::vector<ProxyInfo> > *proxy_chain,
196 unsigned *current_group,
197 unsigned *fallback_group);
206 const unsigned backoff_init_ms,
207 const unsigned backoff_max_ms);
232 void *userp,
void *socketp);
235 bool StripDirect(
const std::string &proxy_list, std::string *cleaned_list);
237 const unsigned expected_size,
238 std::vector<uint64_t> *reply_vals);
260 std::string
EscapeUrl(
const int64_t jobinfo_id,
const std::string &url);
261 unsigned EscapeHeader(
const std::string &header,
char *escaped_buf,
449 #endif // CVMFS_NETWORK_DOWNLOAD_H_
unsigned opt_timeout_direct_
std::vector< std::string > http_tracing_headers_
bool StripDirect(const std::string &proxy_list, std::string *cleaned_list)
unsigned opt_low_speed_limit_
static const unsigned kDnsDefaultTimeoutMs
bool ignore_signature_failures_
unsigned opt_backoff_init_ms_
bool enable_http_tracing_
bool EscapeUrlChar(unsigned char input, char output[3])
unsigned opt_proxy_groups_current_burned_
unsigned opt_proxy_groups_reset_after_
void SetUrlOptions(JobInfo *info)
void ReleaseCredential(JobInfo *info)
SharedPtr< ShardingPolicy > sharding_policy_
std::string opt_proxy_fallback_list_
void SetHostChain(const std::string &host_list)
void SetNocache(JobInfo *info)
unsigned opt_host_reset_after_
void SetLowSpeedLimit(const unsigned low_speed_limit)
DownloadManager(const unsigned max_pool_handles, const perf::StatisticsTemplate &statistics, const std::string &name="standard")
std::string proxy_template_direct_
std::vector< std::string > opt_proxies_
static int ParseHttpCode(const char digits[3])
FRIEND_TEST(T_Download, ValidateGeoReply)
static const int kProbeGeo
unsigned opt_proxy_groups_current_
bool ValidateGeoReply(const std::string &reply_order, const unsigned expected_size, std::vector< uint64_t > *reply_vals)
std::vector< ProxyInfo > * current_proxy_group() const
time_t opt_timestamp_backup_proxies_
void SetProxyChain(const std::string &proxy_list, const std::string &fallback_proxy_list, const ProxySetModes set_mode)
std::string GetProxyList()
std::set< CURL * > * pool_handles_inuse_
pthread_mutex_t * lock_options_
ProxyInfo * ChooseProxyUnlocked(const shash::Any *hash)
pthread_t thread_download_
ProxyInfo(const dns::Host &host, const std::string &url)
std::string opt_proxy_list_
perf::Counter * sz_transfer_time
std::vector< std::vector< ProxyInfo > > * opt_proxy_groups_
unsigned opt_proxy_groups_fallback_
curl_slist * default_headers_
void ReleaseCurlHandle(CURL *handle)
void SetDnsServer(const std::string &address)
DownloadManager * Clone(const perf::StatisticsTemplate &statistics, const std::string &cloned_name)
virtual ~CredentialsAttachment()
static void * MainDownload(void *data)
void SetTimeout(const unsigned seconds_proxy, const unsigned seconds_direct)
perf::Counter * n_retries
std::string opt_dns_server_
uint32_t watch_fds_inuse_
void Backoff(JobInfo *info)
perf::Counter * sz_transferred_bytes
void SetFqrn(const std::string &fqrn)
std::string EscapeUrl(const int64_t jobinfo_id, const std::string &url)
Counter * RegisterTemplated(const std::string &name_minor, const std::string &desc)
void UpdateStatistics(CURL *handle)
void SetDnsTtlLimits(const unsigned min_seconds, const unsigned max_seconds)
uint32_t pool_max_handles_
void GetProxyInfo(std::vector< std::vector< ProxyInfo > > *proxy_chain, unsigned *current_group, unsigned *fallback_group)
void SetProxyGroupResetDelay(const unsigned seconds)
atomic_int32 multi_threaded_
dns::NormalResolver * resolver_
ProxyInfo(const std::string &url)
dns::IpPreference opt_ip_preference_
bool SetShardingPolicy(const ShardingPolicySelector type)
perf::Counter * n_host_failover
void UpdateProxiesUnlocked(const std::string &reason)
void SetIpPreference(const dns::IpPreference preference)
bool failover_indefinitely_
perf::Counter * n_requests
void SetRetryParameters(const unsigned max_retries, const unsigned backoff_init_ms, const unsigned backoff_max_ms)
void SetRegularCache(JobInfo *info)
void CloneProxyConfig(DownloadManager *clone)
void SetMaxIpaddrPerProxy(unsigned limit)
void EnableIgnoreSignatureFailures()
CURL * AcquireCurlHandle()
std::vector< int > * opt_host_chain_rtt_
dns::IpPreference opt_ip_preference() const
SslCertificateStore ssl_certificate_store_
time_t opt_timestamp_backup_host_
std::string GetFallbackProxyList()
void SetProxyTemplates(const std::string &direct, const std::string &forced)
unsigned opt_backoff_max_ms_
std::string GetDnsServer() const
unsigned opt_num_proxies_
unsigned opt_host_chain_current_
CredentialsAttachment * credentials_attachment_
std::vector< std::string > * opt_host_chain_
struct pollfd * watch_fds_
std::map< uint32_t, ProxyInfo * > opt_proxy_map_
UniquePtr< Pipe< kPipeDownloadJobs > > pipe_jobs_
void UseSystemCertificatePath()
Failures Fetch(JobInfo *info)
unsigned opt_max_retries_
bool CanRetry(const JobInfo *info)
perf::Counter * n_proxy_failover
void GetTimeout(unsigned *seconds_proxy, unsigned *seconds_direct)
void SetFailoverIndefinitely()
std::string proxy_template_forced_
time_t opt_timestamp_failover_proxies_
void SetDnsParameters(const unsigned retries, const unsigned timeout_ms)
unsigned EscapeHeader(const std::string &header, char *escaped_buf, size_t buf_size)
UniquePtr< Pipe< kPipeThreadTerminator > > pipe_terminate_
static const int kProbeUnprobed
virtual void ReleaseCurlHandle(CURL *curl_handle, void *info_data)=0
static const unsigned kDnsDefaultRetries
bool GeoSortServers(std::vector< std::string > *servers, std::vector< uint64_t > *output_order=NULL)
static const int kProbeDown
Counters(perf::StatisticsTemplate statistics)
static const unsigned kProxyMapScale
void GetHostInfo(std::vector< std::string > *host_chain, std::vector< int > *rtt, unsigned *current_host)
bool ValidateProxyIpsUnlocked(const std::string &url, const dns::Host &host)
unsigned opt_timeout_proxy_
bool VerifyAndFinalize(const int curl_error, JobInfo *info)
SharedPtr< HealthCheck > health_check_
void SwitchProxy(JobInfo *info)
void AddHTTPTracingHeader(const std::string &header)
void SetCredentialsAttachment(CredentialsAttachment *ca)
std::set< CURL * > * pool_handles_idle_
void RebalanceProxiesUnlocked(const std::string &reason)
pthread_mutex_t * lock_synchronous_mode_
virtual bool ConfigureCurlHandle(CURL *curl_handle, pid_t pid, void **info_data)=0
void InitializeRequest(JobInfo *info, CURL *handle)
static int CallbackCurlSocket(CURL *easy, curl_socket_t s, int action, void *userp, void *socketp)
HeaderLists * header_lists_
void SetHostResetDelay(const unsigned seconds)