Directory: | cvmfs/ |
---|---|
File: | cvmfs/receiver/catalog_merge_tool.h |
Date: | 2025-02-02 02:34:22 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 11 | 11 | 100.0% |
Branches: | 6 | 12 | 50.0% |
Line | Branch | Exec | Source |
---|---|---|---|
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 "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, | ||
41 | manifest::Manifest* manifest, | ||
42 | perf::Statistics* statistics) | ||
43 | : CatalogDiffTool<RoCatalogMgr>(old_catalog_mgr, new_catalog_mgr), | ||
44 | repo_path_(""), | ||
45 | cache_dir_(""), | ||
46 | lease_path_(lease_path), | ||
47 | temp_dir_prefix_(temp_dir_prefix), | ||
48 | download_manager_(NULL), | ||
49 | manifest_(manifest), | ||
50 | output_catalog_mgr_(output_catalog_mgr), | ||
51 | needs_setup_(false), | ||
52 | statistics_(statistics), | ||
53 | counters_(NULL) {} | ||
54 | |||
55 | CatalogMergeTool(RoCatalogMgr* old_catalog_mgr, RoCatalogMgr* new_catalog_mgr, | ||
56 | const std::string& repo_path, | ||
57 | const PathString& lease_path, | ||
58 | const std::string& temp_dir_prefix, | ||
59 | download::DownloadManager* download_manager, | ||
60 | manifest::Manifest* manifest, | ||
61 | perf::Statistics* statistics) | ||
62 | : CatalogDiffTool<RoCatalogMgr>(old_catalog_mgr, new_catalog_mgr), | ||
63 | repo_path_(repo_path), | ||
64 | cache_dir_(""), | ||
65 | lease_path_(lease_path), | ||
66 | temp_dir_prefix_(temp_dir_prefix), | ||
67 | download_manager_(download_manager), | ||
68 | manifest_(manifest), | ||
69 | needs_setup_(true), | ||
70 | statistics_(statistics), | ||
71 | counters_(NULL) {} | ||
72 | |||
73 | 2 | CatalogMergeTool(const std::string& repo_path, | |
74 | const shash::Any& old_root_hash, | ||
75 | const shash::Any& new_root_hash, | ||
76 | const PathString& lease_path, | ||
77 | const std::string& temp_dir_prefix, | ||
78 | download::DownloadManager* download_manager, | ||
79 | manifest::Manifest* manifest, | ||
80 | perf::Statistics* statistics, | ||
81 | const std::string& cache_dir) | ||
82 | : CatalogDiffTool<RoCatalogMgr>(repo_path, | ||
83 | old_root_hash, new_root_hash, | ||
84 | temp_dir_prefix, download_manager, | ||
85 | cache_dir), | ||
86 | 2 | repo_path_(repo_path), | |
87 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | cache_dir_(cache_dir), |
88 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | lease_path_(lease_path), |
89 |
1/2✓ Branch 1 taken 2 times.
✗ Branch 2 not taken.
|
2 | temp_dir_prefix_(temp_dir_prefix), |
90 | 2 | download_manager_(download_manager), | |
91 | 2 | manifest_(manifest), | |
92 | 2 | needs_setup_(true), | |
93 | 2 | statistics_(statistics), | |
94 |
3/6✓ Branch 2 taken 2 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 2 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 2 times.
✗ Branch 9 not taken.
|
4 | counters_(NULL) {} |
95 | |||
96 | 4 | virtual ~CatalogMergeTool() {} | |
97 | |||
98 | bool Run(const Params& params, std::string* new_manifest_path, shash::Any* new_manifest_hash, | ||
99 | uint64_t *final_rev); | ||
100 | |||
101 | protected: | ||
102 | virtual bool IsIgnoredPath(const PathString& path); | ||
103 | virtual bool IsReportablePath(const PathString& path); | ||
104 | |||
105 | virtual void ReportAddition(const PathString& path, | ||
106 | const catalog::DirectoryEntry& entry, | ||
107 | const XattrList& xattrs, | ||
108 | const FileChunkList& chunks); | ||
109 | virtual void ReportRemoval(const PathString& path, | ||
110 | const catalog::DirectoryEntry& entry); | ||
111 | virtual bool ReportModification(const PathString& path, | ||
112 | const catalog::DirectoryEntry& old_entry, | ||
113 | const catalog::DirectoryEntry& new_entry, | ||
114 | const XattrList& xattrs, | ||
115 | const FileChunkList& chunks); | ||
116 | |||
117 | private: | ||
118 | bool CreateNewManifest(std::string* new_manifest_path); | ||
119 | |||
120 | std::string repo_path_; | ||
121 | const std::string cache_dir_; // path if local cache is used, otherwise empty | ||
122 | |||
123 | PathString lease_path_; | ||
124 | std::string temp_dir_prefix_; | ||
125 | |||
126 | download::DownloadManager* download_manager_; | ||
127 | |||
128 | manifest::Manifest* manifest_; | ||
129 | |||
130 | UniquePtr<RwCatalogMgr> output_catalog_mgr_; | ||
131 | |||
132 | const bool needs_setup_; | ||
133 | |||
134 | perf::Statistics *statistics_; | ||
135 | UniquePtr<perf::FsCounters> counters_; | ||
136 | }; | ||
137 | |||
138 | } // namespace receiver | ||
139 | |||
140 | #include "catalog_merge_tool_impl.h" | ||
141 | |||
142 | #endif // CVMFS_RECEIVER_CATALOG_MERGE_TOOL_H_ | ||
143 |