CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
manifest.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_MANIFEST_H_
6 #define CVMFS_MANIFEST_H_
7 
8 #include <stdint.h>
9 
10 #include <map>
11 #include <string>
12 
13 #include "hash.h"
14 #include "history.h"
15 
16 namespace manifest {
17 
22 struct Breadcrumb {
24  Breadcrumb(const shash::Any &h, uint64_t t) : catalog_hash(h), timestamp(t) {}
25  explicit Breadcrumb(const std::string &from_string);
26 
27  bool Export(const std::string &fqrn,
28  const std::string &directory, const int mode) const;
29  std::string ToString() const;
30  bool IsValid() const { return !catalog_hash.IsNull() && (timestamp > 0); }
31 
33  uint64_t timestamp;
34 };
35 
36 
41 class Manifest {
42  public:
43  static Manifest *LoadFile(const std::string &path);
44  static Manifest *LoadMem(const unsigned char *buffer, const unsigned length);
46  const uint64_t catalog_size,
47  const std::string &root_path);
48  Manifest(const shash::Any &catalog_hash,
49  const uint64_t catalog_size,
50  const shash::Md5 &root_path,
51  const uint32_t ttl,
52  const uint64_t revision,
53  const shash::Any &micro_catalog_hash,
54  const std::string &repository_name,
55  const shash::Any certificate,
56  const shash::Any history,
57  const uint64_t publish_timestamp,
58  const bool garbage_collectable,
59  const bool has_alt_catalog_path,
60  const shash::Any &meta_info,
61  const shash::Any &reflog_hash)
62  : catalog_hash_(catalog_hash)
63  , catalog_size_(catalog_size)
64  , root_path_(root_path)
65  , ttl_(ttl)
66  , revision_(revision)
67  , micro_catalog_hash_(micro_catalog_hash)
68  , repository_name_(repository_name)
69  , certificate_(certificate)
70  , history_(history)
71  , publish_timestamp_(publish_timestamp)
72  , garbage_collectable_(garbage_collectable)
73  , has_alt_catalog_path_(has_alt_catalog_path)
74  , meta_info_(meta_info)
75  , reflog_hash_(reflog_hash) {}
76 
77  std::string ExportString() const;
78  bool Export(const std::string &path) const;
79  bool ExportBreadcrumb(const std::string &directory, const int mode) const;
80  static Breadcrumb ReadBreadcrumb(const std::string &repo_name,
81  const std::string &directory);
82 
84 
85  void set_ttl(const uint32_t ttl) { ttl_ = ttl; }
86  void set_revision(const uint64_t revision) { revision_ = revision; }
89  }
90  void set_history(const shash::Any &history_db) {
91  history_ = history_db;
92  }
93  void set_repository_name(const std::string &repository_name) {
95  }
98  }
99  void set_catalog_size(const uint64_t catalog_size) {
101  }
102  void set_catalog_hash(const shash::Any &catalog_hash) {
104  }
107  }
108  void set_has_alt_catalog_path(const bool &has_alt_path) {
109  has_alt_catalog_path_ = has_alt_path;
110  }
113  }
114  void set_root_path(const std::string &root_path) {
115  root_path_ = shash::Md5(shash::AsciiPtr(root_path));
116  }
117  void set_reflog_hash(const shash::Any& checksum) {
118  reflog_hash_ = checksum;
119  }
120 
121  uint64_t revision() const { return revision_; }
122  std::string repository_name() const { return repository_name_; }
123  shash::Md5 root_path() const { return root_path_; }
125  uint64_t catalog_size() const { return catalog_size_; }
126  shash::Any certificate() const { return certificate_; }
127  shash::Any history() const { return history_; }
128  uint64_t publish_timestamp() const { return publish_timestamp_; }
129  bool garbage_collectable() const { return garbage_collectable_; }
131  shash::Any meta_info() const { return meta_info_; }
132  shash::Any reflog_hash() const { return reflog_hash_; }
133 
134  std::string MakeCatalogPath() const {
136  ("data/" + catalog_hash_.MakePath());
137  }
138 
139  std::string MakeCertificatePath() const {
140  return has_alt_catalog_path_ ?
142  }
143 
144  private:
145  static Manifest *Load(const std::map<char, std::string> &content);
147  uint64_t catalog_size_;
149  uint32_t ttl_;
150  uint64_t revision_;
152  std::string repository_name_;
157 
164 
170 
175 }; // class Manifest
176 
177 } // namespace manifest
178 
179 #endif // CVMFS_MANIFEST_H_
void set_repository_name(const std::string &repository_name)
Definition: manifest.h:93
bool IsNull() const
Definition: hash.h:379
shash::Any micro_catalog_hash_
Definition: manifest.h:151
const manifest::Manifest * manifest() const
Definition: repository.h:123
bool Export(const std::string &path) const
Definition: manifest.cc:209
static Manifest * LoadMem(const unsigned char *buffer, const unsigned length)
Definition: manifest.cc:68
uint64_t timestamp
Definition: manifest.h:33
void set_catalog_hash(const shash::Any &catalog_hash)
Definition: manifest.h:102
std::string MakeAlternativePath() const
Definition: hash.h:321
shash::Any meta_info_
Definition: manifest.h:169
shash::Any catalog_hash
Definition: manifest.h:32
shash::Any certificate_
Definition: manifest.h:153
shash::Md5 root_path_
Definition: manifest.h:148
Manifest(const shash::Any &catalog_hash, const uint64_t catalog_size, const std::string &root_path)
void set_certificate(const shash::Any &certificate)
Definition: manifest.h:87
bool garbage_collectable_
Definition: manifest.h:156
void set_meta_info(const shash::Any &meta_info)
Definition: manifest.h:111
std::string ExportString() const
Definition: manifest.cc:174
void set_revision(const uint64_t revision)
Definition: manifest.h:86
shash::Any reflog_hash_
Definition: manifest.h:174
std::string MakeCertificatePath() const
Definition: manifest.h:139
bool has_alt_catalog_path() const
Definition: manifest.h:130
Algorithms algorithm
Definition: hash.h:123
uint64_t catalog_size() const
Definition: manifest.h:125
uint64_t revision() const
Definition: manifest.h:121
Algorithms
Definition: hash.h:39
uint64_t revision_
Definition: manifest.h:150
bool ExportBreadcrumb(const std::string &directory, const int mode) const
Definition: manifest.cc:232
uint64_t publish_timestamp() const
Definition: manifest.h:128
std::string repository_name() const
Definition: manifest.h:122
void set_publish_timestamp(const uint32_t publish_timestamp)
Definition: manifest.h:96
shash::Any certificate() const
Definition: manifest.h:126
shash::Any catalog_hash() const
Definition: manifest.h:124
bool garbage_collectable() const
Definition: manifest.h:129
bool has_alt_catalog_path_
Definition: manifest.h:163
bool Export(const std::string &fqrn, const std::string &directory, const int mode) const
Definition: manifest.cc:36
std::string repository_name_
Definition: manifest.h:152
void set_history(const shash::Any &history_db)
Definition: manifest.h:90
void set_garbage_collectability(const bool garbage_collectable)
Definition: manifest.h:105
void set_ttl(const uint32_t ttl)
Definition: manifest.h:85
shash::Algorithms GetHashAlgorithm() const
Definition: manifest.h:83
std::string ToString() const
Definition: manifest.cc:60
shash::Any history() const
Definition: manifest.h:127
void set_catalog_size(const uint64_t catalog_size)
Definition: manifest.h:99
shash::Md5 root_path() const
Definition: manifest.h:123
bool IsValid() const
Definition: manifest.h:30
std::string MakeCatalogPath() const
Definition: manifest.h:134
Manifest(const shash::Any &catalog_hash, const uint64_t catalog_size, const shash::Md5 &root_path, const uint32_t ttl, const uint64_t revision, const shash::Any &micro_catalog_hash, const std::string &repository_name, const shash::Any certificate, const shash::Any history, const uint64_t publish_timestamp, const bool garbage_collectable, const bool has_alt_catalog_path, const shash::Any &meta_info, const shash::Any &reflog_hash)
Definition: manifest.h:48
static Breadcrumb ReadBreadcrumb(const std::string &repo_name, const std::string &directory)
Definition: manifest.cc:242
void set_has_alt_catalog_path(const bool &has_alt_path)
Definition: manifest.h:108
shash::Any catalog_hash_
Definition: manifest.h:146
shash::Any reflog_hash() const
Definition: manifest.h:132
shash::Any history_
Definition: manifest.h:154
std::string MakePath() const
Definition: hash.h:312
uint64_t publish_timestamp_
Definition: manifest.h:155
void set_reflog_hash(const shash::Any &checksum)
Definition: manifest.h:117
uint64_t catalog_size_
Definition: manifest.h:147
static Manifest * LoadFile(const std::string &path)
Definition: manifest.cc:78
Breadcrumb(const shash::Any &h, uint64_t t)
Definition: manifest.h:24
static Manifest * Load(const std::map< char, std::string > &content)
Definition: manifest.cc:87
shash::Any meta_info() const
Definition: manifest.h:131
void set_root_path(const std::string &root_path)
Definition: manifest.h:114