XRootD
Loading...
Searching...
No Matches
XrdThrottleConfig.hh
Go to the documentation of this file.
1/******************************************************************************/
2/* */
3/* (c) 2025 by the Morgridge Institute for Research */
4/* */
5/* This file is part of the XRootD software suite. */
6/* */
7/* XRootD is free software: you can redistribute it and/or modify it under */
8/* the terms of the GNU Lesser General Public License as published by the */
9/* Free Software Foundation, either version 3 of the License, or (at your */
10/* option) any later version. */
11/* */
12/* XRootD is distributed in the hope that it will be useful, but WITHOUT */
13/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
14/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
15/* License for more details. */
16/* */
17/* You should have received a copy of the GNU Lesser General Public License */
18/* along with XRootD in a file called COPYING.LESSER (LGPL license) and file */
19/* COPYING (GPL license). If not, see <http://www.gnu.org/licenses/>. */
20/* */
21/* The copyright holder's institutional names and contributor's names may not */
22/* be used to endorse or promote products derived from this software without */
23/* specific prior written permission of the institution or contributor. */
24/******************************************************************************/
25
26#ifndef XrdThrottle_Config_hh
27#define XrdThrottle_Config_hh
28
29#include <string>
30
31class XrdOucEnv;
32class XrdOucStream;
33class XrdSysError;
34
35namespace XrdThrottle {
36
38public:
40 : m_env(env), m_log(log)
41 {}
42
43 // Generate the XrdThrottle configuration from the given file name.
44 //
45 // Returns 0 on success, or a non-zero error code on failure.
46 int Configure(const std::string &config_file);
47
48 // Get the configuration for the fslib to use.
49 // The default is "libXrdOfs.so".
50 const std::string &GetFileSystemLibrary() const { return m_fslib; }
51
52 // Get the configuration for the loadshed hostname.
53 // If not set, the default is empty.
54 const std::string &GetLoadshedHost() const { return m_loadshed_hostname; }
55
56 // Get the configuration for the loadshed port.
57 // Valid values are 1 to 65535.
58 // If not set, the default is 0.
59 long long GetLoadshedPort() const { return m_loadshed_port; }
60
61 // Get the configuration for the loadshed frequency.
62 // Valid values are 1 to 100.
63 // If not set, the default is 0.
64 long long GetLoadshedFreq() const { return m_loadshed_freq; }
65
66 // Get the configuration for th maximum number of open files.
67 // If -1, no limit is set.
68 long long GetMaxOpen() const { return m_max_open; }
69
70 // Get the configuration for the maximum number of active connections.
71 // If -1, no limit is set.
72 long long GetMaxConn() const { return m_max_conn; }
73
74 // Get the configuration for the maximum wait time before a request is
75 // failed with EMFILE.
76 // If not set, the default is 30 seconds.
77 long long GetMaxWait() const { return m_max_wait; }
78
79 // Get the configuration for the throttle concurrency limit.
80 // If -1, no limit is set.
81 long long GetThrottleConcurrency() const { return m_throttle_concurrency_limit; }
82
83 // Get the configuration for the maximum number of bytes per second.
84 // If -1, no limit is set.
85 long long GetThrottleDataRate() const { return m_throttle_data_rate; }
86
87 // Get the configuration for the maximum number of IOPS per second.
88 // If -1, no limit is set.
89 long long GetThrottleIOPSRate() const { return m_throttle_iops_rate; }
90
91 // Get the configuration for the recompute interval, in milliseconds.
92 // If not set, the default is 1000 ms.
93 long long GetThrottleRecomputeIntervalMS() const { return m_throttle_recompute_interval_ms; }
94
95 // Get the configuration for the trace levels.
96 // If not set, the default is 0.
97 int GetTraceLevels() const { return m_trace_levels; }
98
99 // Get the per-user configuration file path.
100 // If not set, the default is empty.
101 const std::string &GetUserConfigFile() const { return m_user_config_file; }
102
103private:
104 int xloadshed(XrdOucStream &Config);
105 int xmaxopen(XrdOucStream &Config);
106 int xmaxconn(XrdOucStream &Config);
107 int xmaxwait(XrdOucStream &Config);
108 int xthrottle(XrdOucStream &Config);
109 int xtrace(XrdOucStream &Config);
110 int xuserconfig(XrdOucStream &Config);
111
112 XrdOucEnv *m_env{nullptr};
113 std::string m_fslib{"libXrdOfs.so"};
114 XrdSysError &m_log;
115 std::string m_loadshed_hostname;
116 long long m_loadshed_freq{0};
117 long long m_loadshed_port{0};
118 long long m_max_conn{-1};
119 long long m_max_open{-1};
120 long long m_max_wait{30};
121 long long m_throttle_concurrency_limit{-1};
122 long long m_throttle_data_rate{-1};
123 long long m_throttle_iops_rate{-1};
124 long long m_throttle_recompute_interval_ms{1000};
125 int m_trace_levels{0};
126 std::string m_user_config_file;
127};
128
129} // namespace XrdThrottle
130
131#endif // XrdThrottle_Config_hh
long long GetLoadshedPort() const
long long GetThrottleDataRate() const
Configuration(XrdSysError &log, XrdOucEnv *env)
const std::string & GetUserConfigFile() const
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)