checkpoint_impl.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
  2. // This source code is licensed under both the GPLv2 (found in the
  3. // COPYING file in the root directory) and Apache 2.0 License
  4. // (found in the LICENSE.Apache file in the root directory).
  5. #pragma once
  6. #include <string>
  7. #include "file/filename.h"
  8. #include "rocksdb/db.h"
  9. #include "rocksdb/utilities/checkpoint.h"
  10. namespace ROCKSDB_NAMESPACE {
  11. class CheckpointImpl : public Checkpoint {
  12. public:
  13. explicit CheckpointImpl(DB* db) : db_(db) {}
  14. Status CreateCheckpoint(const std::string& checkpoint_dir,
  15. uint64_t log_size_for_flush,
  16. uint64_t* sequence_number_ptr) override;
  17. Status ExportColumnFamily(ColumnFamilyHandle* handle,
  18. const std::string& export_dir,
  19. ExportImportFilesMetaData** metadata) override;
  20. // Checkpoint logic can be customized by providing callbacks for link, copy,
  21. // or create.
  22. Status CreateCustomCheckpoint(
  23. std::function<Status(const std::string& src_dirname,
  24. const std::string& fname, FileType type)>
  25. link_file_cb,
  26. std::function<Status(const std::string& src_dirname,
  27. const std::string& fname, uint64_t size_limit_bytes,
  28. FileType type, const std::string& checksum_func_name,
  29. const std::string& checksum_val,
  30. const Temperature src_temperature)>
  31. copy_file_cb,
  32. std::function<Status(const std::string& fname,
  33. const std::string& contents, FileType type)>
  34. create_file_cb,
  35. uint64_t* sequence_number, uint64_t log_size_for_flush,
  36. bool get_live_table_checksum = false);
  37. private:
  38. Status CleanStagingDirectory(const std::string& path, Logger* info_log);
  39. // Export logic customization by providing callbacks for link or copy.
  40. Status ExportFilesInMetaData(
  41. const DBOptions& db_options, const ColumnFamilyMetaData& metadata,
  42. std::function<Status(const std::string& src_dirname,
  43. const std::string& fname)>
  44. link_file_cb,
  45. std::function<Status(const std::string& src_dirname,
  46. const std::string& fname)>
  47. copy_file_cb);
  48. private:
  49. DB* db_;
  50. };
  51. } // namespace ROCKSDB_NAMESPACE