Transients.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_TRANSIENTS_H
10 #define SQUID_TRANSIENTS_H
11 
12 #include "ipc/mem/Page.h"
13 #include "ipc/mem/PageStack.h"
14 #include "ipc/StoreMap.h"
15 #include "Store.h"
16 #include "store/Controlled.h"
17 #include "store/forward.h"
18 #include <vector>
19 
21 
27 {
28 public:
31  {
32  public:
33  bool abortedByWriter = false;
34  bool waitingToBeFreed = false;
35  bool collapsed = false;
36  };
37 
38  Transients();
39  virtual ~Transients();
40 
42  StoreEntry *findCollapsed(const sfileno xitIndex);
43 
46 
49  void monitorIo(StoreEntry*, const cache_key*, const Store::IoStatus);
50 
52  void completeWriting(const StoreEntry &e);
53 
55  void status(const StoreEntry &e, EntryStatus &entryStatus) const;
56 
58  int readers(const StoreEntry &e) const;
59 
61  void disconnect(StoreEntry &);
62 
63  /* Store API */
64  virtual StoreEntry *get(const cache_key *) override;
65  virtual void create() override {}
66  virtual void init() override;
67  virtual uint64_t maxSize() const override;
68  virtual uint64_t minSize() const override;
69  virtual uint64_t currentSize() const override;
70  virtual uint64_t currentCount() const override;
71  virtual int64_t maxObjectSize() const override;
72  virtual void getStats(StoreInfoStats &stats) const override;
73  virtual void stat(StoreEntry &e) const override;
74  virtual void reference(StoreEntry &e) override;
75  virtual bool dereference(StoreEntry &e) override;
76  virtual void evictCached(StoreEntry &) override;
77  virtual void evictIfFound(const cache_key *) override;
78  virtual void maintain() override;
79 
82  bool markedForDeletion(const cache_key *) const;
83 
85  bool isReader(const StoreEntry &) const;
87  bool isWriter(const StoreEntry &) const;
88 
89  static int64_t EntryLimit();
90 
92  static bool Enabled() { return EntryLimit(); }
93 
94 protected:
95  void addEntry(StoreEntry*, const cache_key *, const Store::IoStatus);
96 
97  // Ipc::StoreMapCleaner API
98  virtual void noteFreeMapSlice(const Ipc::StoreMapSliceId sliceId) override;
99 
100 private:
103 
104  typedef std::vector<StoreEntry*> Locals;
108 };
109 
110 // TODO: Why use Store as a base? We are not really a cache.
111 
112 #endif /* SQUID_TRANSIENTS_H */
113 
Locals * locals
Definition: Transients.h:107
virtual void init() override
Definition: Transients.cc:41
bool isWriter(const StoreEntry &) const
whether the entry is in &quot;writing to Transients&quot; I/O state
Definition: Transients.cc:358
virtual uint64_t maxSize() const override
Definition: Transients.cc:102
unsigned char cache_key
Store key.
Definition: forward.h:29
std::vector< StoreEntry * > Locals
Definition: Transients.h:104
class Ping::pingStats_ stats
virtual void evictCached(StoreEntry &) override
Definition: Transients.cc:293
virtual bool dereference(StoreEntry &e) override
Definition: Transients.cc:136
bool abortedByWriter
whether the entry was aborted
Definition: Transients.h:33
void clearCollapsingRequirement(const StoreEntry &e)
removes collapsing requirement (for future hits)
Definition: Transients.cc:192
High-level store statistics used by mgr:info action. Used inside PODs!
Definition: StoreStats.h:13
StoreEntry * findCollapsed(const sfileno xitIndex)
return a local, previously collapsed entry
Definition: Transients.cc:176
virtual void evictIfFound(const cache_key *) override
Definition: Transients.cc:307
bool isReader(const StoreEntry &) const
whether the entry is in &quot;reading from Transients&quot; I/O state
Definition: Transients.cc:352
virtual ~Transients()
Definition: Transients.cc:34
API for adjusting external state when dirty map slice is being freed.
Definition: StoreMap.h:352
TransientsMap * map
shared packed info indexed by Store keys, for creating new StoreEntries
Definition: Transients.h:102
Ipc::StoreMap TransientsMap
Definition: Transients.h:20
virtual int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Transients.cc:123
virtual void noteFreeMapSlice(const Ipc::StoreMapSliceId sliceId) override
adjust slice-linked state before a locked Readable slice is erased
Definition: Transients.cc:255
bool collapsed
whether the entry allows collapsing
Definition: Transients.h:35
IoStatus
cache &quot;I/O&quot; direction and status
Definition: forward.h:40
void disconnect(StoreEntry &)
the caller is done writing or reading the given entry
Definition: Transients.cc:318
int32_t StoreMapSliceId
Definition: StoreMap.h:24
virtual void reference(StoreEntry &e) override
somebody needs this entry (many cache replacement policies need to know)
Definition: Transients.cc:130
void monitorIo(StoreEntry *, const cache_key *, const Store::IoStatus)
Definition: Transients.cc:206
void completeWriting(const StoreEntry &e)
called when the in-transit entry has been successfully cached
Definition: Transients.cc:274
virtual void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: Transients.cc:55
signed_int32_t sfileno
Definition: forward.h:22
virtual void create() override
create system resources needed for this store to operate in the future
Definition: Transients.h:65
virtual uint64_t currentCount() const override
the total number of objects stored right now
Definition: Transients.cc:117
virtual uint64_t currentSize() const override
current size
Definition: Transients.cc:109
bool markedForDeletion(const cache_key *) const
Definition: Transients.cc:345
static int64_t EntryLimit()
calculates maximum number of entries we need to store and map
Definition: Transients.cc:338
virtual void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: Transients.cc:90
shared entry metadata, used for synchronization
Definition: Transients.h:30
virtual uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: Transients.cc:96
virtual void stat(StoreEntry &e) const override
Definition: Transients.cc:70
int readers(const StoreEntry &e) const
number of entry readers some time ago
Definition: Transients.cc:283
void status(const StoreEntry &e, EntryStatus &entryStatus) const
copies current shared entry metadata into entryStatus
Definition: Transients.cc:261
bool waitingToBeFreed
whether the entry was marked for deletion
Definition: Transients.h:34
void addEntry(StoreEntry *, const cache_key *, const Store::IoStatus)
creates a new Transients entry
Definition: Transients.cc:225
static bool Enabled()
Can we create and initialize Transients?
Definition: Transients.h:92

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors