#include <Controller.h>
![Inheritance graph](classStore_1_1Controller__inherit__graph.png)
![Collaboration graph](classStore_1_1Controller__coll__graph.png)
Public Member Functions | |
Controller () | |
void | create () override |
create system resources needed for this store to operate in the future More... | |
void | init () override |
uint64_t | maxSize () const override |
uint64_t | minSize () const override |
the minimum size the store will shrink to via normal housekeeping More... | |
uint64_t | currentSize () const override |
current size More... | |
uint64_t | currentCount () const override |
the total number of objects stored right now More... | |
int64_t | maxObjectSize () const override |
the maximum size of a storable object; -1 if unlimited More... | |
void | getStats (StoreInfoStats &stats) const override |
collect statistics More... | |
void | stat (StoreEntry &) const override |
void | sync () override |
prepare for shutdown More... | |
void | maintain () override |
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain More... | |
void | evictCached (StoreEntry &) override |
void | evictIfFound (const cache_key *) override |
int | callback () override |
called once every main loop iteration; TODO: Move to UFS code. More... | |
StoreEntry * | find (const cache_key *) |
StoreEntry * | peek (const cache_key *) |
StoreEntry * | findCallbackXXX (const cache_key *) |
bool | markedForDeletion (const cache_key *key) const |
bool | markedForDeletionAndAbandoned (const StoreEntry &) const |
bool | hasReadableDiskEntry (const StoreEntry &) const |
whether there is a disk entry with e.key More... | |
int64_t | accumulateMore (StoreEntry &) const |
void | configure () |
update configuration, including limits (re)calculation More... | |
void | handleIdleEntry (StoreEntry &) |
called when the entry is no longer needed by any transaction More... | |
void | freeMemorySpace (const int spaceRequired) |
void | memoryOut (StoreEntry &, const bool preserveSwappable) |
called to get rid of no longer needed entry data in RAM, if any More... | |
bool | updateOnNotModified (StoreEntry *old, StoreEntry &e304) |
bool | allowCollapsing (StoreEntry *, const RequestFlags &, const HttpRequestMethod &) |
tries to make the entry available for collapsing future requests More... | |
void | addReading (StoreEntry *, const cache_key *) |
void | addWriting (StoreEntry *, const cache_key *) |
bool | transientsReader (const StoreEntry &) const |
whether the entry is in "reading from Transients" I/O state More... | |
bool | transientsWriter (const StoreEntry &) const |
whether the entry is in "writing to Transients" I/O state More... | |
void | syncCollapsed (const sfileno) |
Update local intransit entry after changes made by appending worker. More... | |
void | noteStoppedSharedWriting (StoreEntry &) |
adjust shared state after this worker stopped changing the entry More... | |
int | transientReaders (const StoreEntry &) const |
number of the transient entry readers some time ago More... | |
void | transientsDisconnect (StoreEntry &) |
disassociates the entry from the intransit table More... | |
void | memoryDisconnect (StoreEntry &) |
disassociates the entry from the memory cache, preserving cached data More... | |
StoreSearch * | search () |
Static Public Member Functions | |
static bool | SmpAware () |
whether there are any SMP-aware storages More... | |
Static Public Attributes | |
static int | store_dirs_rebuilding = 1 |
the number of cache_dirs being rebuilt; TODO: move to Disks::Rebuilding More... | |
Private Member Functions | |
~Controller () override | |
this destructor is never called because Controller singleton is immortal More... | |
bool | memoryCacheHasSpaceFor (const int pagesRequired) const |
whether the memory cache is allowed to store that many additional pages More... | |
void | referenceBusy (StoreEntry &e) |
update reference counters of the recently touched entry More... | |
bool | dereferenceIdle (StoreEntry &, bool wantsLocalMemory) |
void | allowSharing (StoreEntry &, const cache_key *) |
indexes and adds SMP-tracking for an ephemeral peek() result More... | |
StoreEntry * | peekAtLocal (const cache_key *) |
void | memoryEvictCached (StoreEntry &) |
void | transientsUnlinkByKeyIfFound (const cache_key *) |
bool | keepForLocalMemoryCache (StoreEntry &e) const |
whether e should be kept in local RAM for possible future caching More... | |
bool | anchorToCache (StoreEntry &) |
void | checkTransients (const StoreEntry &) const |
void | checkFoundCandidate (const StoreEntry &) const |
flags problematic entries before find() commits to finalizing/returning them More... | |
Private Attributes | |
Disks * | disks |
summary view of all disk caches (including none); never nil More... | |
Memory * | sharedMemStore |
memory cache that multiple workers can use More... | |
bool | localMemStore |
whether local (non-shared) memory cache is enabled More... | |
Transients * | transients |
int | memoryPagesDebt_ = 0 |
Hack: Relays page shortage from freeMemorySpace() to handleIdleEntry(). More... | |
Detailed Description
Public Store interface. Coordinates the work of memory/disk/transient stores and hides their individual existence/differences from the callers.
Definition at line 22 of file Controller.h.
Constructor & Destructor Documentation
◆ Controller()
Store::Controller::Controller | ( | ) |
Definition at line 36 of file Controller.cc.
References assert, and store_table.
◆ ~Controller()
|
overrideprivate |
Definition at line 46 of file Controller.cc.
References assert.
Member Function Documentation
◆ accumulateMore()
int64_t Store::Controller::accumulateMore | ( | StoreEntry & | entry | ) | const |
Additional unknown-size entry bytes required by Store in order to reduce the risk of selecting the wrong disk cache for the growing entry.
Definition at line 472 of file Controller.cc.
Referenced by StoreEntry::mayStartSwapOut().
◆ addReading()
void Store::Controller::addReading | ( | StoreEntry * | e, |
const cache_key * | key | ||
) |
register a being-read StoreEntry (to optimize concurrent cache reads and to receive remote DELETE events)
Definition at line 745 of file Controller.cc.
References StoreEntry::hashInsert(), and Store::ioReading.
◆ addWriting()
void Store::Controller::addWriting | ( | StoreEntry * | e, |
const cache_key * | key | ||
) |
register a being-written StoreEntry (to support concurrent cache reads and to receive remote DELETE events)
Definition at line 753 of file Controller.cc.
References assert, EBIT_TEST, ENTRY_SPECIAL, StoreEntry::flags, and Store::ioWriting.
Referenced by StoreEntry::setPublicKey().
◆ allowCollapsing()
bool Store::Controller::allowCollapsing | ( | StoreEntry * | e, |
const RequestFlags & | reqFlags, | ||
const HttpRequestMethod & | |||
) |
Definition at line 727 of file Controller.cc.
References assert, debugs, StoreEntry::hasTransients(), StoreEntry::hittingRequiresCollapsing(), ksDefault, ksRevalidation, StoreEntry::makePublic(), RequestFlags::refresh, and StoreEntry::setCollapsingRequirement().
Referenced by clientReplyContext::createStoreEntry().
◆ allowSharing()
|
private |
Definition at line 364 of file Controller.cc.
References DBG_IMPORTANT, debugs, StoreEntry::hasTransients(), Here, and StoreEntry::hittingRequiresCollapsing().
◆ anchorToCache()
|
private |
If possible and has not been done, associates the entry with its store(s).
- Returns
- false for not-yet-cached entries that we may attach later
- true for other entries after synchronizing them with their store
Definition at line 864 of file Controller.cc.
References assert, debugs, StoreEntry::hasDisk(), StoreEntry::hasMemStore(), StoreEntry::hasTransients(), Transients::EntryStatus::hasWriter, Here, MemObject::MemCache::io, Store::ioDone, StoreEntry::mem(), MemObject::memCache, StoreEntry::setCollapsingRequirement(), and Transients::EntryStatus::waitingToBeFreed.
◆ callback()
|
overridevirtual |
Reimplemented from Store::Storage.
Definition at line 223 of file Controller.cc.
Referenced by StoreRootEngine::checkEvents(), and DiskdIOStrategy::SEND().
◆ checkFoundCandidate()
|
private |
Definition at line 322 of file Controller.cc.
References StoreEntry::hasTransients(), Here, StoreEntry::hittingRequiresCollapsing(), StoreEntry::isAccepting(), and StoreEntry::locked().
◆ checkTransients()
|
private |
Definition at line 918 of file Controller.cc.
References assert, EBIT_TEST, ENTRY_SPECIAL, StoreEntry::flags, and StoreEntry::hasTransients().
◆ configure()
void Store::Controller::configure | ( | ) |
Definition at line 188 of file Controller.cc.
References Config, SquidConfig::highWaterMark, SquidConfig::lowWaterMark, max(), SquidConfig::maxInMemObjSize, SquidConfig::memMaxSize, min(), SquidConfig::Store, store_maxobjsize, store_pages_max, store_swap_high, store_swap_low, and SquidConfig::Swap.
Referenced by storeConfigure().
◆ create()
|
overridevirtual |
Implements Store::Storage.
Definition at line 73 of file Controller.cc.
References pid, and WaitForAnyPid().
Referenced by SquidMain().
◆ currentCount()
|
overridevirtual |
Implements Store::Storage.
Definition at line 174 of file Controller.cc.
◆ currentSize()
|
overridevirtual |
Implements Store::Storage.
Definition at line 167 of file Controller.cc.
Referenced by snmp_prfProtoFn(), snmp_sysFn(), and storeDigestCalcCap().
◆ dereferenceIdle()
|
private |
dereference()s an idle entry
- Returns
- false if and only if the entry should be deleted
Definition at line 256 of file Controller.cc.
References RemovalPolicy::Dereferenced, EBIT_TEST, ENTRY_SPECIAL, StoreEntry::flags, StoreEntry::hasDisk(), StoreEntry::hittingRequiresCollapsing(), IN_MEMORY, KEY_PRIVATE, StoreEntry::mem_obj, mem_policy, StoreEntry::mem_status, and MemObject::repl.
◆ evictCached()
|
overridevirtual |
Prevent new get() calls from returning the matching entry. If the matching entry is unused, it may be removed from the store now. The store entry is matched using either e
attachment info or e.key
.
Implements Store::Storage.
Definition at line 482 of file Controller.cc.
References debugs.
Referenced by StoreEntry::release(), and StoreEntry::setPrivateKey().
◆ evictIfFound()
|
overridevirtual |
An evictCached() equivalent for callers that did not get() a StoreEntry. Callers with StoreEntry objects must use evictCached() instead.
Implements Store::Storage.
Definition at line 492 of file Controller.cc.
References debugs, and storeKeyText().
Referenced by purgeEntriesByUrl().
◆ find()
StoreEntry * Store::Controller::find | ( | const cache_key * | key | ) |
- Returns
- a locally indexed and SMP-tracked matching StoreEntry (or nil) Slower than peek() but does not restrict StoreEntry use and storage. Counts as an entry reference from the removal policy p.o.v.
Definition at line 343 of file Controller.cc.
References debugs.
Referenced by storeGetPublic(), and storeGetPublicByRequestMethod().
◆ findCallbackXXX()
StoreEntry * Store::Controller::findCallbackXXX | ( | const cache_key * | key | ) |
- Returns
- matching StoreEntry associated with local ICP/HTCP transaction Warning: The returned StoreEntry is not synced and may be marked for deletion. It can only be used for extracting transaction callback details. New code should be designed to avoid this deprecated API.
Definition at line 389 of file Controller.cc.
References hash_lookup(), and store_table.
Referenced by neighborsHtcpReply().
◆ freeMemorySpace()
void Store::Controller::freeMemorySpace | ( | const int | spaceRequired | ) |
Evict memory cache entries to free at least spaceRequired
bytes. Should be called via storeGetMemSpace(). Unreliable: Fails if enough victims cannot be found fast enough.
Definition at line 522 of file Controller.cc.
References debugs, hot_obj_count, mem_policy, RemovalPolicy::PurgeInit, SM_PAGE_SIZE, and squid_curtime.
Referenced by storeGetMemSpace().
◆ getStats()
|
overridevirtual |
Implements Store::Storage.
Definition at line 106 of file Controller.cc.
References StoreInfoStats::Part::capacity, Config, StoreInfoStats::Part::count, hot_obj_count, MemObject::inUseCount(), StoreEntry::inUseCount(), StoreInfoStats::mem, StoreInfoStats::mem_object_count, SquidConfig::memMaxSize, StoreInfoStats::Mem::shared, StoreInfoStats::Part::size, StoreInfoStats::store_entry_count, and mem_node::StoreMemSize().
Referenced by GetInfo().
◆ handleIdleEntry()
void Store::Controller::handleIdleEntry | ( | StoreEntry & | e | ) |
Definition at line 638 of file Controller.cc.
References assert, debugs, destroyStoreEntry, EBIT_TEST, ENTRY_SPECIAL, StoreEntry::flags, IN_MEMORY, KEY_PRIVATE, StoreEntry::mem_obj, StoreEntry::release(), StoreEntry::setMemStatus(), StoreEntry::swappedOut(), and MemObject::unlinkRequest().
Referenced by StoreEntry::doAbandon().
◆ hasReadableDiskEntry()
bool Store::Controller::hasReadableDiskEntry | ( | const StoreEntry & | e | ) | const |
Definition at line 315 of file Controller.cc.
◆ init()
|
overridevirtual |
Start preparing the store for use. To check readiness, callers should use readable() and writable() methods.
Implements Store::Storage.
Definition at line 53 of file Controller.cc.
References Config, MemStore::Enabled(), Transients::Enabled(), IamWorkerProcess(), MemStore::init(), Transients::init(), and SquidConfig::memMaxSize.
Referenced by TestRock::storeInit(), storeInit(), TestStoreHashIndex::testSearch(), TestStoreController::testSearch(), and TestUfs::testUfsSearch().
◆ keepForLocalMemoryCache()
|
private |
Definition at line 564 of file Controller.cc.
References assert, Config, MemObject::endOffset(), MemObject::expectedReplySize(), max(), SquidConfig::maxInMemObjSize, StoreEntry::mem_obj, SquidConfig::memMaxSize, StoreEntry::memoryCachable(), min(), and SquidConfig::Store.
◆ maintain()
|
overridevirtual |
Implements Store::Storage.
Definition at line 87 of file Controller.cc.
References DBG_CRITICAL, debugs, Store::Root(), and squid_curtime.
Referenced by Store::Maintain().
◆ markedForDeletion()
bool Store::Controller::markedForDeletion | ( | const cache_key * | key | ) | const |
Whether a transient entry with the given public key exists and (but) was marked for removal some time ago; get(key) returns nil in such cases.
Definition at line 299 of file Controller.cc.
Referenced by Ipc::StoreMapAnchor::setKey().
◆ markedForDeletionAndAbandoned()
bool Store::Controller::markedForDeletionAndAbandoned | ( | const StoreEntry & | e | ) | const |
markedForDeletion() with no readers this is one method because the two conditions must be checked in the right order
Definition at line 306 of file Controller.cc.
References hash_link::key.
◆ maxObjectSize()
|
overridevirtual |
Implements Store::Storage.
Definition at line 181 of file Controller.cc.
Referenced by MemStore::init().
◆ maxSize()
|
overridevirtual |
The maximum size the store will support in normal use. Inaccuracy is permitted, but may throw estimates for memory etc out of whack.
Implements Store::Storage.
Definition at line 153 of file Controller.cc.
Referenced by Store::Disks::init(), snmp_confFn(), and storeDigestCalcCap().
◆ memoryCacheHasSpaceFor()
|
private |
Definition at line 513 of file Controller.cc.
References debugs, mem_node::InUseCount(), and store_pages_max.
◆ memoryDisconnect()
void Store::Controller::memoryDisconnect | ( | StoreEntry & | e | ) |
Definition at line 609 of file Controller.cc.
Referenced by StoreEntry::destroyMemObject().
◆ memoryEvictCached()
|
private |
removes the entry from the memory cache XXX: Dangerous side effect: Unlocked entries lose their mem_obj.
Definition at line 598 of file Controller.cc.
References StoreEntry::destroyMemObject(), and StoreEntry::locked().
◆ memoryOut()
void Store::Controller::memoryOut | ( | StoreEntry & | e, |
const bool | preserveSwappable | ||
) |
Definition at line 581 of file Controller.cc.
References debugs, and StoreEntry::trimMemory().
Referenced by StoreEntry::swapOut().
◆ minSize()
|
overridevirtual |
Implements Store::Storage.
Definition at line 160 of file Controller.cc.
◆ noteStoppedSharedWriting()
void Store::Controller::noteStoppedSharedWriting | ( | StoreEntry & | e | ) |
Definition at line 617 of file Controller.cc.
References StoreEntry::hasTransients().
Referenced by StoreEntry::storeWritingCheckpoint().
◆ peek()
StoreEntry * Store::Controller::peek | ( | const cache_key * | key | ) |
- Returns
- a matching StoreEntry not suitable for long-term use (or nil) Faster than find() but the returned entry may not receive updates, may lack information from some of the Stores, and should not be updated except that purging peek()ed entries is supported. Does not count as an entry reference from the removal policy p.o.v.
Definition at line 421 of file Controller.cc.
References debugs, and storeKeyText().
◆ peekAtLocal()
|
private |
- Returns
- either an existing local reusable StoreEntry object or nil To treat remotely marked entries specially, callers ought to check markedForDeletion() first!
Definition at line 405 of file Controller.cc.
References assert, EBIT_TEST, hash_lookup(), KEY_PRIVATE, and store_table.
◆ referenceBusy()
|
private |
Definition at line 231 of file Controller.cc.
References EBIT_TEST, ENTRY_SPECIAL, StoreEntry::flags, StoreEntry::hasDisk(), IN_MEMORY, StoreEntry::mem_obj, mem_policy, StoreEntry::mem_status, RemovalPolicy::Referenced, and MemObject::repl.
◆ search()
StoreSearch * Store::Controller::search | ( | ) |
- Returns
- an iterator for all Store entries
Definition at line 205 of file Controller.cc.
References Store::NewLocalSearch().
Referenced by statObjectsStart(), storeCleanup(), storeDigestRebuildResume(), TestStoreController::testSearch(), TestStoreHashIndex::testSearch(), and TestUfs::testUfsSearch().
◆ SmpAware()
|
static |
Definition at line 912 of file Controller.cc.
References MemStore::Enabled(), and Store::Disks::SmpAware().
Referenced by Transients::EntryLimit(), and clientReplyContext::processExpired().
◆ stat()
|
overridevirtual |
Output stats to the provided store entry. TODO: make these calls asynchronous
Implements Store::Storage.
Definition at line 132 of file Controller.cc.
References Math::doublePercent(), StoreEntry::inUseCount(), PRIu64, and storeAppendPrintf().
Referenced by Store::Stats().
◆ sync()
|
overridevirtual |
Reimplemented from Store::Storage.
Definition at line 212 of file Controller.cc.
Referenced by SquidShutdown().
◆ syncCollapsed()
void Store::Controller::syncCollapsed | ( | const sfileno | xitIndex | ) |
Definition at line 765 of file Controller.cc.
References StoreEntry::abort(), assert, CurrentException(), debugs, EBIT_TEST, ENTRY_ABORTED, StoreEntry::flags, StoreEntry::hasDisk(), StoreEntry::hasMemStore(), Transients::EntryStatus::hasWriter, StoreEntry::invokeHandlers(), MemObject::MemCache::io, Store::ioDone, StoreEntry::locked(), StoreEntry::mem_obj, MemObject::memCache, StoreEntry::release(), StoreEntry::setCollapsingRequirement(), and Transients::EntryStatus::waitingToBeFreed.
Referenced by CollapsedForwarding::HandleNewData().
◆ transientReaders()
int Store::Controller::transientReaders | ( | const StoreEntry & | e | ) | const |
Definition at line 624 of file Controller.cc.
References StoreEntry::hasTransients().
Referenced by CollapsedForwarding::Broadcast().
◆ transientsDisconnect()
void Store::Controller::transientsDisconnect | ( | StoreEntry & | e | ) |
Definition at line 631 of file Controller.cc.
Referenced by StoreEntry::destroyMemObject().
◆ transientsReader()
bool Store::Controller::transientsReader | ( | const StoreEntry & | e | ) | const |
Definition at line 460 of file Controller.cc.
References StoreEntry::hasTransients().
◆ transientsUnlinkByKeyIfFound()
|
private |
◆ transientsWriter()
bool Store::Controller::transientsWriter | ( | const StoreEntry & | e | ) | const |
Definition at line 466 of file Controller.cc.
References StoreEntry::hasTransients().
◆ updateOnNotModified()
bool Store::Controller::updateOnNotModified | ( | StoreEntry * | old, |
StoreEntry & | e304 | ||
) |
using a 304 response, update the old entry (metadata and reply headers)
- Returns
- whether the old entry can be used (and is considered fresh)
Definition at line 687 of file Controller.cc.
References MemObject::appliedUpdates, CurrentException(), DBG_IMPORTANT, debugs, EBIT_TEST, ENTRY_SPECIAL, StoreEntry::flags, IN_MEMORY, StoreEntry::mem_obj, StoreEntry::mem_status, Must, StoreEntry::swap_dirn, and StoreEntry::updateOnNotModified().
Member Data Documentation
◆ disks
|
private |
Definition at line 153 of file Controller.h.
◆ localMemStore
|
private |
Definition at line 155 of file Controller.h.
◆ memoryPagesDebt_
|
private |
Definition at line 163 of file Controller.h.
◆ sharedMemStore
|
private |
Definition at line 154 of file Controller.h.
◆ store_dirs_rebuilding
|
static |
Definition at line 133 of file Controller.h.
Referenced by Store::Disks::configure(), Fs::Ufs::UFSSwapDir::HandleCleanEvent(), icpGetCommonOpcode(), Store::Disks::init(), Fs::Ufs::UFSSwapDir::maintain(), StoreEntry::release(), storeCleanupComplete(), storeDirWriteCleanLogs(), TestRock::storeInit(), storeLateRelease(), storeRebuildComplete(), Rock::Rebuild::swanSong(), TestUfs::testUfsSearch(), wccp2HereIam(), and Fs::Ufs::UFSSwapDir::writeCleanDone().
◆ transients
|
private |
A shared table of public store entries that do not know whether they will belong to a memory cache, a disk cache, or will be uncachable when the response header comes. Used for SMP collapsed forwarding.
Definition at line 160 of file Controller.h.
The documentation for this class was generated from the following files:
- src/store/Controller.h
- src/store/Controller.cc
- src/tests/stub_libstore.cc
Introduction
- About Squid
- Why Squid?
- Squid Developers
- How to Donate
- How to Help Out
- Getting Squid
- Squid Source Packages
- Squid Deployment Case-Studies
- Squid Software Foundation
Documentation
- Quick Setup
- Configuration:
- FAQ and Wiki
- Guide Books:
- Non-English
- More...
Support
- Security Advisories
- Bugzilla Database
- Mailing lists
- Contacting us
- Commercial services
- Project Sponsors
- Squid-based products