#include <Transients.h>


Classes | |
class | EntryStatus |
shared entry metadata, used for synchronization More... | |
Public Member Functions | |
Transients () | |
virtual | ~Transients () |
StoreEntry * | findCollapsed (const sfileno xitIndex) |
return a local, previously collapsed entry More... | |
void | clearCollapsingRequirement (const StoreEntry &e) |
removes collapsing requirement (for future hits) More... | |
void | monitorIo (StoreEntry *, const cache_key *, const Store::IoStatus) |
void | completeWriting (const StoreEntry &e) |
called when the in-transit entry has been successfully cached More... | |
void | status (const StoreEntry &e, EntryStatus &entryStatus) const |
copies current shared entry metadata into entryStatus More... | |
int | readers (const StoreEntry &e) const |
number of entry readers some time ago More... | |
void | disconnect (StoreEntry &) |
the caller is done writing or reading the given entry More... | |
virtual StoreEntry * | get (const cache_key *) override |
virtual void | create () override |
create system resources needed for this store to operate in the future More... | |
virtual void | init () override |
virtual uint64_t | maxSize () const override |
virtual uint64_t | minSize () const override |
the minimum size the store will shrink to via normal housekeeping More... | |
virtual uint64_t | currentSize () const override |
current size More... | |
virtual uint64_t | currentCount () const override |
the total number of objects stored right now More... | |
virtual int64_t | maxObjectSize () const override |
the maximum size of a storable object; -1 if unlimited More... | |
virtual void | getStats (StoreInfoStats &stats) const override |
collect statistics More... | |
virtual void | stat (StoreEntry &e) const override |
virtual void | reference (StoreEntry &e) override |
somebody needs this entry (many cache replacement policies need to know) More... | |
virtual bool | dereference (StoreEntry &e) override |
virtual void | evictCached (StoreEntry &) override |
virtual void | evictIfFound (const cache_key *) override |
virtual void | maintain () override |
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain More... | |
bool | markedForDeletion (const cache_key *) const |
bool | isReader (const StoreEntry &) const |
whether the entry is in "reading from Transients" I/O state More... | |
bool | isWriter (const StoreEntry &) const |
whether the entry is in "writing to Transients" I/O state More... | |
bool | hasWriter (const StoreEntry &) |
whether we or somebody else is in the "writing to Transients" I/O state More... | |
virtual void | updateHeaders (StoreEntry *) |
make stored metadata and HTTP headers the same as in the given entry More... | |
virtual bool | anchorToCache (StoreEntry &, bool &) |
virtual bool | updateAnchored (StoreEntry &) |
virtual int | callback () |
called once every main loop iteration; TODO: Move to UFS code. More... | |
virtual void | sync () |
prepare for shutdown More... | |
Static Public Member Functions | |
static int64_t | EntryLimit () |
calculates maximum number of entries we need to store and map More... | |
static bool | Enabled () |
Can we create and initialize Transients? More... | |
Protected Member Functions | |
void | addEntry (StoreEntry *, const cache_key *, const Store::IoStatus) |
creates a new Transients entry More... | |
void | addWriterEntry (StoreEntry &, const cache_key *) |
addEntry() helper used for cache entry creators/writers More... | |
void | addReaderEntry (StoreEntry &, const cache_key *) |
void | anchorEntry (StoreEntry &, const sfileno, const Ipc::StoreMapAnchor &) |
fills (recently created) StoreEntry with information currently in Transients More... | |
virtual void | noteFreeMapSlice (const Ipc::StoreMapSliceId sliceId) override |
adjust slice-linked state before a locked Readable slice is erased More... | |
Private Types | |
typedef std::vector< StoreEntry * > | Locals |
Private Attributes | |
TransientsMap * | map |
shared packed info indexed by Store keys, for creating new StoreEntries More... | |
Locals * | locals |
Detailed Description
Keeps track of store entries being delivered to clients that arrived before those entries were [fully] cached. This SMP-shared table is necessary to
- sync an entry-writing worker with entry-reading worker(s); and
- sync an entry-deleting worker with both entry-reading/writing workers.
Definition at line 26 of file Transients.h.
Member Typedef Documentation
◆ Locals
|
private |
Definition at line 109 of file Transients.h.
Constructor & Destructor Documentation
◆ Transients()
Transients::Transients | ( | ) |
Definition at line 30 of file Transients.cc.
◆ ~Transients()
|
virtual |
Definition at line 34 of file Transients.cc.
Member Function Documentation
◆ addEntry()
|
protected |
Definition at line 232 of file Transients.cc.
References addReaderEntry(), addWriterEntry(), assert, StoreEntry::hasTransients(), Store::ioReading, Store::ioWriting, map, StoreEntry::mem_obj, and Must.
Referenced by monitorIo().
◆ addReaderEntry()
|
protected |
addEntry() helper used for cache readers readers do not modify the cache, but they must create a Transients entry
Definition at line 271 of file Transients.cc.
References anchorEntry(), Here, map, and Ipc::StoreMap::openOrCreateForReading().
Referenced by addEntry().
◆ addWriterEntry()
|
protected |
Definition at line 249 of file Transients.cc.
References Here, MemObject::XitTable::index, Store::ioWriting, map, StoreEntry::mem_obj, Ipc::StoreMap::openForWriting(), Ipc::StoreMap::startAppending(), and MemObject::xitTable.
Referenced by addEntry().
◆ anchorEntry()
|
protected |
Definition at line 284 of file Transients.cc.
References assert, Ipc::StoreMapAnchor::basics, EBIT_TEST, ENTRY_REQUIRES_COLLAPSING, Ipc::StoreMapAnchor::exportInto(), Ipc::StoreMapAnchor::Basics::flags, hasWriter(), MemObject::XitTable::index, Store::ioReading, StoreEntry::mem_obj, StoreEntry::setCollapsingRequirement(), and MemObject::xitTable.
Referenced by addReaderEntry(), and get().
◆ anchorToCache()
|
inlinevirtualinherited |
If Transients entry cannot be attached to this storage, return false. If the entry is not found, return false. Otherwise, return true after tying the entry to this cache and setting inSync to updateAnchored().
Reimplemented in Rock::SwapDir, Store::Disks, and MemStore.
Definition at line 40 of file Controlled.h.
Referenced by Store::Disks::anchorToCache().
◆ callback()
|
inlinevirtualinherited |
Reimplemented in Store::Disks, Store::Controller, Fs::Ufs::UFSSwapDir, and TestStore.
◆ clearCollapsingRequirement()
void Transients::clearCollapsingRequirement | ( | const StoreEntry & | e | ) |
Definition at line 199 of file Transients.cc.
References assert, CollapsedForwarding::Broadcast(), EBIT_CLR, EBIT_TEST, ENTRY_REQUIRES_COLLAPSING, StoreEntry::hasTransients(), MemObject::XitTable::index, isWriter(), map, StoreEntry::mem_obj, Ipc::StoreMap::writeableEntry(), and MemObject::xitTable.
◆ completeWriting()
void Transients::completeWriting | ( | const StoreEntry & | e | ) |
Definition at line 327 of file Transients.cc.
References assert, StoreEntry::hasTransients(), MemObject::XitTable::index, MemObject::XitTable::io, Store::ioReading, isWriter(), map, StoreEntry::mem_obj, Ipc::StoreMap::switchWritingToReading(), and MemObject::xitTable.
◆ create()
|
inlineoverridevirtual |
Implements Store::Storage.
Definition at line 65 of file Transients.h.
◆ currentCount()
|
overridevirtual |
Implements Store::Storage.
Definition at line 118 of file Transients.cc.
References Ipc::StoreMap::entryCount(), and map.
Referenced by getStats(), and stat().
◆ currentSize()
|
overridevirtual |
◆ dereference()
|
overridevirtual |
somebody no longer needs this entry (usually after calling reference()) return false iff the idle entry should be destroyed
Implements Store::Controlled.
Definition at line 137 of file Transients.cc.
◆ disconnect()
void Transients::disconnect | ( | StoreEntry & | entry | ) |
Definition at line 371 of file Transients.cc.
References Ipc::StoreMap::abortWriting(), assert, Ipc::StoreMap::closeForReadingAndFreeIdle(), debugs, StoreEntry::hasTransients(), Store::ioDone, isReader(), isWriter(), locals, map, StoreEntry::mem_obj, and MemObject::xitTable.
◆ Enabled()
|
inlinestatic |
Definition at line 94 of file Transients.h.
References EntryLimit().
Referenced by Store::Controller::init(), and init().
◆ EntryLimit()
|
static |
Definition at line 391 of file Transients.cc.
References Config, SquidConfig::shared_transient_entries_limit, Store::Controller::SmpAware(), and UsingSmp().
Referenced by TransientsRr::create(), Enabled(), and init().
◆ 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 346 of file Transients.cc.
References CollapsedForwarding::Broadcast(), debugs, Ipc::StoreMap::freeEntry(), StoreEntry::hasTransients(), MemObject::XitTable::index, map, StoreEntry::mem_obj, and MemObject::xitTable.
◆ 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 360 of file Transients.cc.
References CollapsedForwarding::Broadcast(), Ipc::StoreMap::fileNoByKey(), Ipc::StoreMap::freeEntry(), and map.
◆ findCollapsed()
StoreEntry * Transients::findCollapsed | ( | const sfileno | xitIndex | ) |
◆ get()
|
overridevirtual |
- Returns
- a possibly unlocked/unregistered stored entry with key (or nil) The returned entry might not match the caller's Store ID or method. The caller must abandon()/release() the entry or register it with Root(). This method must not trigger slow I/O operations (e.g., disk swap in).
Implements Store::Controlled.
Definition at line 144 of file Transients.cc.
References anchorEntry(), assert, Ipc::StoreMapAnchor::basics, Ipc::StoreMap::closeForReadingAndFreeIdle(), StoreEntry::createMemObject(), debugs, EBIT_TEST, ENTRY_REQUIRES_COLLAPSING, Ipc::StoreMapAnchor::Basics::flags, KEY_PRIVATE, locals, map, NULL, Ipc::StoreMap::openForReading(), and Ipc::StoreMap::peekAtWriter().
◆ getStats()
|
overridevirtual |
Implements Store::Storage.
Definition at line 56 of file Transients.cc.
References Ipc::Mem::PageId::cachePage, currentCount(), Ipc::Mem::PageLevel(), Ipc::Mem::PageLimit(), Ipc::Mem::PageSize(), and Ping::stats.
◆ hasWriter()
bool Transients::hasWriter | ( | const StoreEntry & | e | ) |
Definition at line 300 of file Transients.cc.
References StoreEntry::hasTransients(), MemObject::XitTable::index, map, StoreEntry::mem_obj, Ipc::StoreMap::peekAtWriter(), and MemObject::xitTable.
Referenced by anchorEntry().
◆ init()
|
overridevirtual |
Start preparing the store for use. To check readiness, callers should use readable() and writable() methods.
Implements Store::Storage.
Definition at line 41 of file Transients.cc.
References assert, Ipc::StoreMap::cleaner, Ipc::StoreMap::disableHitValidation(), Enabled(), EntryLimit(), locals, map, MapLabel, and Must.
Referenced by Store::Controller::init().
◆ isReader()
bool Transients::isReader | ( | const StoreEntry & | e | ) | const |
Definition at line 405 of file Transients.cc.
References MemObject::XitTable::io, Store::ioReading, StoreEntry::mem_obj, and MemObject::xitTable.
Referenced by disconnect().
◆ isWriter()
bool Transients::isWriter | ( | const StoreEntry & | e | ) | const |
Definition at line 411 of file Transients.cc.
References MemObject::XitTable::io, Store::ioWriting, StoreEntry::mem_obj, and MemObject::xitTable.
Referenced by clearCollapsingRequirement(), completeWriting(), disconnect(), and status().
◆ maintain()
|
overridevirtual |
Implements Store::Storage.
Definition at line 91 of file Transients.cc.
◆ markedForDeletion()
bool Transients::markedForDeletion | ( | const cache_key * | key | ) | const |
Whether an 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 398 of file Transients.cc.
References assert, map, and Ipc::StoreMap::markedForDeletion().
◆ maxObjectSize()
|
overridevirtual |
◆ 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 103 of file Transients.cc.
References max().
Referenced by stat().
◆ minSize()
|
overridevirtual |
Implements Store::Storage.
Definition at line 97 of file Transients.cc.
◆ monitorIo()
void Transients::monitorIo | ( | StoreEntry * | e, |
const cache_key * | key, | ||
const Store::IoStatus | direction | ||
) |
start listening for remote DELETE requests targeting either a complete StoreEntry (ioReading) or a being-formed miss StoreEntry (ioWriting)
Definition at line 213 of file Transients.cc.
References addEntry(), assert, StoreEntry::hasTransients(), MemObject::XitTable::index, locals, StoreEntry::mem_obj, and MemObject::xitTable.
◆ noteFreeMapSlice()
|
overrideprotectedvirtual |
Implements Ipc::StoreMapCleaner.
Definition at line 308 of file Transients.cc.
◆ readers()
int Transients::readers | ( | const StoreEntry & | e | ) | const |
Definition at line 336 of file Transients.cc.
References assert, StoreEntry::hasTransients(), MemObject::XitTable::index, Ipc::StoreMapAnchor::lock, map, StoreEntry::mem_obj, Ipc::StoreMap::peekAtEntry(), Ipc::ReadWriteLock::readers, and MemObject::xitTable.
◆ reference()
|
overridevirtual |
Implements Store::Controlled.
Definition at line 131 of file Transients.cc.
◆ stat()
|
overridevirtual |
Output stats to the provided store entry. TODO: make these calls asynchronous
Implements Store::Storage.
Definition at line 71 of file Transients.cc.
References currentCount(), currentSize(), Math::doublePercent(), Ipc::StoreMap::entryLimit(), map, maxSize(), PRId64, and storeAppendPrintf().
◆ status()
void Transients::status | ( | const StoreEntry & | e, |
Transients::EntryStatus & | entryStatus | ||
) | const |
Definition at line 314 of file Transients.cc.
References Transients::EntryStatus::abortedByWriter, assert, Transients::EntryStatus::collapsed, EBIT_TEST, ENTRY_REQUIRES_COLLAPSING, StoreEntry::hasTransients(), MemObject::XitTable::index, isWriter(), map, StoreEntry::mem_obj, Ipc::StoreMap::readableEntry(), Transients::EntryStatus::waitingToBeFreed, Ipc::StoreMap::writeableEntry(), and MemObject::xitTable.
◆ sync()
|
inlinevirtualinherited |
Reimplemented in Store::Disks, Store::Controller, and Fs::Ufs::UFSSwapDir.
◆ updateAnchored()
|
inlinevirtualinherited |
Update a local Transients entry with fresh info from this cache (if any). Return true iff the cache supports Transients entries and the given local Transients entry is now in sync with this storage.
Reimplemented in Store::Disks, MemStore, and Rock::SwapDir.
Definition at line 45 of file Controlled.h.
Referenced by Store::Disks::updateAnchored().
◆ updateHeaders()
|
inlinevirtualinherited |
Reimplemented in MemStore, Rock::SwapDir, and Store::Disks.
Definition at line 35 of file Controlled.h.
Referenced by Store::Disks::updateHeaders().
Member Data Documentation
◆ locals
|
private |
local collapsed reader and writer entries, indexed by transient ID, for syncing old StoreEntries
Definition at line 112 of file Transients.h.
Referenced by ~Transients(), disconnect(), findCollapsed(), get(), init(), and monitorIo().
◆ map
|
private |
Definition at line 107 of file Transients.h.
Referenced by ~Transients(), addEntry(), addReaderEntry(), addWriterEntry(), clearCollapsingRequirement(), completeWriting(), currentCount(), disconnect(), evictCached(), evictIfFound(), findCollapsed(), get(), hasWriter(), init(), markedForDeletion(), readers(), stat(), and status().
The documentation for this class was generated from the following files:
- src/Transients.h
- src/Transients.cc