CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
catalog_merge_tool.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_RECEIVER_CATALOG_MERGE_TOOL_H_
6 #define CVMFS_RECEIVER_CATALOG_MERGE_TOOL_H_
7 
8 #include <string>
9 
10 #include "catalog_diff_tool.h"
11 #include "file_chunk.h"
12 #include "params.h"
13 #include "statistics.h"
14 #include "util/pointer.h"
15 
16 namespace catalog {
17 class WritableCatalogManager;
18 }
19 
20 namespace download {
21 class DownloadManager;
22 }
23 
24 namespace manifest {
25 class Manifest;
26 }
27 
28 namespace shash {
29 struct Any;
30 }
31 
32 namespace receiver {
33 
34 template <typename RwCatalogMgr, typename RoCatalogMgr>
35 class CatalogMergeTool : public CatalogDiffTool<RoCatalogMgr> {
36  public:
37  CatalogMergeTool(RoCatalogMgr* old_catalog_mgr, RoCatalogMgr* new_catalog_mgr,
38  RwCatalogMgr* output_catalog_mgr,
39  const PathString& lease_path,
40  const std::string& temp_dir_prefix,
42  perf::Statistics* statistics)
43  : CatalogDiffTool<RoCatalogMgr>(old_catalog_mgr, new_catalog_mgr),
44  repo_path_(""),
45  lease_path_(lease_path),
46  temp_dir_prefix_(temp_dir_prefix),
47  download_manager_(NULL),
48  manifest_(manifest),
49  output_catalog_mgr_(output_catalog_mgr),
50  needs_setup_(false),
51  statistics_(statistics),
52  counters_(NULL) {}
53 
54  CatalogMergeTool(RoCatalogMgr* old_catalog_mgr, RoCatalogMgr* new_catalog_mgr,
55  const std::string& repo_path,
56  const PathString& lease_path,
57  const std::string& temp_dir_prefix,
58  download::DownloadManager* download_manager,
60  perf::Statistics* statistics)
61  : CatalogDiffTool<RoCatalogMgr>(old_catalog_mgr, new_catalog_mgr),
62  repo_path_(repo_path),
63  lease_path_(lease_path),
64  temp_dir_prefix_(temp_dir_prefix),
65  download_manager_(download_manager),
66  manifest_(manifest),
67  needs_setup_(true),
68  statistics_(statistics),
69  counters_(NULL) {}
70 
71  CatalogMergeTool(const std::string& repo_path,
72  const shash::Any& old_root_hash,
73  const shash::Any& new_root_hash,
74  const PathString& lease_path,
75  const std::string& temp_dir_prefix,
76  download::DownloadManager* download_manager,
78  perf::Statistics* statistics)
79  : CatalogDiffTool<RoCatalogMgr>(repo_path, old_root_hash, new_root_hash,
80  temp_dir_prefix, download_manager),
81  repo_path_(repo_path),
82  lease_path_(lease_path),
83  temp_dir_prefix_(temp_dir_prefix),
84  download_manager_(download_manager),
85  manifest_(manifest),
86  needs_setup_(true),
87  statistics_(statistics),
88  counters_(NULL) {}
89 
90  virtual ~CatalogMergeTool() {}
91 
92  bool Run(const Params& params, std::string* new_manifest_path,
93  uint64_t *final_rev);
94 
95  protected:
96  virtual bool IsIgnoredPath(const PathString& path);
97  virtual bool IsReportablePath(const PathString& path);
98 
99  virtual void ReportAddition(const PathString& path,
100  const catalog::DirectoryEntry& entry,
101  const XattrList& xattrs,
102  const FileChunkList& chunks);
103  virtual void ReportRemoval(const PathString& path,
104  const catalog::DirectoryEntry& entry);
105  virtual bool ReportModification(const PathString& path,
106  const catalog::DirectoryEntry& old_entry,
107  const catalog::DirectoryEntry& new_entry,
108  const XattrList& xattrs,
109  const FileChunkList& chunks);
110 
111  private:
112  bool CreateNewManifest(std::string* new_manifest_path);
113 
114  std::string repo_path_;
115 
117  std::string temp_dir_prefix_;
118 
120 
122 
124 
125  const bool needs_setup_;
126 
129 };
130 
131 } // namespace receiver
132 
133 #include "catalog_merge_tool_impl.h"
134 
135 #endif // CVMFS_RECEIVER_CATALOG_MERGE_TOOL_H_
UniquePtr< RwCatalogMgr > output_catalog_mgr_
const manifest::Manifest * manifest() const
Definition: repository.h:123
virtual bool ReportModification(const PathString &path, const catalog::DirectoryEntry &old_entry, const catalog::DirectoryEntry &new_entry, const XattrList &xattrs, const FileChunkList &chunks)
perf::Statistics * statistics_
CatalogMergeTool(RoCatalogMgr *old_catalog_mgr, RoCatalogMgr *new_catalog_mgr, const std::string &repo_path, const PathString &lease_path, const std::string &temp_dir_prefix, download::DownloadManager *download_manager, manifest::Manifest *manifest, perf::Statistics *statistics)
UniquePtr< perf::FsCounters > counters_
CatalogMergeTool(RoCatalogMgr *old_catalog_mgr, RoCatalogMgr *new_catalog_mgr, RwCatalogMgr *output_catalog_mgr, const PathString &lease_path, const std::string &temp_dir_prefix, manifest::Manifest *manifest, perf::Statistics *statistics)
virtual bool IsReportablePath(const PathString &path)
download::DownloadManager * download_manager_
bool Run(const Params &params, std::string *new_manifest_path, uint64_t *final_rev)
CatalogMergeTool(const std::string &repo_path, const shash::Any &old_root_hash, const shash::Any &new_root_hash, const PathString &lease_path, const std::string &temp_dir_prefix, download::DownloadManager *download_manager, manifest::Manifest *manifest, perf::Statistics *statistics)
virtual bool IsIgnoredPath(const PathString &path)
manifest::Manifest * manifest_
bool CreateNewManifest(std::string *new_manifest_path)
virtual void ReportAddition(const PathString &path, const catalog::DirectoryEntry &entry, const XattrList &xattrs, const FileChunkList &chunks)
virtual void ReportRemoval(const PathString &path, const catalog::DirectoryEntry &entry)