]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/include/rocksdb/sst_file_manager.h
1 // Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
2 // This source code is licensed under the BSD-style license found in the
3 // LICENSE file in the root directory of this source tree. An additional grant
4 // of patent rights can be found in the PATENTS file in the same directory.
10 #include <unordered_map>
12 #include "rocksdb/status.h"
19 // SstFileManager is used to track SST files in the DB and control there
21 // All SstFileManager public functions are thread-safe.
22 class SstFileManager
{
24 virtual ~SstFileManager() {}
26 // Update the maximum allowed space that should be used by RocksDB, if
27 // the total size of the SST files exceeds max_allowed_space, writes to
30 // Setting max_allowed_space to 0 will disable this feature, maximum allowed
31 // space will be infinite (Default value).
34 virtual void SetMaxAllowedSpaceUsage(uint64_t max_allowed_space
) = 0;
36 // Return true if the total size of SST files exceeded the maximum allowed
40 virtual bool IsMaxAllowedSpaceReached() = 0;
42 // Return the total size of all tracked files.
44 virtual uint64_t GetTotalSize() = 0;
46 // Return a map containing all tracked files and there corresponding sizes.
48 virtual std::unordered_map
<std::string
, uint64_t> GetTrackedFiles() = 0;
50 // Return delete rate limit in bytes per second.
52 virtual int64_t GetDeleteRateBytesPerSecond() = 0;
54 // Update the delete rate limit in bytes per second.
55 // zero means disable delete rate limiting and delete files immediately
57 virtual void SetDeleteRateBytesPerSecond(int64_t delete_rate
) = 0;
60 // Create a new SstFileManager that can be shared among multiple RocksDB
61 // instances to track SST file and control there deletion rate.
63 // @param env: Pointer to Env object, please see "rocksdb/env.h".
64 // @param info_log: If not nullptr, info_log will be used to log errors.
66 // == Deletion rate limiting specific arguments ==
67 // @param trash_dir: Path to the directory where deleted files will be moved
68 // to be deleted in a background thread while applying rate limiting. If this
69 // directory dont exist, it will be created. This directory should not be
70 // used by any other process or any other SstFileManager, Set to "" to
71 // disable deletion rate limiting.
72 // @param rate_bytes_per_sec: How many bytes should be deleted per second, If
73 // this value is set to 1024 (1 Kb / sec) and we deleted a file of size 4 Kb
74 // in 1 second, we will wait for another 3 seconds before we delete other
75 // files, Set to 0 to disable deletion rate limiting.
76 // @param delete_existing_trash: If set to true, the newly created
77 // SstFileManager will delete files that already exist in trash_dir.
78 // @param status: If not nullptr, status will contain any errors that happened
79 // during creating the missing trash_dir or deleting existing files in trash.
80 extern SstFileManager
* NewSstFileManager(
81 Env
* env
, std::shared_ptr
<Logger
> info_log
= nullptr,
82 std::string trash_dir
= "", int64_t rate_bytes_per_sec
= 0,
83 bool delete_existing_trash
= true, Status
* status
= nullptr);
85 } // namespace rocksdb