CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
cache_tiered.h
Go to the documentation of this file.
1 
7 #ifndef CVMFS_CACHE_TIERED_H_
8 #define CVMFS_CACHE_TIERED_H_
9 
10 #include <string>
11 
12 #include "cache.h"
13 #include "gtest/gtest_prod.h"
14 
27  FRIEND_TEST(T_MountPoint, TieredCacheMgr);
28  FRIEND_TEST(T_MountPoint, TieredComplex);
29 
30  public:
31  virtual CacheManagerIds id() { return kTieredCacheManager; }
32  virtual std::string Describe();
33 
34  static CacheManager *Create(CacheManager *upper_cache,
35  CacheManager *lower_cache);
36  void SetLowerReadOnly() { lower_readonly_ = true; }
37 
38  virtual ~TieredCacheManager();
40  bool result = upper_->AcquireQuotaManager(quota_mgr);
42  return result;
43  }
44 
45  virtual int Open(const BlessedObject &object);
46  virtual int64_t GetSize(int fd) {return upper_->GetSize(fd);}
47  virtual int Close(int fd) {return upper_->Close(fd);}
48  virtual int64_t Pread(int fd, void *buf, uint64_t size, uint64_t offset)
49  { return upper_->Pread(fd, buf, size, offset); }
50  virtual int Dup(int fd) { return upper_->Dup(fd); }
51  virtual int Readahead(int fd) { return upper_->Readahead(fd); }
52 
53  virtual uint32_t SizeOfTxn()
54  { return upper_->SizeOfTxn() + lower_->SizeOfTxn(); }
55  virtual int StartTxn(const shash::Any &id, uint64_t size, void *txn);
56  virtual void CtrlTxn(const ObjectInfo &object_info,
57  const int flags,
58  void *txn);
59  virtual int64_t Write(const void *buf, uint64_t size, void *txn);
60  virtual int Reset(void *txn);
61  virtual int OpenFromTxn(void *txn) { return upper_->OpenFromTxn(txn); }
62  virtual int AbortTxn(void *txn);
63  virtual int CommitTxn(void *txn);
64  virtual void Spawn();
65 
66  virtual manifest::Breadcrumb LoadBreadcrumb(const std::string &fqrn);
67  virtual bool StoreBreadcrumb(const manifest::Manifest &manifest);
68 
69  protected:
70  virtual void *DoSaveState();
71  virtual int DoRestoreState(void *data);
72  virtual bool DoFreeState(void *data);
73 
74  private:
75  static const unsigned kCopyBufferSize = 64 * 1024; // 64kB
76 
77  struct SavedState {
78  SavedState() : state_upper(NULL), state_lower(NULL) { }
79  void *state_upper;
80  void *state_lower;
81  };
82 
83  // NOTE: TieredCacheManager takes ownership of both caches passed.
85  CacheManager *lower_cache)
86  : upper_(upper_cache), lower_(lower_cache), lower_readonly_(false) { }
87 
91 }; // class TieredCacheManager
92 
93 #endif // CVMFS_CACHE_TIERED_H_
virtual CacheManagerIds id()
Definition: cache_tiered.h:31
const manifest::Manifest * manifest() const
Definition: repository.h:123
virtual int64_t GetSize(int fd)=0
virtual int AbortTxn(void *txn)
virtual int Dup(int fd)
Definition: cache_tiered.h:50
virtual int Open(const BlessedObject &object)
Definition: cache_tiered.cc:51
virtual int OpenFromTxn(void *txn)
Definition: cache_tiered.h:61
virtual int64_t Pread(int fd, void *buf, uint64_t size, uint64_t offset)
Definition: cache_tiered.h:48
FRIEND_TEST(T_MountPoint, TieredCacheMgr)
virtual bool DoFreeState(void *data)
Definition: cache_tiered.cc:24
virtual void * DoSaveState()
Definition: cache_tiered.cc:43
virtual std::string Describe()
Definition: cache_tiered.cc:17
TieredCacheManager(CacheManager *upper_cache, CacheManager *lower_cache)
Definition: cache_tiered.h:84
virtual int Reset(void *txn)
static CacheManager * Create(CacheManager *upper_cache, CacheManager *lower_cache)
virtual uint32_t SizeOfTxn()
Definition: cache_tiered.h:53
virtual int OpenFromTxn(void *txn)=0
virtual int64_t GetSize(int fd)
Definition: cache_tiered.h:46
CacheManagerIds
Definition: cache.h:23
virtual int CommitTxn(void *txn)
virtual int DoRestoreState(void *data)
Definition: cache_tiered.cc:33
virtual int Close(int fd)=0
virtual int64_t Write(const void *buf, uint64_t size, void *txn)
CacheManager * lower_
Definition: cache_tiered.h:89
virtual int Close(int fd)
Definition: cache_tiered.h:47
virtual void CtrlTxn(const ObjectInfo &object_info, const int flags, void *txn)
CacheManager * upper_
Definition: cache_tiered.h:88
QuotaManager * quota_mgr()
Definition: cache.h:198
virtual int Readahead(int fd)
Definition: cache_tiered.h:51
static const unsigned kCopyBufferSize
Definition: cache_tiered.h:75
virtual int StartTxn(const shash::Any &id, uint64_t size, void *txn)
QuotaManager * quota_mgr_
Definition: cache.h:237
virtual uint32_t SizeOfTxn()=0
virtual int Dup(int fd)=0
virtual bool AcquireQuotaManager(QuotaManager *quota_mgr)
Definition: cache_tiered.h:39
virtual int Readahead(int fd)=0
virtual manifest::Breadcrumb LoadBreadcrumb(const std::string &fqrn)
virtual bool AcquireQuotaManager(QuotaManager *quota_mgr)=0
virtual ~TieredCacheManager()
virtual void Spawn()
static void size_t size
Definition: smalloc.h:47
virtual int64_t Pread(int fd, void *buf, uint64_t size, uint64_t offset)=0
virtual bool StoreBreadcrumb(const manifest::Manifest &manifest)