CernVM-FS  2.10.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
reflog.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_REFLOG_H_
6 #define CVMFS_REFLOG_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "reflog_sql.h"
12 
13 namespace manifest {
14 
15 
38 class Reflog {
39  public:
40  static Reflog *Open(const std::string &database_path);
41  static Reflog *Create(const std::string &database_path,
42  const std::string &repo_name);
43  static void HashDatabase(const std::string &database_path,
44  shash::Any *hash_reflog);
45 
46  static bool ReadChecksum(const std::string &path, shash::Any* checksum);
47  static bool WriteChecksum(const std::string &path, const shash::Any &value);
48 
49  bool AddCertificate(const shash::Any &certificate);
50  bool AddCatalog(const shash::Any &catalog);
51  bool AddHistory(const shash::Any &history);
52  bool AddMetainfo(const shash::Any &metainfo);
53 
54  uint64_t CountEntries();
56  std::vector<shash::Any> *hashes) const;
58  uint64_t timestamp,
59  std::vector<shash::Any> *hashes) const;
60 
61  bool Remove(const shash::Any &hash);
62 
63  bool ContainsCertificate(const shash::Any &certificate) const;
64  bool ContainsCatalog(const shash::Any &catalog) const;
65  bool ContainsHistory(const shash::Any &history) const;
66  bool ContainsMetainfo(const shash::Any &metainfo) const;
67 
68  bool GetCatalogTimestamp(const shash::Any &catalog,
69  uint64_t *timestamp) const;
70 
71  void BeginTransaction();
72  void CommitTransaction();
73 
76  bool OwnsDatabaseFile() const {
77  return database_.IsValid() && database_->OwnsFile();
78  }
79  bool Vacuum() { return database_->Vacuum(); }
80 
81  std::string fqrn() const;
82  std::string database_file() const;
83 
84  protected:
85  bool AddReference(const shash::Any &hash,
86  const SqlReflog::ReferenceType type);
87  bool ContainsReference(const shash::Any &hash,
88  const SqlReflog::ReferenceType type) const;
89  bool GetReferenceTimestamp(const shash::Any &hash,
90  const SqlReflog::ReferenceType type,
91  uint64_t *timestamp) const;
92 
93  private:
94  bool CreateDatabase(const std::string &database_path,
95  const std::string &repo_name);
96  bool OpenDatabase(const std::string &database_path);
97 
98  void PrepareQueries();
99 
100  private:
102 
109 };
110 
111 } // namespace manifest
112 
113 #endif // CVMFS_REFLOG_H_
bool ContainsReference(const shash::Any &hash, const SqlReflog::ReferenceType type) const
Definition: reflog.cc:260
void TakeDatabaseFileOwnership()
Definition: reflog.cc:307
void PrepareQueries()
Definition: reflog.cc:110
std::string database_file() const
Definition: reflog.cc:337
bool ContainsHistory(const shash::Any &history) const
Definition: reflog.cc:239
const manifest::Manifest * manifest() const
Definition: repository.h:123
bool AddHistory(const shash::Any &history)
Definition: reflog.cc:134
UniquePtr< ReflogDatabase > database_
Definition: reflog.h:101
bool GetCatalogTimestamp(const shash::Any &catalog, uint64_t *timestamp) const
Definition: reflog.cc:228
UniquePtr< SqlListReferences > list_references_
Definition: reflog.h:105
static bool ReadChecksum(const std::string &path, shash::Any *checksum)
Definition: reflog.cc:47
const history::History * history() const
bool AddReference(const shash::Any &hash, const SqlReflog::ReferenceType type)
Definition: reflog.cc:251
bool OwnsDatabaseFile() const
Definition: reflog.h:76
bool AddCatalog(const shash::Any &catalog)
Definition: reflog.cc:128
static Reflog * Create(const std::string &database_path, const std::string &repo_name)
Definition: reflog.cc:32
uint64_t CountEntries()
Definition: reflog.cc:146
bool ContainsMetainfo(const shash::Any &metainfo) const
Definition: reflog.cc:245
UniquePtr< SqlRemoveReference > remove_reference_
Definition: reflog.h:106
static Reflog * Open(const std::string &database_path)
Definition: reflog.cc:17
bool OpenDatabase(const std::string &database_path)
Definition: reflog.cc:96
bool AddMetainfo(const shash::Any &metainfo)
Definition: reflog.cc:140
bool Remove(const shash::Any &hash)
Definition: reflog.cc:187
UniquePtr< SqlCountReferences > count_references_
Definition: reflog.h:104
bool List(SqlReflog::ReferenceType type, std::vector< shash::Any > *hashes) const
Definition: reflog.cc:157
void BeginTransaction()
Definition: reflog.cc:295
static void HashDatabase(const std::string &database_path, shash::Any *hash_reflog)
Definition: reflog.cc:322
bool GetReferenceTimestamp(const shash::Any &hash, const SqlReflog::ReferenceType type, uint64_t *timestamp) const
Definition: reflog.cc:275
bool ListOlderThan(SqlReflog::ReferenceType type, uint64_t timestamp, std::vector< shash::Any > *hashes) const
Definition: reflog.cc:165
bool IsValid() const
Definition: pointer.h:43
void DropDatabaseFileOwnership()
Definition: reflog.cc:313
bool AddCertificate(const shash::Any &certificate)
Definition: reflog.cc:121
UniquePtr< SqlInsertReference > insert_reference_
Definition: reflog.h:103
bool ContainsCatalog(const shash::Any &catalog) const
Definition: reflog.cc:222
std::string fqrn() const
Definition: reflog.cc:331
void CommitTransaction()
Definition: reflog.cc:301
bool Vacuum()
Definition: reflog.h:79
UniquePtr< SqlContainsReference > contains_reference_
Definition: reflog.h:107
static bool WriteChecksum(const std::string &path, const shash::Any &value)
Definition: reflog.cc:64
bool ContainsCertificate(const shash::Any &certificate) const
Definition: reflog.cc:215
bool CreateDatabase(const std::string &database_path, const std::string &repo_name)
Definition: reflog.cc:80
UniquePtr< SqlGetTimestamp > get_timestamp_
Definition: reflog.h:108