Controller.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_STORE_CONTROLLER_H
10 #define SQUID_SRC_STORE_CONTROLLER_H
11 
12 #include "store/Storage.h"
13 
14 class MemObject;
15 class RequestFlags;
16 class HttpRequestMethod;
17 
18 namespace Store {
19 
22 class Controller: public Storage
23 {
24 public:
25  Controller();
26 
27  /* Storage API */
28  void create() override;
29  void init() override;
30  uint64_t maxSize() const override;
31  uint64_t minSize() const override;
32  uint64_t currentSize() const override;
33  uint64_t currentCount() const override;
34  int64_t maxObjectSize() const override;
35  void getStats(StoreInfoStats &stats) const override;
36  void stat(StoreEntry &) const override;
37  void sync() override;
38  void maintain() override;
39  void evictCached(StoreEntry &) override;
40  void evictIfFound(const cache_key *) override;
41  int callback() override;
42 
46  StoreEntry *find(const cache_key *);
47 
53  StoreEntry *peek(const cache_key *);
54 
60 
63  bool markedForDeletion(const cache_key *key) const;
64 
67  bool markedForDeletionAndAbandoned(const StoreEntry &) const;
68 
70  bool hasReadableDiskEntry(const StoreEntry &) const;
71 
74  int64_t accumulateMore(StoreEntry &) const;
75 
77  void configure();
78 
81 
85  void freeMemorySpace(const int spaceRequired);
86 
88  void memoryOut(StoreEntry &, const bool preserveSwappable);
89 
92  bool updateOnNotModified(StoreEntry *old, StoreEntry &e304);
93 
95  bool allowCollapsing(StoreEntry *, const RequestFlags &, const HttpRequestMethod &);
96 
99  void addReading(StoreEntry *, const cache_key *);
100 
103  void addWriting(StoreEntry *, const cache_key *);
104 
106  bool transientsReader(const StoreEntry &) const;
107 
109  bool transientsWriter(const StoreEntry &) const;
110 
112  void syncCollapsed(const sfileno);
113 
116 
118  int transientReaders(const StoreEntry &) const;
119 
122 
125 
127  StoreSearch *search();
128 
130  static bool SmpAware();
131 
134 
135 private:
136  ~Controller() override;
137 
138  bool memoryCacheHasSpaceFor(const int pagesRequired) const;
139 
140  void referenceBusy(StoreEntry &e);
141  bool dereferenceIdle(StoreEntry &, bool wantsLocalMemory);
142 
143  void allowSharing(StoreEntry &, const cache_key *);
144  StoreEntry *peekAtLocal(const cache_key *);
145 
148  bool keepForLocalMemoryCache(StoreEntry &e) const;
149  bool anchorToCache(StoreEntry &);
150  void checkTransients(const StoreEntry &) const;
151  void checkFoundCandidate(const StoreEntry &) const;
152 
156 
161 
164 };
165 
167 extern Controller &Root();
168 
169 } // namespace Store
170 
171 #endif /* SQUID_SRC_STORE_CONTROLLER_H */
172 
int transientReaders(const StoreEntry &) const
number of the transient entry readers some time ago
Definition: Controller.cc:624
Disks * disks
summary view of all disk caches (including none); never nil
Definition: Controller.h:153
void memoryDisconnect(StoreEntry &)
disassociates the entry from the memory cache, preserving cached data
Definition: Controller.cc:609
void noteStoppedSharedWriting(StoreEntry &)
adjust shared state after this worker stopped changing the entry
Definition: Controller.cc:617
uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: Controller.cc:160
bool anchorToCache(StoreEntry &)
Definition: Controller.cc:864
bool localMemStore
whether local (non-shared) memory cache is enabled
Definition: Controller.h:155
void memoryOut(StoreEntry &, const bool preserveSwappable)
called to get rid of no longer needed entry data in RAM, if any
Definition: Controller.cc:581
int memoryPagesDebt_
Hack: Relays page shortage from freeMemorySpace() to handleIdleEntry().
Definition: Controller.h:163
void create() override
create system resources needed for this store to operate in the future
Definition: Controller.cc:73
unsigned char cache_key
Store key.
Definition: forward.h:29
bool hasReadableDiskEntry(const StoreEntry &) const
whether there is a disk entry with e.key
Definition: Controller.cc:315
void sync() override
prepare for shutdown
Definition: Controller.cc:212
StoreEntry * peekAtLocal(const cache_key *)
Definition: Controller.cc:405
static bool SmpAware()
whether there are any SMP-aware storages
Definition: Controller.cc:912
void addReading(StoreEntry *, const cache_key *)
Definition: Controller.cc:745
void checkTransients(const StoreEntry &) const
Definition: Controller.cc:918
void init() override
Definition: Controller.cc:53
void configure()
update configuration, including limits (re)calculation
Definition: Controller.cc:188
void referenceBusy(StoreEntry &e)
update reference counters of the recently touched entry
Definition: Controller.cc:231
bool transientsReader(const StoreEntry &) const
whether the entry is in "reading from Transients" I/O state
Definition: Controller.cc:460
int callback() override
called once every main loop iteration; TODO: Move to UFS code.
Definition: Controller.cc:223
bool memoryCacheHasSpaceFor(const int pagesRequired) const
whether the memory cache is allowed to store that many additional pages
Definition: Controller.cc:513
Transients * transients
Definition: Controller.h:160
void memoryEvictCached(StoreEntry &)
Definition: Controller.cc:598
void evictCached(StoreEntry &) override
Definition: Controller.cc:482
bool allowCollapsing(StoreEntry *, const RequestFlags &, const HttpRequestMethod &)
tries to make the entry available for collapsing future requests
Definition: Controller.cc:727
int64_t accumulateMore(StoreEntry &) const
Definition: Controller.cc:472
void addWriting(StoreEntry *, const cache_key *)
Definition: Controller.cc:753
void transientsDisconnect(StoreEntry &)
disassociates the entry from the intransit table
Definition: Controller.cc:631
StoreEntry * find(const cache_key *)
Definition: Controller.cc:343
void evictIfFound(const cache_key *) override
Definition: Controller.cc:492
summary view of all disk caches (cache_dirs) combined
Definition: Disks.h:18
bool markedForDeletion(const cache_key *key) const
Definition: Controller.cc:299
void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: Controller.cc:106
void stat(StoreEntry &) const override
Definition: Controller.cc:132
void syncCollapsed(const sfileno)
Update local intransit entry after changes made by appending worker.
Definition: Controller.cc:765
StoreSearch * search()
Definition: Controller.cc:205
static int store_dirs_rebuilding
the number of cache_dirs being rebuilt; TODO: move to Disks::Rebuilding
Definition: Controller.h:133
signed_int32_t sfileno
Definition: forward.h:22
uint64_t currentSize() const override
current size
Definition: Controller.cc:167
bool updateOnNotModified(StoreEntry *old, StoreEntry &e304)
Definition: Controller.cc:687
uint64_t maxSize() const override
Definition: Controller.cc:153
void transientsUnlinkByKeyIfFound(const cache_key *)
bool keepForLocalMemoryCache(StoreEntry &e) const
whether e should be kept in local RAM for possible future caching
Definition: Controller.cc:564
int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Controller.cc:181
StoreEntry * findCallbackXXX(const cache_key *)
Definition: Controller.cc:389
void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: Controller.cc:87
void handleIdleEntry(StoreEntry &)
called when the entry is no longer needed by any transaction
Definition: Controller.cc:638
StoreEntry * peek(const cache_key *)
Definition: Controller.cc:421
void allowSharing(StoreEntry &, const cache_key *)
indexes and adds SMP-tracking for an ephemeral peek() result
Definition: Controller.cc:364
bool transientsWriter(const StoreEntry &) const
whether the entry is in "writing to Transients" I/O state
Definition: Controller.cc:466
Memory * sharedMemStore
memory cache that multiple workers can use
Definition: Controller.h:154
void freeMemorySpace(const int spaceRequired)
Definition: Controller.cc:522
uint64_t currentCount() const override
the total number of objects stored right now
Definition: Controller.cc:174
void checkFoundCandidate(const StoreEntry &) const
flags problematic entries before find() commits to finalizing/returning them
Definition: Controller.cc:322
bool markedForDeletionAndAbandoned(const StoreEntry &) const
Definition: Controller.cc:306
High-level store statistics used by mgr:info action. Used inside PODs!
Definition: StoreStats.h:13
bool dereferenceIdle(StoreEntry &, bool wantsLocalMemory)
Definition: Controller.cc:256
~Controller() override
this destructor is never called because Controller singleton is immortal
Definition: Controller.cc:46
Controller & Root()
safely access controller singleton
Definition: Controller.cc:926

 

Introduction

Documentation

Support

Miscellaneous