20#ifndef __XrdThrottleManager_hh_
21#define __XrdThrottleManager_hh_
24#define likely(x) __builtin_expect(!!(x), 1)
25#define unlikely(x) __builtin_expect(!!(x), 0)
35#include <unordered_map>
53bool OpenFile(
const std::string &entity, std::string &open_error_message);
56void Apply(
int reqsize,
int reqops,
int uid);
60void SetThrottles(
float reqbyterate,
float reqoprate,
int concurrency,
float interval_length)
64void SetLoadShed(std::string &hostname,
unsigned port,
unsigned frequency)
82void PerformLoadShed(
const std::string &opaque, std::string &host,
unsigned &port);
145std::unordered_map<std::string, std::unique_ptr<std::unordered_map<pid_t, unsigned long>>>
m_active_conns;
161 struct timespec end_timer = {0, 0};
162#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
163 int retval = clock_gettime(
clock_id, &end_timer);
169 end_timer.tv_sec -=
m_timer.tv_sec;
170 end_timer.tv_nsec -=
m_timer.tv_nsec;
171 if (end_timer.tv_nsec < 0)
174 end_timer.tv_nsec += 1000000000;
198#if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__))
#define likely(x)
Definition XrdThrottleManager.hh:27
#define unlikely(x)
Definition XrdThrottleManager.hh:28
Definition XrdOucTrace.hh:36
Definition XrdSysPthread.hh:79
Definition XrdSysError.hh:90
Definition XrdThrottleManager.hh:45
std::vector< int > m_secondary_ops_shares
Definition XrdThrottleManager.hh:124
~XrdThrottleManager()
Definition XrdThrottleManager.hh:86
unsigned m_loadshed_frequency
Definition XrdThrottleManager.hh:137
void SetThrottles(float reqbyterate, float reqoprate, int concurrency, float interval_length)
Definition XrdThrottleManager.hh:60
void SetMaxOpen(unsigned long max_open)
Definition XrdThrottleManager.hh:67
bool IsThrottling()
Definition XrdThrottleManager.hh:58
XrdSysError * m_log
Definition XrdThrottleManager.hh:108
int m_last_round_allocation
Definition XrdThrottleManager.hh:125
void Apply(int reqsize, int reqops, int uid)
unsigned long m_max_conns
Definition XrdThrottleManager.hh:142
float m_ops_per_second
Definition XrdThrottleManager.hh:115
void StopIOTimer(struct timespec)
void StealShares(int uid, int &reqsize, int &reqops)
std::unordered_map< std::string, unsigned long > m_conn_counters
Definition XrdThrottleManager.hh:144
std::unordered_map< std::string, std::unique_ptr< std::unordered_map< pid_t, unsigned long > > > m_active_conns
Definition XrdThrottleManager.hh:145
std::vector< int > m_secondary_bytes_shares
Definition XrdThrottleManager.hh:122
XrdOucTrace * m_trace
Definition XrdThrottleManager.hh:107
std::vector< int > m_primary_ops_shares
Definition XrdThrottleManager.hh:123
void SetLoadShed(std::string &hostname, unsigned port, unsigned frequency)
Definition XrdThrottleManager.hh:64
XrdSysCondVar m_compute_var
Definition XrdThrottleManager.hh:110
void PrepLoadShed(const char *opaque, std::string &lsOpaque)
bool CheckLoadShed(const std::string &opaque)
struct timespec m_io_wait
Definition XrdThrottleManager.hh:129
int m_loadshed_limit_hit
Definition XrdThrottleManager.hh:138
void GetShares(int &shares, int &request)
int m_io_counter
Definition XrdThrottleManager.hh:128
std::mutex m_file_mutex
Definition XrdThrottleManager.hh:146
XrdThrottleTimer StartIOTimer()
void SetMaxConns(unsigned long max_conns)
Definition XrdThrottleManager.hh:69
unsigned m_loadshed_port
Definition XrdThrottleManager.hh:136
int m_concurrency_limit
Definition XrdThrottleManager.hh:116
float m_interval_length_seconds
Definition XrdThrottleManager.hh:113
XrdThrottleManager(XrdSysError *lP, XrdOucTrace *tP)
static const char * TraceID
Definition XrdThrottleManager.hh:148
void PerformLoadShed(const std::string &opaque, std::string &host, unsigned &port)
float m_bytes_per_second
Definition XrdThrottleManager.hh:114
struct timespec m_stable_io_wait
Definition XrdThrottleManager.hh:132
std::vector< int > m_primary_bytes_shares
Definition XrdThrottleManager.hh:121
int m_stable_io_counter
Definition XrdThrottleManager.hh:131
bool CloseFile(const std::string &entity)
bool OpenFile(const std::string &entity, std::string &open_error_message)
static int GetUid(const char *username)
std::string m_loadshed_host
Definition XrdThrottleManager.hh:135
static const int m_max_users
Definition XrdThrottleManager.hh:120
std::unordered_map< std::string, unsigned long > m_file_counters
Definition XrdThrottleManager.hh:143
unsigned long m_max_open
Definition XrdThrottleManager.hh:141
static void * RecomputeBootstrap(void *pp)
Definition XrdThrottleManager.hh:153
static int clock_id
Definition XrdThrottleManager.hh:214
XrdThrottleTimer(XrdThrottleManager &manager)
Definition XrdThrottleManager.hh:195
XrdThrottleManager & m_manager
Definition XrdThrottleManager.hh:211
void StopTimer()
Definition XrdThrottleManager.hh:159
~XrdThrottleTimer()
Definition XrdThrottleManager.hh:185
struct timespec m_timer
Definition XrdThrottleManager.hh:212