]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/rocksdb/db/wal_manager.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / rocksdb / db / wal_manager.h
index 6caf1640c06ca26889b14eddb4981f03fcaac43d..783bfe99cad28a0978a26fd47478ac07ecdceb17 100644 (file)
@@ -18,6 +18,7 @@
 #include <memory>
 
 #include "db/version_set.h"
+#include "file/file_util.h"
 #include "options/db_options.h"
 #include "port/port.h"
 #include "rocksdb/env.h"
 #include "rocksdb/transaction_log.h"
 #include "rocksdb/types.h"
 
-namespace rocksdb {
+namespace ROCKSDB_NAMESPACE {
 
 #ifndef ROCKSDB_LITE
+
+// WAL manager provides the abstraction for reading the WAL files as a single
+// unit. Internally, it opens and reads the files using Reader or Writer
+// abstraction.
 class WalManager {
  public:
   WalManager(const ImmutableDBOptions& db_options,
-             const EnvOptions& env_options, const bool seq_per_batch = false)
+             const FileOptions& file_options, const bool seq_per_batch = false)
       : db_options_(db_options),
-        env_options_(env_options),
+        file_options_(file_options),
         env_(db_options.env),
+        fs_(db_options.fs.get()),
         purge_wal_files_last_run_(0),
-        seq_per_batch_(seq_per_batch) {}
+        seq_per_batch_(seq_per_batch),
+        wal_in_db_path_(IsWalDirSameAsDBPath(&db_options)) {}
 
   Status GetSortedWalFiles(VectorLogPtr& files);
 
+  // Allow user to tail transaction log to find all recent changes to the
+  // database that are newer than `seq_number`.
   Status GetUpdatesSince(
       SequenceNumber seq_number, std::unique_ptr<TransactionLogIterator>* iter,
       const TransactionLogIterator::ReadOptions& read_options,
@@ -51,6 +60,8 @@ class WalManager {
 
   Status DeleteFile(const std::string& fname, uint64_t number);
 
+  Status GetLiveWalFile(uint64_t number, std::unique_ptr<LogFile>* log_file);
+
   Status TEST_ReadFirstRecord(const WalFileType type, const uint64_t number,
                               SequenceNumber* sequence) {
     return ReadFirstRecord(type, number, sequence);
@@ -78,8 +89,9 @@ class WalManager {
 
   // ------- state from DBImpl ------
   const ImmutableDBOptions& db_options_;
-  const EnvOptions& env_options_;
+  const FileOptions file_options_;
   Env* env_;
+  FileSystem* fs_;
 
   // ------- WalManager state -------
   // cache for ReadFirstRecord() calls
@@ -91,10 +103,12 @@ class WalManager {
 
   bool seq_per_batch_;
 
+  bool wal_in_db_path_;
+
   // obsolete files will be deleted every this seconds if ttl deletion is
   // enabled and archive size_limit is disabled.
   static const uint64_t kDefaultIntervalToDeleteObsoleteWAL = 600;
 };
 
 #endif  // ROCKSDB_LITE
-}  // namespace rocksdb
+}  // namespace ROCKSDB_NAMESPACE