40 auto it = std::find_if(
pools.begin(),
pools.end(),
42 return it ==
pools.end() ? nullptr : *it;
48 const auto it = std::find_if(
pools.begin(),
pools.end(),
50 if (it !=
pools.end()) {
64 int64_t aggregateSpeed, int64_t aggregateSize, uint16_t initialBucketPercent):
67 individualRestore(bucketSpeed),
68 individualMaximum(bucketSize),
69 aggregateRestore(aggregateSpeed),
70 aggregateMaximum(aggregateSize),
71 initialBucketLevel(initialBucketPercent),
101 SBuf name(
"response_delay_pool_access ");
118 static const SBuf bucketSpeedLimit(
"individual-restore");
119 static const SBuf maxBucketSize(
"individual-maximum");
120 static const SBuf aggregateSpeedLimit(
"aggregate-restore");
121 static const SBuf maxAggregateSize(
"aggregate-maximum");
122 static const SBuf initialBucketPercent(
"initial-bucket-level");
124 static std::map<SBuf, int64_t> params;
125 params[bucketSpeedLimit] = -1;
126 params[maxBucketSize] = -1;
127 params[aggregateSpeedLimit] = -1;
128 params[maxAggregateSize] = -1;
129 params[initialBucketPercent] = 50;
133 debugs(3,
DBG_CRITICAL,
"FATAL: response_delay_pool missing required \"name\" parameter.");
139 char *value =
nullptr;
146 auto it = params.find(
SBuf(key));
147 if (it == params.end()) {
152 it->second = (it->first == initialBucketPercent) ?
xatos(value) :
xatoll(value, 10);
155 const char *fatalMsg =
nullptr;
156 if ((params[bucketSpeedLimit] < 0) != (params[maxBucketSize] < 0))
157 fatalMsg =
"'individual-restore' and 'individual-maximum'";
158 else if ((params[aggregateSpeedLimit] < 0) != (params[maxAggregateSize] < 0))
159 fatalMsg =
"'aggregate-restore' and 'aggregate-maximum'";
168 params[bucketSpeedLimit],
169 params[maxBucketSize],
170 params[aggregateSpeedLimit],
171 params[maxAggregateSize],
172 static_cast<uint16_t
>(params[initialBucketPercent])
200 for (
auto pool: pools)
int64_t xatoll(const char *token, int base, char eov)
unsigned short xatos(const char *token)
void aclParseAccessLine(const char *directive, ConfigParser &, acl_access **config)
Parses a single line of a "action followed by acls" directive (e.g., http_access).
static bool NextKvPair(char *&key, char *&value)
static char * NextToken()
void update(DelaySpec const &, int incr)
int const & level() const
Limits Squid-to-client bandwidth for each matching response.
void parseResponseDelayPool()
void dumpResponseDelayPoolParameters(StoreEntry *)
void parseResponseDelayPoolAccess()
~MessageDelayPool() override
int64_t individualRestore
the speed limit of an individual bucket (bytes/s)
time_t lastUpdate
Time the aggregate bucket level was last refilled.
bool noLimit() const
whether the aggregate bucket has no limit
DelayBucket theBucket
the aggregate bucket
void refillBucket()
Increases the aggregate bucket level with the aggregateRestore speed.
SBuf poolName
the response delay pool name
MessageBucketPointer createBucket()
creates an individual response bucket
uint16_t initialBucketLevel
the initial bucket size as a percentage of individualMaximum
int64_t individualMaximum
the maximum size of an individual bucket
MessageDelayPool(const SBuf &name, int64_t bucketSpeed, int64_t bucketSize, int64_t aggregateSpeed, int64_t aggregateSize, uint16_t initialBucketPercent)
int64_t aggregateMaximum
the maximum size of the aggregate bucket
void dump(StoreEntry *entry) const
int64_t aggregateRestore
the speed limit of the aggregate bucket (bytes/s)
void add(MessageDelayPool *pool)
appends a single MessageDelayPool, created during configuration
static MessageDelayPools * Instance()
std::vector< MessageDelayPool::Pointer > pools
MessageDelayPool::Pointer pool(const SBuf &name)
returns a MessageDelayPool with a given name or null otherwise
void freePools()
memory cleanup, performing during reconfiguration
SBuf & append(const SBuf &S)
#define debugs(SECTION, LEVEL, CONTENT)
void aclDestroyAccessList(acl_access **list)
void dump_acl_access(StoreEntry *entry, const char *name, acl_access *head)
void storeAppendPrintf(StoreEntry *e, const char *fmt,...)