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 
47  StoreEntry *find(const cache_key *);
48 
54  StoreEntry *peek(const cache_key *);
55 
61 
64  bool markedForDeletion(const cache_key *key) const;
65 
68  bool markedForDeletionAndAbandoned(const StoreEntry &) const;
69 
71  bool hasReadableDiskEntry(const StoreEntry &) const;
72 
75  int64_t accumulateMore(StoreEntry &) const;
76 
78  void updateLimits();
79 
82 
86  void freeMemorySpace(const int spaceRequired);
87 
89  void memoryOut(StoreEntry &, const bool preserveSwappable);
90 
92  void updateOnNotModified(StoreEntry *old, const StoreEntry &newer);
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 
113 
115  void syncCollapsed(const sfileno);
116 
118  void stopSharing(StoreEntry &);
119 
121  int transientReaders(const StoreEntry &) const;
122 
125 
128 
131 
133  StoreSearch *search();
134 
136  static bool SmpAware();
137 
140 
141 private:
142  bool memoryCacheHasSpaceFor(const int pagesRequired) const;
143 
144  void referenceBusy(StoreEntry &e);
145  bool dereferenceIdle(StoreEntry &, bool wantsLocalMemory);
146 
147  void allowSharing(StoreEntry &, const cache_key *);
148  StoreEntry *peekAtLocal(const cache_key *);
149 
152  bool keepForLocalMemoryCache(StoreEntry &e) const;
153  bool anchorToCache(StoreEntry &e, bool &inSync);
154  void checkTransients(const StoreEntry &) const;
155 
159 
164 
167 };
168 
170 extern Controller &Root();
171 
173 extern void Init(Controller *root = nullptr);
174 
176 extern void FreeMemory();
177 
178 } // namespace Store
179 
180 #endif /* SQUID_STORE_CONTROLLER_H */
181 
bool memoryCacheHasSpaceFor(const int pagesRequired) const
whether the memory cache is allowed to store that many additional pages
Definition: Controller.cc:488
void Init(Controller *root=nullptr)
initialize the storage module; a custom root is used by unit tests only
Definition: Controller.cc:884
StoreSearch * search()
Definition: Controller.cc:215
static int store_dirs_rebuilding
the number of cache_dirs being rebuilt; TODO: move to Disks::Rebuilding
Definition: Controller.h:139
StoreEntry * find(const cache_key *)
Definition: Controller.cc:325
unsigned char cache_key
Store key.
Definition: forward.h:29
virtual void sync() override
prepare for shutdown
Definition: Controller.cc:222
void stopSharing(StoreEntry &)
stop any current (and prevent any future) SMP sharing of the given entry
Definition: Controller.cc:592
void freeMemorySpace(const int spaceRequired)
Definition: Controller.cc:497
class Ping::pingStats_ stats
bool dereferenceIdle(StoreEntry &, bool wantsLocalMemory)
Definition: Controller.cc:273
void referenceBusy(StoreEntry &e)
update reference counters of the recently touched entry
Definition: Controller.cc:248
Controller & Root()
safely access controller singleton
Definition: Controller.cc:877
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:198
void transientsDisconnect(StoreEntry &)
disassociates the entry from the intransit table
Definition: Controller.cc:620
virtual uint64_t maxSize() const override
Definition: Controller.cc:163
int transientReaders(const StoreEntry &) const
number of the transient entry readers some time ago
Definition: Controller.cc:613
Disks * swapDir
summary view of all disk caches
Definition: Controller.h:156
virtual void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: Controller.cc:93
virtual ~Controller() override
Definition: Controller.cc:45
void handleIdleEntry(StoreEntry &)
called when the entry is no longer needed by any transaction
Definition: Controller.cc:634
void checkTransients(const StoreEntry &) const
Definition: Controller.cc:865
void memoryEvictCached(StoreEntry &)
Definition: Controller.cc:573
summary view of all disk caches (cache_dirs) combined
Definition: Disks.h:18
Transients * transients
Definition: Controller.h:163
static bool SmpAware()
whether there are any SMP-aware storages
Definition: Controller.cc:859
Memory * sharedMemStore
memory cache that multiple workers can use
Definition: Controller.h:157
virtual void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: Controller.cc:115
int64_t accumulateMore(StoreEntry &) const
Definition: Controller.cc:447
signed_int32_t sfileno
Definition: forward.h:22
void addReading(StoreEntry *, const cache_key *)
Definition: Controller.cc:714
void allowSharing(StoreEntry &, const cache_key *)
indexes and adds SMP-tracking for an ephemeral peek() result
Definition: Controller.cc:346
bool transientsWriter(const StoreEntry &) const
whether the entry is in "writing to Transients" I/O state
Definition: Controller.cc:441
bool markedForDeletionAndAbandoned(const StoreEntry &) const
Definition: Controller.cc:310
virtual int callback() override
called once every main loop iteration; TODO: Move to UFS code.
Definition: Controller.cc:233
bool localMemStore
whether local (non-shared) memory cache is enabled
Definition: Controller.h:158
void memoryDisconnect(StoreEntry &)
disassociates the entry from the memory cache, preserving cached data
Definition: Controller.cc:584
void transientsCompleteWriting(StoreEntry &)
marks the entry completed for collapsed requests
Definition: Controller.cc:602
StoreEntry * findCallbackXXX(const cache_key *)
Definition: Controller.cc:362
bool markedForDeletion(const cache_key *key) const
Definition: Controller.cc:303
virtual void create() override
create system resources needed for this store to operate in the future
Definition: Controller.cc:79
void addWriting(StoreEntry *, const cache_key *)
Definition: Controller.cc:722
void FreeMemory()
undo Init()
Definition: Controller.cc:890
int memoryPagesDebt_
Hack: Relays page shortage from freeMemorySpace() to handleIdleEntry().
Definition: Controller.h:166
virtual void evictCached(StoreEntry &) override
Definition: Controller.cc:457
virtual void evictIfFound(const cache_key *) override
Definition: Controller.cc:468
bool hasReadableDiskEntry(const StoreEntry &) const
whether there is a disk entry with e.key
Definition: Controller.cc:319
virtual uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: Controller.cc:170
StoreEntry * peekAtLocal(const cache_key *)
Definition: Controller.cc:378
virtual void init() override
Definition: Controller.cc:59
void memoryOut(StoreEntry &, const bool preserveSwappable)
called to get rid of no longer needed entry data in RAM, if any
Definition: Controller.cc:556
StoreEntry * peek(const cache_key *)
Definition: Controller.cc:394
virtual uint64_t currentCount() const override
the total number of objects stored right now
Definition: Controller.cc:184
void updateOnNotModified(StoreEntry *old, const StoreEntry &newer)
update old entry metadata and HTTP headers using a newer entry
Definition: Controller.cc:680
bool keepForLocalMemoryCache(StoreEntry &e) const
whether e should be kept in local RAM for possible future caching
Definition: Controller.cc:539
bool transientsReader(const StoreEntry &) const
whether the entry is in "reading from Transients" I/O state
Definition: Controller.cc:435
void transientsClearCollapsingRequirement(StoreEntry &e)
removes collapsing requirement (for future hits)
Definition: Controller.cc:627
virtual void stat(StoreEntry &) const override
Definition: Controller.cc:141
virtual uint64_t currentSize() const override
current size
Definition: Controller.cc:177
virtual int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Controller.cc:191
bool allowCollapsing(StoreEntry *, const RequestFlags &, const HttpRequestMethod &)
tries to make the entry available for collapsing future requests
Definition: Controller.cc:697
void syncCollapsed(const sfileno)
Update local intransit entry after changes made by appending worker.
Definition: Controller.cc:734
void transientsUnlinkByKeyIfFound(const cache_key *)
bool anchorToCache(StoreEntry &e, bool &inSync)
Definition: Controller.cc:833

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors