Controller.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 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_STORE_CONTROLLER_H
10 #define SQUID_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  virtual ~Controller() override;
27 
28  /* Storage API */
29  virtual void create() override;
30  virtual void init() override;
31  virtual uint64_t maxSize() const override;
32  virtual uint64_t minSize() const override;
33  virtual uint64_t currentSize() const override;
34  virtual uint64_t currentCount() const override;
35  virtual int64_t maxObjectSize() const override;
36  virtual void getStats(StoreInfoStats &stats) const override;
37  virtual void stat(StoreEntry &) const override;
38  virtual void sync() override;
39  virtual void maintain() override;
40  virtual void evictCached(StoreEntry &) override;
41  virtual void evictIfFound(const cache_key *) override;
42  virtual int callback() override;
43  virtual bool smpAware() const override;
44 
48  StoreEntry *find(const cache_key *);
49 
55  StoreEntry *peek(const cache_key *);
56 
62 
65  bool markedForDeletion(const cache_key *key) const;
66 
69  bool markedForDeletionAndAbandoned(const StoreEntry &) const;
70 
72  bool hasReadableDiskEntry(const StoreEntry &) const;
73 
76  int64_t accumulateMore(StoreEntry &) const;
77 
79  void updateLimits();
80 
83 
87  void freeMemorySpace(const int spaceRequired);
88 
90  void memoryOut(StoreEntry &, const bool preserveSwappable);
91 
93  void updateOnNotModified(StoreEntry *old, const StoreEntry &newer);
94 
96  bool allowCollapsing(StoreEntry *, const RequestFlags &, const HttpRequestMethod &);
97 
100  void addReading(StoreEntry *, const cache_key *);
101 
104  void addWriting(StoreEntry *, const cache_key *);
105 
107  bool transientsReader(const StoreEntry &) const;
108 
110  bool transientsWriter(const StoreEntry &) const;
111 
114 
116  void syncCollapsed(const sfileno);
117 
119  void stopSharing(StoreEntry &);
120 
122  int transientReaders(const StoreEntry &) const;
123 
126 
129 
131  StoreSearch *search();
132 
135 
136 private:
137  bool memoryCacheHasSpaceFor(const int pagesRequired) const;
138 
139  void referenceBusy(StoreEntry &e);
140  bool dereferenceIdle(StoreEntry &, bool wantsLocalMemory);
141 
142  void allowSharing(StoreEntry &, const cache_key *);
143  StoreEntry *peekAtLocal(const cache_key *);
144 
147  bool keepForLocalMemoryCache(StoreEntry &e) const;
148  bool anchorToCache(StoreEntry &e, bool &inSync);
149  void checkTransients(const StoreEntry &) const;
150 
153 
158 
161 };
162 
164 extern Controller &Root();
165 
167 extern void Init(Controller *root = nullptr);
168 
170 extern void FreeMemory();
171 
172 } // namespace Store
173 
174 #endif /* SQUID_STORE_CONTROLLER_H */
175 
bool memoryCacheHasSpaceFor(const int pagesRequired) const
whether the memory cache is allowed to store that many additional pages
Definition: Controller.cc:476
Memory * memStore
memory cache
Definition: Controller.h:152
void Init(Controller *root=nullptr)
initialize the storage module; a custom root is used by unit tests only
Definition: Controller.cc:855
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:134
StoreEntry * find(const cache_key *)
Definition: Controller.cc:315
unsigned char cache_key
Store key.
Definition: forward.h:29
virtual void sync() override
prepare for shutdown
Definition: Controller.cc:212
void stopSharing(StoreEntry &)
stop any current (and prevent any future) SMP sharing of the given entry
Definition: Controller.cc:580
void freeMemorySpace(const int spaceRequired)
Definition: Controller.cc:485
class Ping::pingStats_ stats
bool dereferenceIdle(StoreEntry &, bool wantsLocalMemory)
Definition: Controller.cc:263
void referenceBusy(StoreEntry &e)
update reference counters of the recently touched entry
Definition: Controller.cc:238
Controller & Root()
safely access controller singleton
Definition: Controller.cc:848
High-level store statistics used by mgr:info action. Used inside PODs!
Definition: StoreStats.h:13
void updateLimits()
slowly calculate (and cache) hi/lo watermarks and similar limits
Definition: Controller.cc:188
void transientsDisconnect(StoreEntry &)
disassociates the entry from the intransit table
Definition: Controller.cc:608
virtual bool smpAware() const override
Definition: Controller.cc:830
virtual uint64_t maxSize() const override
Definition: Controller.cc:153
int transientReaders(const StoreEntry &) const
number of the transient entry readers some time ago
Definition: Controller.cc:601
Disks * swapDir
summary view of all disk caches
Definition: Controller.h:151
virtual void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: Controller.cc:89
virtual ~Controller() override
Definition: Controller.cc:44
void handleIdleEntry(StoreEntry &)
called when the entry is no longer needed by any transaction
Definition: Controller.cc:615
StoreEntry * findCallback(const cache_key *)
Definition: Controller.cc:352
void checkTransients(const StoreEntry &) const
Definition: Controller.cc:836
void memoryEvictCached(StoreEntry &)
Definition: Controller.cc:561
summary view of all disk caches (cache_dirs) combined
Definition: Disks.h:18
Transients * transients
Definition: Controller.h:157
virtual void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: Controller.cc:111
int64_t accumulateMore(StoreEntry &) const
Definition: Controller.cc:435
signed_int32_t sfileno
Definition: forward.h:22
void addReading(StoreEntry *, const cache_key *)
Definition: Controller.cc:695
void allowSharing(StoreEntry &, const cache_key *)
indexes and adds SMP-tracking for an ephemeral peek() result
Definition: Controller.cc:336
bool transientsWriter(const StoreEntry &) const
whether the entry is in "writing to Transients" I/O state
Definition: Controller.cc:429
bool markedForDeletionAndAbandoned(const StoreEntry &) const
Definition: Controller.cc:300
virtual int callback() override
called once every main loop iteration; TODO: Move to UFS code.
Definition: Controller.cc:223
void memoryDisconnect(StoreEntry &)
disassociates the entry from the memory cache, preserving cached data
Definition: Controller.cc:572
void transientsCompleteWriting(StoreEntry &)
marks the entry completed for collapsed requests
Definition: Controller.cc:590
bool markedForDeletion(const cache_key *key) const
Definition: Controller.cc:293
virtual void create() override
create system resources needed for this store to operate in the future
Definition: Controller.cc:75
void addWriting(StoreEntry *, const cache_key *)
Definition: Controller.cc:703
void FreeMemory()
undo Init()
Definition: Controller.cc:861
int memoryPagesDebt_
Hack: Relays page shortage from freeMemorySpace() to handleIdleEntry().
Definition: Controller.h:160
virtual void evictCached(StoreEntry &) override
Definition: Controller.cc:445
virtual void evictIfFound(const cache_key *) override
Definition: Controller.cc:456
bool hasReadableDiskEntry(const StoreEntry &) const
whether there is a disk entry with e.key
Definition: Controller.cc:309
virtual uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: Controller.cc:160
StoreEntry * peekAtLocal(const cache_key *)
Definition: Controller.cc:366
virtual void init() override
Definition: Controller.cc:58
void memoryOut(StoreEntry &, const bool preserveSwappable)
called to get rid of no longer needed entry data in RAM, if any
Definition: Controller.cc:544
StoreEntry * peek(const cache_key *)
Definition: Controller.cc:382
virtual uint64_t currentCount() const override
the total number of objects stored right now
Definition: Controller.cc:174
void updateOnNotModified(StoreEntry *old, const StoreEntry &newer)
update old entry metadata and HTTP headers using a newer entry
Definition: Controller.cc:661
bool keepForLocalMemoryCache(StoreEntry &e) const
whether e should be kept in local RAM for possible future caching
Definition: Controller.cc:527
bool transientsReader(const StoreEntry &) const
whether the entry is in "reading from Transients" I/O state
Definition: Controller.cc:423
virtual void stat(StoreEntry &) const override
Definition: Controller.cc:131
virtual uint64_t currentSize() const override
current size
Definition: Controller.cc:167
virtual int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Controller.cc:181
bool allowCollapsing(StoreEntry *, const RequestFlags &, const HttpRequestMethod &)
tries to make the entry available for collapsing future requests
Definition: Controller.cc:682
void syncCollapsed(const sfileno)
Update local intransit entry after changes made by appending worker.
Definition: Controller.cc:715
void transientsUnlinkByKeyIfFound(const cache_key *)
bool anchorToCache(StoreEntry &e, bool &inSync)
Definition: Controller.cc:804

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors