MessageDelayPools.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_SRC_MESSAGEDELAYPOOLS_H
10 #define SQUID_SRC_MESSAGEDELAYPOOLS_H
11 
12 #if USE_DELAY_POOLS
13 
14 #include "acl/Acl.h"
15 #include "base/RefCount.h"
16 #include "DelayBucket.h"
17 #include "DelayPools.h"
18 #include "sbuf/SBuf.h"
19 
22 
27 {
28 public:
30 
31  MessageDelayPool(const SBuf &name, int64_t bucketSpeed, int64_t bucketSize,
32  int64_t aggregateSpeed, int64_t aggregateSize, uint16_t initialBucketPercent);
33  ~MessageDelayPool() override;
34  MessageDelayPool(const MessageDelayPool &) = delete;
35  MessageDelayPool &operator=(const MessageDelayPool &) = delete;
36 
38  void refillBucket();
40  void bytesIn(int qty) { if (!noLimit()) theBucket.bytesIn(qty); }
42  int level() { return theBucket.level(); }
46  bool noLimit () const { return aggregateRestore < 0; }
47 
48  void dump (StoreEntry * entry) const;
49 
65 
66 private:
68  time_t lastUpdate;
69 };
70 
74 {
75 public:
76  MessageDelayPools(const MessageDelayPools &) = delete;
78 
79  static MessageDelayPools *Instance();
80 
82  MessageDelayPool::Pointer pool(const SBuf &name);
84  void add(MessageDelayPool *pool);
86  void freePools();
87 
88  std::vector<MessageDelayPool::Pointer> pools;
89 
90 private:
93  void Stats() { } // TODO
94 };
95 
98 {
99 public:
100  void parseResponseDelayPool();
103  void freePools();
104 };
105 
106 #define free_response_delay_pool_access(X)
107 #define dump_response_delay_pool_access(X, Y, Z)
108 
109 inline void
111 {
112  cfg->freePools();
113 }
114 
115 inline void
117 {
119 }
120 
121 inline void
123 {
124  cfg->parseResponseDelayPool();
125 }
126 
127 inline void
129 {
131 }
132 
133 #endif
134 #endif /* SQUID_SRC_MESSAGEDELAYPOOLS_H */
135 
MessageDelayPool::Pointer pool(const SBuf &name)
returns a MessageDelayPool with a given name or null otherwise
MessageDelayPool(const SBuf &name, int64_t bucketSpeed, int64_t bucketSize, int64_t aggregateSpeed, int64_t aggregateSize, uint16_t initialBucketPercent)
void refillBucket()
Increases the aggregate bucket level with the aggregateRestore speed.
DelayBucket theBucket
the aggregate bucket
MessageDelayPools & operator=(const MessageDelayPools &)=delete
time_t lastUpdate
Time the aggregate bucket level was last refilled.
void bytesIn(int qty)
decreases the aggregate level
int64_t aggregateRestore
the speed limit of the aggregate bucket (bytes/s)
Definition: SBuf.h:93
void dumpResponseDelayPoolParameters(StoreEntry *)
void dump_response_delay_pool_parameters(StoreEntry *entry, const char *, MessageDelayConfig &cfg)
std::vector< MessageDelayPool::Pointer > pools
represents configuration for response delay pools
MessageDelayPool & operator=(const MessageDelayPool &)=delete
bool noLimit() const
whether the aggregate bucket has no limit
void free_response_delay_pool_parameters(MessageDelayConfig *cfg)
int64_t aggregateMaximum
the maximum size of the aggregate bucket
int64_t individualMaximum
the maximum size of an individual bucket
void parse_response_delay_pool_access(MessageDelayConfig *cfg)
uint16_t initialBucketLevel
the initial bucket size as a percentage of individualMaximum
MessageBucketPointer createBucket()
creates an individual response bucket
~MessageDelayPool() override
void freePools()
memory cleanup, performing during reconfiguration
acl_access * access
int level()
current aggregate level
void parse_response_delay_pool_parameters(MessageDelayConfig *cfg)
void dump(StoreEntry *entry) const
int const & level() const
Definition: DelayBucket.h:24
static MessageDelayPools * Instance()
RefCount< MessageDelayPool > Pointer
void add(MessageDelayPool *pool)
appends a single MessageDelayPool, created during configuration
int64_t individualRestore
the speed limit of an individual bucket (bytes/s)
RefCount< MessageBucket > MessageBucketPointer
void bytesIn(int qty)
Definition: DelayBucket.cc:41
SBuf poolName
the response delay pool name
Limits Squid-to-client bandwidth for each matching response.
Definition: MessageBucket.h:20

 

Introduction

Documentation

Support

Miscellaneous