]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/include/rocksdb/trace_reader_writer.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / rocksdb / include / rocksdb / trace_reader_writer.h
1 // Copyright (c) 2011-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
8 #include "rocksdb/env.h"
9
10 namespace ROCKSDB_NAMESPACE {
11
12 // Allow custom implementations of TraceWriter and TraceReader.
13 // By default, RocksDB provides a way to capture the traces to a file using the
14 // factory NewFileTraceWriter(). But users could also choose to export traces to
15 // any other system by providing custom implementations of TraceWriter and
16 // TraceReader.
17
18 // TraceWriter allows exporting RocksDB traces to any system, one operation at
19 // a time.
20 class TraceWriter {
21 public:
22 virtual ~TraceWriter() = default;
23
24 virtual Status Write(const Slice& data) = 0;
25 virtual Status Close() = 0;
26 virtual uint64_t GetFileSize() = 0;
27 };
28
29 // TraceReader allows reading RocksDB traces from any system, one operation at
30 // a time. A RocksDB Replayer could depend on this to replay operations.
31 class TraceReader {
32 public:
33 virtual ~TraceReader() = default;
34
35 virtual Status Read(std::string* data) = 0;
36 virtual Status Close() = 0;
37
38 // Seek back to the trace header. Replayer can call this method to restart
39 // replaying. Note this method may fail if the reader is already closed.
40 virtual Status Reset() = 0;
41 };
42
43 // Factory methods to write/read traces to/from a file.
44 // The implementations may not be thread-safe.
45 Status NewFileTraceWriter(Env* env, const EnvOptions& env_options,
46 const std::string& trace_filename,
47 std::unique_ptr<TraceWriter>* trace_writer);
48 Status NewFileTraceReader(Env* env, const EnvOptions& env_options,
49 const std::string& trace_filename,
50 std::unique_ptr<TraceReader>* trace_reader);
51
52 } // namespace ROCKSDB_NAMESPACE