1 |
|
|
/** |
2 |
|
|
* This file is part of the CernVM File System. |
3 |
|
|
*/ |
4 |
|
|
|
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 "util/pointer.h" |
14 |
|
|
|
15 |
|
|
namespace catalog { |
16 |
|
|
class WritableCatalogManager; |
17 |
|
|
} |
18 |
|
|
|
19 |
|
|
namespace download { |
20 |
|
|
class DownloadManager; |
21 |
|
|
} |
22 |
|
|
|
23 |
|
|
namespace manifest { |
24 |
|
|
class Manifest; |
25 |
|
|
} |
26 |
|
|
|
27 |
|
|
namespace shash { |
28 |
|
|
struct Any; |
29 |
|
|
} |
30 |
|
|
|
31 |
|
|
namespace receiver { |
32 |
|
|
|
33 |
|
|
template <typename RwCatalogMgr, typename RoCatalogMgr> |
34 |
|
|
class CatalogMergeTool : public CatalogDiffTool<RoCatalogMgr> { |
35 |
|
|
public: |
36 |
|
|
CatalogMergeTool(RoCatalogMgr* old_catalog_mgr, RoCatalogMgr* new_catalog_mgr, |
37 |
|
|
RwCatalogMgr* output_catalog_mgr, |
38 |
|
|
const PathString& lease_path, |
39 |
|
|
const std::string& temp_dir_prefix, |
40 |
|
|
manifest::Manifest* manifest) |
41 |
|
|
: CatalogDiffTool<RoCatalogMgr>(old_catalog_mgr, new_catalog_mgr), |
42 |
|
|
repo_path_(""), |
43 |
|
|
lease_path_(lease_path), |
44 |
|
|
temp_dir_prefix_(temp_dir_prefix), |
45 |
|
|
download_manager_(NULL), |
46 |
|
|
manifest_(manifest), |
47 |
|
|
output_catalog_mgr_(output_catalog_mgr), |
48 |
|
|
needs_setup_(false) {} |
49 |
|
|
|
50 |
|
|
CatalogMergeTool(RoCatalogMgr* old_catalog_mgr, RoCatalogMgr* new_catalog_mgr, |
51 |
|
|
const std::string& repo_path, |
52 |
|
|
const PathString& lease_path, |
53 |
|
|
const std::string& temp_dir_prefix, |
54 |
|
|
download::DownloadManager* download_manager, |
55 |
|
|
manifest::Manifest* manifest) |
56 |
|
|
: CatalogDiffTool<RoCatalogMgr>(old_catalog_mgr, new_catalog_mgr), |
57 |
|
|
repo_path_(repo_path), |
58 |
|
|
lease_path_(lease_path), |
59 |
|
|
temp_dir_prefix_(temp_dir_prefix), |
60 |
|
|
download_manager_(download_manager), |
61 |
|
|
manifest_(manifest), |
62 |
|
|
needs_setup_(true) {} |
63 |
|
|
|
64 |
|
1 |
CatalogMergeTool(const std::string& repo_path, |
65 |
|
|
const shash::Any& old_root_hash, |
66 |
|
|
const shash::Any& new_root_hash, |
67 |
|
|
const PathString& lease_path, |
68 |
|
|
const std::string& temp_dir_prefix, |
69 |
|
|
download::DownloadManager* download_manager, |
70 |
|
|
manifest::Manifest* manifest) |
71 |
|
|
: CatalogDiffTool<RoCatalogMgr>(repo_path, old_root_hash, new_root_hash, |
72 |
|
|
temp_dir_prefix, download_manager), |
73 |
|
|
repo_path_(repo_path), |
74 |
|
|
lease_path_(lease_path), |
75 |
|
|
temp_dir_prefix_(temp_dir_prefix), |
76 |
|
|
download_manager_(download_manager), |
77 |
|
|
manifest_(manifest), |
78 |
|
1 |
needs_setup_(true) {} |
79 |
|
|
|
80 |
✗✓ |
1 |
virtual ~CatalogMergeTool() {} |
81 |
|
|
|
82 |
|
|
bool Run(const Params& params, std::string* new_manifest_path); |
83 |
|
|
|
84 |
|
|
protected: |
85 |
|
|
virtual void ReportAddition(const PathString& path, |
86 |
|
|
const catalog::DirectoryEntry& entry, |
87 |
|
|
const XattrList& xattrs, |
88 |
|
|
const FileChunkList& chunks); |
89 |
|
|
virtual void ReportRemoval(const PathString& path, |
90 |
|
|
const catalog::DirectoryEntry& entry); |
91 |
|
|
virtual void ReportModification(const PathString& path, |
92 |
|
|
const catalog::DirectoryEntry& old_entry, |
93 |
|
|
const catalog::DirectoryEntry& new_entry, |
94 |
|
|
const XattrList& xattrs, |
95 |
|
|
const FileChunkList& chunks); |
96 |
|
|
|
97 |
|
|
private: |
98 |
|
|
bool CreateNewManifest(std::string* new_manifest_path); |
99 |
|
|
|
100 |
|
|
std::string repo_path_; |
101 |
|
|
|
102 |
|
|
PathString lease_path_; |
103 |
|
|
std::string temp_dir_prefix_; |
104 |
|
|
|
105 |
|
|
download::DownloadManager* download_manager_; |
106 |
|
|
|
107 |
|
|
manifest::Manifest* manifest_; |
108 |
|
|
|
109 |
|
|
UniquePtr<RwCatalogMgr> output_catalog_mgr_; |
110 |
|
|
|
111 |
|
|
const bool needs_setup_; |
112 |
|
|
}; |
113 |
|
|
|
114 |
|
|
} // namespace receiver |
115 |
|
|
|
116 |
|
|
#include "catalog_merge_tool_impl.h" |
117 |
|
|
|
118 |
|
|
#endif // CVMFS_RECEIVER_CATALOG_MERGE_TOOL_H_ |