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