Transients.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 "http/MethodType.h"
13 #include "ipc/mem/Page.h"
14 #include "ipc/mem/PageStack.h"
15 #include "ipc/StoreMap.h"
16 #include "Store.h"
17 #include "store/Controlled.h"
18 #include <vector>
19 
20 // StoreEntry restoration info not already stored by Ipc::StoreMap
22  char url[MAX_URL+1];
25 };
28 
33 {
34 public:
35  Transients();
36  virtual ~Transients();
37 
39  StoreEntry *findCollapsed(const sfileno xitIndex);
40 
42  void startWriting(StoreEntry *e, const RequestFlags &reqFlags, const HttpRequestMethod &reqMethod);
43 
45  void completeWriting(const StoreEntry &e);
46 
48  void abandon(const StoreEntry &e);
49 
51  bool abandoned(const StoreEntry &e) const;
52 
54  int readers(const StoreEntry &e) const;
55 
57  void disconnect(MemObject &mem_obj);
58 
59  /* Store API */
60  virtual StoreEntry *get(const cache_key *) override;
61  virtual void create() override {}
62  virtual void init() override;
63  virtual uint64_t maxSize() const override;
64  virtual uint64_t minSize() const override;
65  virtual uint64_t currentSize() const override;
66  virtual uint64_t currentCount() const override;
67  virtual int64_t maxObjectSize() const override;
68  virtual void getStats(StoreInfoStats &stats) const override;
69  virtual void stat(StoreEntry &e) const override;
70  virtual void reference(StoreEntry &e) override;
71  virtual bool dereference(StoreEntry &e) override;
72  virtual void markForUnlink(StoreEntry &e) override;
73  virtual void unlink(StoreEntry &e) override;
74  virtual void maintain() override;
75  virtual bool smpAware() const override { return true; }
76 
77  static int64_t EntryLimit();
78 
79 protected:
80  StoreEntry *copyFromShm(const sfileno index);
81  bool copyToShm(const StoreEntry &e, const sfileno index, const RequestFlags &reqFlags, const HttpRequestMethod &reqMethod);
82 
83  bool abandonedAt(const sfileno index) const;
84 
85  // Ipc::StoreMapCleaner API
86  virtual void noteFreeMapSlice(const Ipc::StoreMapSliceId sliceId) override;
87 
88 private:
91 
95 
96  typedef std::vector<StoreEntry*> Locals;
99 };
100 
101 // TODO: Why use Store as a base? We are not really a cache.
102 
103 #endif /* SQUID_TRANSIENTS_H */
104 
Locals * locals
local collapsed entries indexed by transient ID, for syncing old StoreEntries
Definition: Transients.h:98
virtual bool smpAware() const override
Definition: Transients.h:75
virtual void init() override
Definition: Transients.cc:43
Ipc::Mem::Pointer< Extras > extras
Definition: Transients.h:94
virtual uint64_t maxSize() const override
Definition: Transients.cc:106
unsigned char cache_key
Store key.
Definition: forward.h:29
bool abandonedAt(const sfileno index) const
whether an in-transit entry at the index is now abandoned by its writer
Definition: Transients.cc:306
std::vector< StoreEntry * > Locals
Definition: Transients.h:96
class Ping::pingStats_ stats
void startWriting(StoreEntry *e, const RequestFlags &reqFlags, const HttpRequestMethod &reqMethod)
add an in-transit entry suitable for collapsing future requests
Definition: Transients.cc:220
Ipc::StoreMapItems< TransientsMapExtraItem > TransientsMapExtras
Definition: Transients.h:26
virtual bool dereference(StoreEntry &e) override
Definition: Transients.cc:140
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:204
virtual ~Transients()
Definition: Transients.cc:36
API for adjusting external state when dirty map slice is being freed.
Definition: StoreMap.h:329
virtual void markForUnlink(StoreEntry &e) override
expect an unlink() call after the entry becomes idle
Definition: Transients.cc:337
TransientsMap * map
shared packed info indexed by Store keys, for creating new StoreEntries
Definition: Transients.h:90
Ipc::StoreMap TransientsMap
Definition: Transients.h:27
virtual int64_t maxObjectSize() const override
the maximum size of a storable object; -1 if unlimited
Definition: Transients.cc:127
virtual void noteFreeMapSlice(const Ipc::StoreMapSliceId sliceId) override
adjust slice-linked state before a locked Readable slice is erased
Definition: Transients.cc:281
enum Http::_method_t MethodType
void abandon(const StoreEntry &e)
the calling entry writer no longer expects to cache this entry
Definition: Transients.cc:287
void disconnect(MemObject &mem_obj)
the caller is done writing or reading this entry
Definition: Transients.cc:350
int32_t StoreMapSliceId
Definition: StoreMap.h:24
virtual void unlink(StoreEntry &e) override
remove the entry from the store
Definition: Transients.cc:343
virtual void reference(StoreEntry &e) override
somebody needs this entry (many cache replacement policies need to know)
Definition: Transients.cc:134
void completeWriting(const StoreEntry &e)
called when the in-transit entry has been successfully cached
Definition: Transients.cc:313
virtual void getStats(StoreInfoStats &stats) const override
collect statistics
Definition: Transients.cc:59
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:61
virtual uint64_t currentCount() const override
the total number of objects stored right now
Definition: Transients.cc:121
virtual uint64_t currentSize() const override
current size
Definition: Transients.cc:113
StoreEntry * copyFromShm(const sfileno index)
Definition: Transients.cc:174
TransientsMapExtras Extras
shared packed info that standard StoreMap does not store for us
Definition: Transients.h:93
char url[MAX_URL+1]
Request-URI; TODO: decrease MAX_URL by one.
Definition: Transients.h:22
static int64_t EntryLimit()
calculates maximum number of entries we need to store and map
Definition: Transients.cc:368
virtual void maintain() override
perform regular periodic maintenance; TODO: move to UFSSwapDir::Maintain
Definition: Transients.cc:94
bool copyToShm(const StoreEntry &e, const sfileno index, const RequestFlags &reqFlags, const HttpRequestMethod &reqMethod)
copies all relevant local data to shared memory
Definition: Transients.cc:260
virtual uint64_t minSize() const override
the minimum size the store will shrink to via normal housekeeping
Definition: Transients.cc:100
bool abandoned(const StoreEntry &e) const
whether an in-transit entry is now abandoned by its writer
Definition: Transients.cc:298
virtual void stat(StoreEntry &e) const override
Definition: Transients.cc:74
int readers(const StoreEntry &e) const
number of entry readers some time ago
Definition: Transients.cc:327
#define MAX_URL
Definition: defines.h:118
Http::MethodType reqMethod
request method; extensions are not supported
Definition: Transients.h:24
RequestFlags reqFlags
request flags
Definition: Transients.h:23

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors