XRootD
Loading...
Searching...
No Matches
XrdThrottleConfig.hh
Go to the documentation of this file.
1
2#ifndef XrdThrottle_Config_hh
3#define XrdThrottle_Config_hh
4
5#include <string>
6
7class XrdOucEnv;
8class XrdOucStream;
9class XrdSysError;
10
11namespace XrdThrottle {
12
14public:
16 : m_env(env), m_log(log)
17 {}
18
19 // Generate the XrdThrottle configuration from the given file name.
20 //
21 // Returns 0 on success, or a non-zero error code on failure.
22 int Configure(const std::string &config_file);
23
24 // Get the configuration for the fslib to use.
25 // The default is "libXrdOfs.so".
26 const std::string &GetFileSystemLibrary() const { return m_fslib; }
27
28 // Get the configuration for the loadshed hostname.
29 // If not set, the default is empty.
30 const std::string &GetLoadshedHost() const { return m_loadshed_hostname; }
31
32 // Get the configuration for the loadshed port.
33 // Valid values are 1 to 65535.
34 // If not set, the default is 0.
35 long long GetLoadshedPort() const { return m_loadshed_port; }
36
37 // Get the configuration for the loadshed frequency.
38 // Valid values are 1 to 100.
39 // If not set, the default is 0.
40 long long GetLoadshedFreq() const { return m_loadshed_freq; }
41
42 // Get the configuration for th maximum number of open files.
43 // If -1, no limit is set.
44 long long GetMaxOpen() const { return m_max_open; }
45
46 // Get the configuration for the maximum number of active connections.
47 // If -1, no limit is set.
48 long long GetMaxConn() const { return m_max_conn; }
49
50 // Get the configuration for the maximum wait time before a request is
51 // failed with EMFILE.
52 // If not set, the default is 30 seconds.
53 long long GetMaxWait() const { return m_max_wait; }
54
55 // Get the configuration for the throttle concurrency limit.
56 // If -1, no limit is set.
57 long long GetThrottleConcurrency() const { return m_throttle_concurrency_limit; }
58
59 // Get the configuration for the maximum number of bytes per second.
60 // If -1, no limit is set.
61 long long GetThrottleDataRate() const { return m_throttle_data_rate; }
62
63 // Get the configuration for the maximum number of IOPS per second.
64 // If -1, no limit is set.
65 long long GetThrottleIOPSRate() const { return m_throttle_iops_rate; }
66
67 // Get the configuration for the recompute interval, in milliseconds.
68 // If not set, the default is 1000 ms.
69 long long GetThrottleRecomputeIntervalMS() const { return m_throttle_recompute_interval_ms; }
70
71 // Get the configuration for the trace levels.
72 // If not set, the default is 0.
73 int GetTraceLevels() const { return m_trace_levels; }
74
75private:
76 int xloadshed(XrdOucStream &Config);
77 int xmaxopen(XrdOucStream &Config);
78 int xmaxconn(XrdOucStream &Config);
79 int xmaxwait(XrdOucStream &Config);
80 int xthrottle(XrdOucStream &Config);
81 int xtrace(XrdOucStream &Config);
82
83 XrdOucEnv *m_env{nullptr};
84 std::string m_fslib{"libXrdOfs.so"};
85 XrdSysError &m_log;
86 std::string m_loadshed_hostname;
87 long long m_loadshed_freq{0};
88 long long m_loadshed_port{0};
89 long long m_max_conn{-1};
90 long long m_max_open{-1};
91 long long m_max_wait{30};
92 long long m_throttle_concurrency_limit{-1};
93 long long m_throttle_data_rate{-1};
94 long long m_throttle_iops_rate{-1};
95 long long m_throttle_recompute_interval_ms{1000};
96 int m_trace_levels{0};
97};
98
99} // namespace XrdThrottle
100
101#endif // XrdThrottle_Config_hh
long long GetLoadshedPort() const
long long GetThrottleDataRate() const
Configuration(XrdSysError &log, XrdOucEnv *env)
long long GetThrottleConcurrency() const
const std::string & GetLoadshedHost() const
const std::string & GetFileSystemLibrary() const
long long GetLoadshedFreq() const
long long GetThrottleIOPSRate() const
long long GetThrottleRecomputeIntervalMS() const
int Configure(const std::string &config_file)