]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/utilities/checkpoint/checkpoint_impl.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / rocksdb / utilities / checkpoint / checkpoint_impl.h
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
6 #pragma once
7 #ifndef ROCKSDB_LITE
8
9 #include "rocksdb/utilities/checkpoint.h"
10
11 #include <string>
12 #include "file/filename.h"
13 #include "rocksdb/db.h"
14
15 namespace ROCKSDB_NAMESPACE {
16
17 class CheckpointImpl : public Checkpoint {
18 public:
19 // Creates a Checkpoint object to be used for creating openable snapshots
20 explicit CheckpointImpl(DB* db) : db_(db) {}
21
22 // Builds an openable snapshot of RocksDB on the same disk, which
23 // accepts an output directory on the same disk, and under the directory
24 // (1) hard-linked SST files pointing to existing live SST files
25 // SST files will be copied if output directory is on a different filesystem
26 // (2) a copied manifest files and other files
27 // The directory should not already exist and will be created by this API.
28 // The directory will be an absolute path
29 using Checkpoint::CreateCheckpoint;
30 virtual Status CreateCheckpoint(const std::string& checkpoint_dir,
31 uint64_t log_size_for_flush,
32 uint64_t* sequence_number_ptr) override;
33
34 // Exports all live SST files of a specified Column Family onto export_dir
35 // and returning SST files information in metadata.
36 // - SST files will be created as hard links when the directory specified
37 // is in the same partition as the db directory, copied otherwise.
38 // - export_dir should not already exist and will be created by this API.
39 // - Always triggers a flush.
40 using Checkpoint::ExportColumnFamily;
41 virtual Status ExportColumnFamily(
42 ColumnFamilyHandle* handle, const std::string& export_dir,
43 ExportImportFilesMetaData** metadata) override;
44
45 // Checkpoint logic can be customized by providing callbacks for link, copy,
46 // or create.
47 Status CreateCustomCheckpoint(
48 const DBOptions& db_options,
49 std::function<Status(const std::string& src_dirname,
50 const std::string& fname, FileType type)>
51 link_file_cb,
52 std::function<Status(const std::string& src_dirname,
53 const std::string& fname, uint64_t size_limit_bytes,
54 FileType type, const std::string& checksum_func_name,
55 const std::string& checksum_val)>
56 copy_file_cb,
57 std::function<Status(const std::string& fname,
58 const std::string& contents, FileType type)>
59 create_file_cb,
60 uint64_t* sequence_number, uint64_t log_size_for_flush,
61 bool get_live_table_checksum = false);
62
63 private:
64 void CleanStagingDirectory(const std::string& path, Logger* info_log);
65
66 // Export logic customization by providing callbacks for link or copy.
67 Status ExportFilesInMetaData(
68 const DBOptions& db_options, const ColumnFamilyMetaData& metadata,
69 std::function<Status(const std::string& src_dirname,
70 const std::string& fname)>
71 link_file_cb,
72 std::function<Status(const std::string& src_dirname,
73 const std::string& fname)>
74 copy_file_cb);
75
76 private:
77 DB* db_;
78 };
79
80 } // namespace ROCKSDB_NAMESPACE
81
82 #endif // ROCKSDB_LITE