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> 53 bool OpenFile(
const std::string &entity, std::string &open_error_message);
54 bool CloseFile(
const std::string &entity);
56 void Apply(
int reqsize,
int reqops,
int uid);
60 void SetThrottles(
float reqbyterate,
float reqoprate,
int concurrency,
float interval_length)
64 void SetLoadShed(std::string &hostname,
unsigned port,
unsigned frequency)
74 int GetUid(
const char *username);
78 void PrepLoadShed(
const char *opaque, std::string &lsOpaque);
82 void PerformLoadShed(
const std::string &opaque, std::string &host,
unsigned &port);
103 void GetShares(
int &shares,
int &request);
105 void StealShares(
int uid,
int &reqsize,
int &reqops);
145 std::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__)) unsigned long m_max_conns
Definition: XrdThrottleManager.hh:142
~XrdThrottleManager()
Definition: XrdThrottleManager.hh:86
static int clock_id
Definition: XrdThrottleManager.hh:214
void PerformLoadShed(const std::string &opaque, std::string &host, unsigned &port)
Definition: XrdThrottleManager.hh:44
static const int m_max_users
Definition: XrdThrottleManager.hh:120
void PrepLoadShed(const char *opaque, std::string &lsOpaque)
bool CheckLoadShed(const std::string &opaque)
static void * RecomputeBootstrap(void *pp)
void SetMaxOpen(unsigned long max_open)
Definition: XrdThrottleManager.hh:67
float m_ops_per_second
Definition: XrdThrottleManager.hh:115
XrdThrottleManager(XrdSysError *lP, XrdOucTrace *tP)
float m_interval_length_seconds
Definition: XrdThrottleManager.hh:113
void StopTimer()
Definition: XrdThrottleManager.hh:159
unsigned long m_max_open
Definition: XrdThrottleManager.hh:141
std::vector< int > m_secondary_bytes_shares
Definition: XrdThrottleManager.hh:122
bool CloseFile(const std::string &entity)
Definition: XrdOucTrace.hh:35
Definition: XrdSysError.hh:89
void SetLoadShed(std::string &hostname, unsigned port, unsigned frequency)
Definition: XrdThrottleManager.hh:64
XrdThrottleTimer(XrdThrottleManager &manager)
Definition: XrdThrottleManager.hh:195
Definition: XrdThrottleManager.hh:152
static int GetUid(const char *username)
std::unordered_map< std::string, unsigned long > m_file_counters
Definition: XrdThrottleManager.hh:143
void GetShares(int &shares, int &request)
bool OpenFile(const std::string &entity, std::string &open_error_message)
XrdThrottleManager & m_manager
Definition: XrdThrottleManager.hh:211
XrdOucTrace * m_trace
Definition: XrdThrottleManager.hh:107
struct timespec m_stable_io_wait
Definition: XrdThrottleManager.hh:132
XrdSysCondVar m_compute_var
Definition: XrdThrottleManager.hh:110
Definition: XrdSysPthread.hh:78
std::vector< int > m_primary_bytes_shares
Definition: XrdThrottleManager.hh:121
bool IsThrottling()
Definition: XrdThrottleManager.hh:58
void SetMaxConns(unsigned long max_conns)
Definition: XrdThrottleManager.hh:69
struct timespec m_timer
Definition: XrdThrottleManager.hh:212
std::string m_loadshed_host
Definition: XrdThrottleManager.hh:135
struct timespec m_io_wait
Definition: XrdThrottleManager.hh:129
std::mutex m_file_mutex
Definition: XrdThrottleManager.hh:146
unsigned m_loadshed_port
Definition: XrdThrottleManager.hh:136
void SetThrottles(float reqbyterate, float reqoprate, int concurrency, float interval_length)
Definition: XrdThrottleManager.hh:60
std::vector< int > m_primary_ops_shares
Definition: XrdThrottleManager.hh:123
void StealShares(int uid, int &reqsize, int &reqops)
~XrdThrottleTimer()
Definition: XrdThrottleManager.hh:185
std::unordered_map< std::string, std::unique_ptr< std::unordered_map< pid_t, unsigned long > > > m_active_conns
Definition: XrdThrottleManager.hh:145
int m_last_round_allocation
Definition: XrdThrottleManager.hh:125
int m_concurrency_limit
Definition: XrdThrottleManager.hh:116
unsigned m_loadshed_frequency
Definition: XrdThrottleManager.hh:137
std::unordered_map< std::string, unsigned long > m_conn_counters
Definition: XrdThrottleManager.hh:144
int m_loadshed_limit_hit
Definition: XrdThrottleManager.hh:138
float m_bytes_per_second
Definition: XrdThrottleManager.hh:114
int m_io_counter
Definition: XrdThrottleManager.hh:128
#define likely(x)
Definition: XrdThrottleManager.hh:27
#define unlikely(x)
Definition: XrdThrottleManager.hh:28
int m_stable_io_counter
Definition: XrdThrottleManager.hh:131
std::vector< int > m_secondary_ops_shares
Definition: XrdThrottleManager.hh:124
static const char * TraceID
Definition: XrdThrottleManager.hh:148
void Apply(int reqsize, int reqops, int uid)
XrdSysError * m_log
Definition: XrdThrottleManager.hh:108
void StopIOTimer(struct timespec)
XrdThrottleTimer StartIOTimer()