]>
Commit | Line | Data |
---|---|---|
e2851fe7 AR |
1 | #ifndef SQUID_FS_ROCK_SWAP_DIR_H |
2 | #define SQUID_FS_ROCK_SWAP_DIR_H | |
3 | ||
4 | #include "SwapDir.h" | |
43ebbac3 | 5 | #include "DiskIO/DiskFile.h" |
e2851fe7 | 6 | #include "DiskIO/IORequestor.h" |
fcd789da | 7 | #include "fs/rock/RockDbCell.h" |
68353d5a | 8 | #include "ipc/StoreMap.h" |
e2851fe7 AR |
9 | |
10 | class DiskIOStrategy; | |
e2851fe7 AR |
11 | class ReadRequest; |
12 | class WriteRequest; | |
13 | ||
9199139f AR |
14 | namespace Rock |
15 | { | |
e2851fe7 AR |
16 | |
17 | class Rebuild; | |
18 | ||
19 | /// \ingroup Rock | |
20 | class SwapDir: public ::SwapDir, public IORequestor | |
21 | { | |
22 | public: | |
23 | SwapDir(); | |
24 | virtual ~SwapDir(); | |
25 | ||
26 | /* public ::SwapDir API */ | |
c6059970 | 27 | virtual void reconfigure(); |
e2851fe7 | 28 | virtual StoreSearch *search(String const url, HttpRequest *); |
44def0f9 | 29 | virtual StoreEntry *get(const cache_key *key); |
79672f4f | 30 | virtual void get(String const, STOREGETCLIENT, void * cbdata); |
f58bb2f4 | 31 | virtual void disconnect(StoreEntry &e); |
39c1e1d9 DK |
32 | virtual uint64_t currentSize() const; |
33 | virtual uint64_t currentCount() const; | |
34 | virtual bool doReportStat() const; | |
da9d3191 | 35 | virtual void swappedOut(const StoreEntry &e); |
9bb01611 AR |
36 | virtual void create(); |
37 | virtual void parse(int index, char *path); | |
6d8d05b5 | 38 | |
051dedf9 | 39 | int64_t entryLimitHigh() const { return SwapFilenMax; } ///< Core limit |
b3165da6 DK |
40 | int64_t entryLimitAllowed() const; |
41 | ||
902df398 DK |
42 | typedef Ipc::StoreMapWithExtras<DbCellHeader> DirMap; |
43 | ||
e2851fe7 AR |
44 | protected: |
45 | /* protected ::SwapDir API */ | |
14911a4e | 46 | virtual bool needsDiskStrand() const; |
e2851fe7 | 47 | virtual void init(); |
43ebbac3 | 48 | virtual ConfigOption *getOptionTree() const; |
24063512 | 49 | virtual bool allowOptionReconfigure(const char *const option) const; |
c728b6f9 | 50 | virtual bool canStore(const StoreEntry &e, int64_t diskSpaceNeeded, int &load) const; |
e2851fe7 AR |
51 | virtual StoreIOState::Pointer createStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); |
52 | virtual StoreIOState::Pointer openStoreIO(StoreEntry &, StoreIOState::STFNCB *, StoreIOState::STIOCB *, void *); | |
53 | virtual void maintain(); | |
e2851fe7 AR |
54 | virtual void diskFull(); |
55 | virtual void reference(StoreEntry &e); | |
54347cbd | 56 | virtual bool dereference(StoreEntry &e, bool); |
c521ad17 | 57 | virtual bool unlinkdUseful() const; |
e2851fe7 AR |
58 | virtual void unlink(StoreEntry &e); |
59 | virtual void statfs(StoreEntry &e) const; | |
60 | ||
61 | /* IORequestor API */ | |
62 | virtual void ioCompletedNotification(); | |
63 | virtual void closeCompleted(); | |
64 | virtual void readCompleted(const char *buf, int len, int errflag, RefCount< ::ReadRequest>); | |
65 | virtual void writeCompleted(int errflag, size_t len, RefCount< ::WriteRequest>); | |
66 | ||
24063512 | 67 | void parseSize(const bool reconfiguring); ///< parses anonymous cache_dir size option |
e2851fe7 | 68 | void validateOptions(); ///< warns of configuration problems; may quit |
43ebbac3 AR |
69 | bool parseTimeOption(char const *option, const char *value, int reconfiguring); |
70 | void dumpTimeOption(StoreEntry * e) const; | |
df881a0f AR |
71 | bool parseRateOption(char const *option, const char *value, int reconfiguring); |
72 | void dumpRateOption(StoreEntry * e) const; | |
e2851fe7 AR |
73 | |
74 | void rebuild(); ///< starts loading and validating stored entry metadata | |
e2851fe7 | 75 | ///< used to add entries successfully loaded during rebuild |
c728b6f9 | 76 | bool addEntry(const int fileno, const DbCellHeader &header, const StoreEntry &from); |
e2851fe7 AR |
77 | |
78 | bool full() const; ///< no more entries can be stored without purging | |
79 | void trackReferences(StoreEntry &e); ///< add to replacement policy scope | |
80 | void ignoreReferences(StoreEntry &e); ///< delete from repl policy scope | |
81 | ||
e2851fe7 AR |
82 | int64_t diskOffset(int filen) const; |
83 | int64_t diskOffsetLimit() const; | |
f1eaa254 | 84 | int entryLimit() const { return map->entryLimit(); } |
e2851fe7 AR |
85 | |
86 | friend class Rebuild; | |
87 | const char *filePath; ///< location of cache storage file inside path/ | |
88 | ||
89 | private: | |
90 | DiskIOStrategy *io; | |
91 | RefCount<DiskFile> theFile; ///< cache storage for this cache_dir | |
f1eaa254 | 92 | DirMap *map; |
b3165da6 | 93 | |
43ebbac3 AR |
94 | /* configurable options */ |
95 | DiskFile::Config fileConfig; ///< file-level configuration options | |
96 | ||
b3165da6 | 97 | static const int64_t HeaderSize; ///< on-disk db header size |
e2851fe7 AR |
98 | }; |
99 | ||
9bb01611 AR |
100 | /// initializes shared memory segments used by Rock::SwapDir |
101 | class SwapDirRr: public Ipc::Mem::RegisteredRunner | |
102 | { | |
103 | public: | |
104 | /* ::RegisteredRunner API */ | |
105 | virtual ~SwapDirRr(); | |
106 | ||
107 | protected: | |
108 | /* Ipc::Mem::RegisteredRunner API */ | |
109 | virtual void create(const RunnerRegistry &); | |
110 | ||
111 | private: | |
112 | Vector<SwapDir::DirMap::Owner *> owners; | |
113 | }; | |
114 | ||
e2851fe7 AR |
115 | } // namespace Rock |
116 | ||
117 | #endif /* SQUID_FS_ROCK_SWAP_DIR_H */ |