allows testing of methods without having all the other components live More...

#include <testStore.h>

Inheritance diagram for StoreControllerStub:
Collaboration diagram for StoreControllerStub:

Public Member Functions

 StoreControllerStub ()
 
int callback () override
 called once every main loop iteration; TODO: Move to UFS code. More...
 
virtual StoreEntryget (const cache_key *)
 
virtual void get (String, void(*)(StoreEntry *, void *), void *)
 
void init () override
 
void maintain () override
 perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain More...
 
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 &) const override
 collect statistics More...
 
void stat (StoreEntry &) const override
 
virtual void reference (StoreEntry &)
 
virtual bool dereference (StoreEntry &)
 
virtual StoreSearchsearch ()
 
void create () override
 create system resources needed for this store to operate in the future More...
 
void sync () override
 prepare for shutdown More...
 
void evictCached (StoreEntry &) override
 
void evictIfFound (const cache_key *) override
 
StoreEntryfind (const cache_key *)
 
StoreEntrypeek (const cache_key *)
 
StoreEntryfindCallbackXXX (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...
 

Static Public Member Functions

static bool SmpAware ()
 whether there are any SMP-aware storages More...
 

Public Attributes

bool statsCalled
 

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

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...
 
StoreEntrypeekAtLocal (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 * swapDir
 summary view of all disk caches More...
 
Memory * sharedMemStore
 memory cache that multiple workers can use More...
 
bool localMemStore
 whether local (non-shared) memory cache is enabled More...
 
Transientstransients
 
int memoryPagesDebt_ = 0
 Hack: Relays page shortage from freeMemorySpace() to handleIdleEntry(). More...
 

Detailed Description

Definition at line 42 of file testStore.h.

Constructor & Destructor Documentation

◆ StoreControllerStub()

StoreControllerStub::StoreControllerStub ( )
inline

Definition at line 46 of file testStore.h.

Member Function Documentation

◆ accumulateMore()

int64_t Store::Controller::accumulateMore ( StoreEntry entry) const
inherited

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 480 of file Controller.cc.

Referenced by StoreEntry::mayStartSwapOut().

◆ addReading()

void Store::Controller::addReading ( StoreEntry e,
const cache_key key 
)
inherited

register a being-read StoreEntry (to optimize concurrent cache reads and to receive remote DELETE events)

Definition at line 753 of file Controller.cc.

References StoreEntry::hashInsert(), and Store::ioReading.

◆ addWriting()

void Store::Controller::addWriting ( StoreEntry e,
const cache_key key 
)
inherited

register a being-written StoreEntry (to support concurrent cache reads and to receive remote DELETE events)

Definition at line 761 of file Controller.cc.

References assert, EBIT_TEST, ENTRY_SPECIAL, StoreEntry::flags, and Store::ioWriting.

Referenced by StoreEntry::setPublicKey().

◆ allowCollapsing()

◆ allowSharing()

void Store::Controller::allowSharing ( StoreEntry entry,
const cache_key key 
)
privateinherited

◆ anchorToCache()

bool Store::Controller::anchorToCache ( StoreEntry entry)
privateinherited

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 872 of file Controller.cc.

References assert, debugs, StoreEntry::hasDisk(), StoreEntry::hasMemStore(), StoreEntry::hasTransients(), Transients::EntryStatus::hasWriter, Here, MemObject::MemCache::io, MemObject::ioDone, StoreEntry::mem(), MemObject::memCache, StoreEntry::setCollapsingRequirement(), and Transients::EntryStatus::waitingToBeFreed.

◆ callback()

int StoreControllerStub::callback ( )
overridevirtual

Reimplemented from Store::Controller.

Definition at line 20 of file testStore.cc.

◆ checkFoundCandidate()

void Store::Controller::checkFoundCandidate ( const StoreEntry entry) const
privateinherited

◆ checkTransients()

void Store::Controller::checkTransients ( const StoreEntry e) const
privateinherited

◆ configure()

◆ create()

void Store::Controller::create ( )
overridevirtualinherited

Implements Store::Storage.

Definition at line 78 of file Controller.cc.

References pid, and WaitForAnyPid().

Referenced by SquidMain().

◆ currentCount()

uint64_t StoreControllerStub::currentCount ( ) const
overridevirtual

Reimplemented from Store::Controller.

Definition at line 58 of file testStore.cc.

◆ currentSize()

uint64_t StoreControllerStub::currentSize ( ) const
overridevirtual

Reimplemented from Store::Controller.

Definition at line 52 of file testStore.cc.

◆ dereference()

virtual bool StoreControllerStub::dereference ( StoreEntry )
inlinevirtual

Definition at line 76 of file testStore.h.

◆ dereferenceIdle()

bool Store::Controller::dereferenceIdle ( StoreEntry e,
bool  wantsLocalMemory 
)
privateinherited

◆ evictCached()

void Store::Controller::evictCached ( StoreEntry e)
overridevirtualinherited

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 490 of file Controller.cc.

References debugs.

Referenced by StoreEntry::release(), and StoreEntry::setPrivateKey().

◆ evictIfFound()

void Store::Controller::evictIfFound ( const cache_key )
overridevirtualinherited

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 501 of file Controller.cc.

References debugs, and storeKeyText().

Referenced by purgeEntriesByUrl().

◆ find()

StoreEntry * Store::Controller::find ( const cache_key key)
inherited
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 349 of file Controller.cc.

References debugs.

Referenced by storeGetPublic(), and storeGetPublicByRequestMethod().

◆ findCallbackXXX()

StoreEntry * Store::Controller::findCallbackXXX ( const cache_key key)
inherited
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 395 of file Controller.cc.

References hash_lookup(), and store_table.

Referenced by neighborsHtcpReply().

◆ freeMemorySpace()

void Store::Controller::freeMemorySpace ( const int  spaceRequired)
inherited

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 530 of file Controller.cc.

References debugs, hot_obj_count, mem_policy, RemovalPolicy::PurgeInit, SM_PAGE_SIZE, and squid_curtime.

Referenced by storeGetMemSpace().

◆ get() [1/2]

StoreEntry * StoreControllerStub::get ( const cache_key )
virtual

Definition at line 26 of file testStore.cc.

◆ get() [2/2]

void StoreControllerStub::get ( String  ,
void(*)(StoreEntry *, void *)  ,
void *   
)
virtual

Definition at line 32 of file testStore.cc.

◆ getStats()

void StoreControllerStub::getStats ( StoreInfoStats stats) const
overridevirtual

Reimplemented from Store::Controller.

Definition at line 70 of file testStore.cc.

◆ handleIdleEntry()

◆ hasReadableDiskEntry()

bool Store::Controller::hasReadableDiskEntry ( const StoreEntry e) const
inherited

Definition at line 321 of file Controller.cc.

◆ init()

void StoreControllerStub::init ( )
overridevirtual

Start preparing the store for use. To check readiness, callers should use readable() and writable() methods.

Reimplemented from Store::Controller.

Definition at line 36 of file testStore.cc.

◆ keepForLocalMemoryCache()

bool Store::Controller::keepForLocalMemoryCache ( StoreEntry e) const
privateinherited

◆ maintain()

void StoreControllerStub::maintain ( )
inlineoverridevirtual

Reimplemented from Store::Controller.

Definition at line 58 of file testStore.h.

◆ markedForDeletion()

bool Store::Controller::markedForDeletion ( const cache_key key) const
inherited

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 305 of file Controller.cc.

Referenced by Ipc::StoreMapAnchor::setKey().

◆ markedForDeletionAndAbandoned()

bool Store::Controller::markedForDeletionAndAbandoned ( const StoreEntry e) const
inherited

markedForDeletion() with no readers this is one method because the two conditions must be checked in the right order

Definition at line 312 of file Controller.cc.

References hash_link::key.

◆ maxObjectSize()

int64_t StoreControllerStub::maxObjectSize ( ) const
overridevirtual

Reimplemented from Store::Controller.

Definition at line 64 of file testStore.cc.

◆ maxSize()

uint64_t StoreControllerStub::maxSize ( ) const
overridevirtual

The maximum size the store will support in normal use. Inaccuracy is permitted, but may throw estimates for memory etc out of whack.

Reimplemented from Store::Controller.

Definition at line 40 of file testStore.cc.

◆ memoryCacheHasSpaceFor()

bool Store::Controller::memoryCacheHasSpaceFor ( const int  pagesRequired) const
privateinherited

Definition at line 521 of file Controller.cc.

References debugs, mem_node::InUseCount(), and store_pages_max.

◆ memoryDisconnect()

void Store::Controller::memoryDisconnect ( StoreEntry e)
inherited

Definition at line 617 of file Controller.cc.

Referenced by StoreEntry::destroyMemObject().

◆ memoryEvictCached()

void Store::Controller::memoryEvictCached ( StoreEntry e)
privateinherited

removes the entry from the memory cache XXX: Dangerous side effect: Unlocked entries lose their mem_obj.

Definition at line 606 of file Controller.cc.

References StoreEntry::destroyMemObject(), and StoreEntry::locked().

◆ memoryOut()

void Store::Controller::memoryOut ( StoreEntry e,
const bool  preserveSwappable 
)
inherited

Definition at line 589 of file Controller.cc.

References debugs, and StoreEntry::trimMemory().

Referenced by StoreEntry::swapOut().

◆ minSize()

uint64_t StoreControllerStub::minSize ( ) const
overridevirtual

Reimplemented from Store::Controller.

Definition at line 46 of file testStore.cc.

◆ noteStoppedSharedWriting()

void Store::Controller::noteStoppedSharedWriting ( StoreEntry e)
inherited

Definition at line 625 of file Controller.cc.

References StoreEntry::hasTransients().

Referenced by StoreEntry::storeWritingCheckpoint().

◆ peek()

StoreEntry * Store::Controller::peek ( const cache_key key)
inherited
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 427 of file Controller.cc.

References debugs, and storeKeyText().

◆ peekAtLocal()

StoreEntry * Store::Controller::peekAtLocal ( const cache_key key)
privateinherited
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 411 of file Controller.cc.

References assert, EBIT_TEST, hash_lookup(), KEY_PRIVATE, and store_table.

◆ reference()

virtual void StoreControllerStub::reference ( StoreEntry )
inlinevirtual

Definition at line 74 of file testStore.h.

◆ referenceBusy()

void Store::Controller::referenceBusy ( StoreEntry e)
privateinherited

◆ search()

StoreSearch * StoreControllerStub::search ( )
virtual

Definition at line 81 of file testStore.cc.

◆ SmpAware()

bool Store::Controller::SmpAware ( )
staticinherited

◆ stat()

void StoreControllerStub::stat ( StoreEntry e) const
overridevirtual

Output stats to the provided store entry. TODO: make these calls asynchronous

Reimplemented from Store::Controller.

Definition at line 75 of file testStore.cc.

References statsCalled.

◆ sync()

void Store::Controller::sync ( void  )
overridevirtualinherited

Reimplemented from Store::Storage.

Definition at line 218 of file Controller.cc.

Referenced by SquidShutdown().

◆ syncCollapsed()

◆ transientReaders()

int Store::Controller::transientReaders ( const StoreEntry e) const
inherited

Definition at line 632 of file Controller.cc.

References StoreEntry::hasTransients().

Referenced by CollapsedForwarding::Broadcast().

◆ transientsDisconnect()

void Store::Controller::transientsDisconnect ( StoreEntry e)
inherited

Definition at line 639 of file Controller.cc.

Referenced by StoreEntry::destroyMemObject().

◆ transientsReader()

bool Store::Controller::transientsReader ( const StoreEntry e) const
inherited

Definition at line 468 of file Controller.cc.

References StoreEntry::hasTransients().

◆ transientsUnlinkByKeyIfFound()

void Store::Controller::transientsUnlinkByKeyIfFound ( const cache_key )
privateinherited

◆ transientsWriter()

bool Store::Controller::transientsWriter ( const StoreEntry e) const
inherited

Definition at line 474 of file Controller.cc.

References StoreEntry::hasTransients().

◆ updateOnNotModified()

bool Store::Controller::updateOnNotModified ( StoreEntry old,
StoreEntry e304 
)
inherited

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 695 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

◆ localMemStore

bool Store::Controller::localMemStore
privateinherited

Definition at line 154 of file Controller.h.

◆ memoryPagesDebt_

int Store::Controller::memoryPagesDebt_ = 0
privateinherited

Definition at line 162 of file Controller.h.

◆ sharedMemStore

Memory* Store::Controller::sharedMemStore
privateinherited

Definition at line 153 of file Controller.h.

◆ statsCalled

bool StoreControllerStub::statsCalled

Definition at line 48 of file testStore.h.

Referenced by stat(), and TestStore::testStats().

◆ store_dirs_rebuilding

◆ swapDir

Disks* Store::Controller::swapDir
privateinherited

Definition at line 152 of file Controller.h.

◆ transients

Transients* Store::Controller::transients
privateinherited

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 159 of file Controller.h.


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors