CernVM-FS  2.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
catalog_diff_tool.h
Go to the documentation of this file.
1 
5 #ifndef CVMFS_CATALOG_DIFF_TOOL_H_
6 #define CVMFS_CATALOG_DIFF_TOOL_H_
7 
8 #include <string>
9 
10 #include "directory_entry.h"
11 #include "file_chunk.h"
12 #include "shortstring.h"
13 #include "statistics.h"
14 #include "util/pointer.h"
15 #include "util/raii_temp_dir.h"
16 #include "xattr.h"
17 
18 namespace download {
19 class DownloadManager;
20 }
21 
22 template <typename RoCatalogMgr>
24  public:
25  CatalogDiffTool(RoCatalogMgr* old_catalog_mgr, RoCatalogMgr* new_catalog_mgr)
26  : repo_path_(""),
27  temp_dir_prefix_(""),
28  download_manager_(NULL),
29  old_catalog_mgr_(old_catalog_mgr),
30  new_catalog_mgr_(new_catalog_mgr),
31  needs_setup_(false) {}
32 
33  CatalogDiffTool(const std::string& repo_path, const shash::Any& old_root_hash,
34  const shash::Any& new_root_hash,
35  const std::string& temp_dir_prefix,
36  download::DownloadManager* download_manager)
37  : repo_path_(repo_path),
38  old_root_hash_(old_root_hash),
39  new_root_hash_(new_root_hash),
40  temp_dir_prefix_(temp_dir_prefix),
41  download_manager_(download_manager),
46  needs_setup_(true) {}
47 
48  virtual ~CatalogDiffTool() {}
49 
50  bool Init();
51 
52  bool Run(const PathString& path);
53 
54  protected:
63  virtual bool IsIgnoredPath(const PathString& path) { return false; }
64 
88  virtual bool IsReportablePath(const PathString& path) { return true; }
89 
90  virtual void ReportAddition(const PathString& path,
91  const catalog::DirectoryEntry& entry,
92  const XattrList& xattrs,
93  const FileChunkList& chunks) = 0;
94  virtual void ReportRemoval(const PathString& path,
95  const catalog::DirectoryEntry& entry) = 0;
96  virtual bool ReportModification(const PathString& path,
97  const catalog::DirectoryEntry& old_entry,
98  const catalog::DirectoryEntry& new_entry,
99  const XattrList& xattrs,
100  const FileChunkList& chunks) = 0;
101 
103  return old_catalog_mgr_->GetRootCatalog();
104  }
106  return new_catalog_mgr_->GetRootCatalog();
107  }
108  RoCatalogMgr* GetOldCatalogMgr() {
109  return old_catalog_mgr_.weak_ref();
110  }
111  RoCatalogMgr* GetNewCatalogMgr() {
112  return new_catalog_mgr_.weak_ref();
113  }
114 
115  private:
116  RoCatalogMgr* OpenCatalogManager(const std::string& repo_path,
117  const std::string& temp_dir,
118  const shash::Any& root_hash,
119  download::DownloadManager* download_manager,
120  perf::Statistics* stats);
121 
122  void DiffRec(const PathString& path);
123 
124  std::string repo_path_;
127  std::string temp_dir_prefix_;
128 
130 
133 
136 
139 
140  const bool needs_setup_;
141 };
142 
143 #include "catalog_diff_tool_impl.h"
144 
145 #endif // CVMFS_CATALOG_DIFF_TOOL_H_
download::DownloadManager * download_manager_
UniquePtr< RoCatalogMgr > new_catalog_mgr_
perf::Statistics stats_new_
std::string temp_dir_prefix_
virtual ~CatalogDiffTool()
const catalog::Catalog * GetNewCatalog() const
T * weak_ref() const
Definition: pointer.h:42
virtual bool IsIgnoredPath(const PathString &path)
void DiffRec(const PathString &path)
UniquePtr< RoCatalogMgr > old_catalog_mgr_
virtual void ReportAddition(const PathString &path, const catalog::DirectoryEntry &entry, const XattrList &xattrs, const FileChunkList &chunks)=0
shash::Any old_root_hash_
RoCatalogMgr * OpenCatalogManager(const std::string &repo_path, const std::string &temp_dir, const shash::Any &root_hash, download::DownloadManager *download_manager, perf::Statistics *stats)
std::string repo_path_
virtual bool ReportModification(const PathString &path, const catalog::DirectoryEntry &old_entry, const catalog::DirectoryEntry &new_entry, const XattrList &xattrs, const FileChunkList &chunks)=0
RoCatalogMgr * GetNewCatalogMgr()
RoCatalogMgr * GetOldCatalogMgr()
UniquePtr< RaiiTempDir > new_raii_temp_dir_
perf::Statistics stats_old_
const bool needs_setup_
virtual void ReportRemoval(const PathString &path, const catalog::DirectoryEntry &entry)=0
shash::Any new_root_hash_
bool Run(const PathString &path)
const catalog::Catalog * GetOldCatalog() const
CatalogDiffTool(const std::string &repo_path, const shash::Any &old_root_hash, const shash::Any &new_root_hash, const std::string &temp_dir_prefix, download::DownloadManager *download_manager)
CatalogDiffTool(RoCatalogMgr *old_catalog_mgr, RoCatalogMgr *new_catalog_mgr)
UniquePtr< RaiiTempDir > old_raii_temp_dir_
virtual bool IsReportablePath(const PathString &path)