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> 54 bool OpenFile(
const std::string &entity, std::string &open_error_message);
55 bool CloseFile(
const std::string &entity);
57 void Apply(
int reqsize,
int reqops,
int uid);
61 void SetThrottles(
float reqbyterate,
float reqoprate,
int concurrency,
float interval_length)
65 void SetLoadShed(std::string &hostname,
unsigned port,
unsigned frequency)
77 int GetUid(
const char *username);
81 void PrepLoadShed(
const char *opaque, std::string &lsOpaque);
85 void PerformLoadShed(
const std::string &opaque, std::string &host,
unsigned &port);
106 void GetShares(
int &shares,
int &request);
108 void StealShares(
int uid,
int &reqsize,
int &reqops);
150 std::unordered_map<std::string, std::unique_ptr<std::unordered_map<pid_t, unsigned long>>>
m_active_conns;
169 struct timespec end_timer = {0, 0};
170 #if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__)) 171 int retval = clock_gettime(
clock_id, &end_timer);
177 end_timer.tv_sec -=
m_timer.tv_sec;
178 end_timer.tv_nsec -=
m_timer.tv_nsec;
179 if (end_timer.tv_nsec < 0)
182 end_timer.tv_nsec += 1000000000;
206 #if defined(__linux__) || defined(__GNU__) || (defined(__FreeBSD_kernel__) && defined(__GLIBC__)) unsigned long m_max_conns
Definition: XrdThrottleManager.hh:147
~XrdThrottleManager()
Definition: XrdThrottleManager.hh:89
static int clock_id
Definition: XrdThrottleManager.hh:222
int m_stable_io_active
Definition: XrdThrottleManager.hh:135
void PerformLoadShed(const std::string &opaque, std::string &host, unsigned &port)
Definition: XrdThrottleManager.hh:45
static const int m_max_users
Definition: XrdThrottleManager.hh:123
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:68
float m_ops_per_second
Definition: XrdThrottleManager.hh:118
XrdThrottleManager(XrdSysError *lP, XrdOucTrace *tP)
float m_interval_length_seconds
Definition: XrdThrottleManager.hh:116
void StopTimer()
Definition: XrdThrottleManager.hh:167
unsigned long m_max_open
Definition: XrdThrottleManager.hh:146
std::vector< int > m_secondary_bytes_shares
Definition: XrdThrottleManager.hh:125
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:65
XrdThrottleTimer(XrdThrottleManager &manager)
Definition: XrdThrottleManager.hh:203
Definition: XrdThrottleManager.hh:160
static int GetUid(const char *username)
std::unordered_map< std::string, unsigned long > m_file_counters
Definition: XrdThrottleManager.hh:148
void GetShares(int &shares, int &request)
int m_io_active
Definition: XrdThrottleManager.hh:131
bool OpenFile(const std::string &entity, std::string &open_error_message)
XrdThrottleManager & m_manager
Definition: XrdThrottleManager.hh:219
XrdOucTrace * m_trace
Definition: XrdThrottleManager.hh:110
struct timespec m_stable_io_wait
Definition: XrdThrottleManager.hh:137
XrdSysCondVar m_compute_var
Definition: XrdThrottleManager.hh:113
Definition: XrdSysPthread.hh:78
std::vector< int > m_primary_bytes_shares
Definition: XrdThrottleManager.hh:124
bool IsThrottling()
Definition: XrdThrottleManager.hh:59
void SetMaxConns(unsigned long max_conns)
Definition: XrdThrottleManager.hh:70
struct timespec m_timer
Definition: XrdThrottleManager.hh:220
void SetMonitor(XrdXrootdGStream *gstream)
Definition: XrdThrottleManager.hh:72
std::string m_loadshed_host
Definition: XrdThrottleManager.hh:140
struct timespec m_io_wait
Definition: XrdThrottleManager.hh:132
Definition: XrdXrootdGStream.hh:43
std::mutex m_file_mutex
Definition: XrdThrottleManager.hh:151
unsigned m_loadshed_port
Definition: XrdThrottleManager.hh:141
void SetThrottles(float reqbyterate, float reqoprate, int concurrency, float interval_length)
Definition: XrdThrottleManager.hh:61
std::vector< int > m_primary_ops_shares
Definition: XrdThrottleManager.hh:126
void StealShares(int uid, int &reqsize, int &reqops)
~XrdThrottleTimer()
Definition: XrdThrottleManager.hh:193
std::unordered_map< std::string, std::unique_ptr< std::unordered_map< pid_t, unsigned long > > > m_active_conns
Definition: XrdThrottleManager.hh:150
int m_last_round_allocation
Definition: XrdThrottleManager.hh:128
unsigned m_io_total
Definition: XrdThrottleManager.hh:133
int m_concurrency_limit
Definition: XrdThrottleManager.hh:119
int m_stable_io_total
Definition: XrdThrottleManager.hh:136
unsigned m_loadshed_frequency
Definition: XrdThrottleManager.hh:142
std::unordered_map< std::string, unsigned long > m_conn_counters
Definition: XrdThrottleManager.hh:149
int m_loadshed_limit_hit
Definition: XrdThrottleManager.hh:143
float m_bytes_per_second
Definition: XrdThrottleManager.hh:117
#define likely(x)
Definition: XrdThrottleManager.hh:27
#define unlikely(x)
Definition: XrdThrottleManager.hh:28
XrdXrootdGStream * m_gstream
Definition: XrdThrottleManager.hh:154
std::vector< int > m_secondary_ops_shares
Definition: XrdThrottleManager.hh:127
static const char * TraceID
Definition: XrdThrottleManager.hh:156
void Apply(int reqsize, int reqops, int uid)
XrdSysError * m_log
Definition: XrdThrottleManager.hh:111
void StopIOTimer(struct timespec)
XrdThrottleTimer StartIOTimer()