]> git.proxmox.com Git - ceph.git/blob - ceph/src/rocksdb/include/rocksdb/trace_reader_writer.h
update source to Ceph Pacific 16.2.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 TraceWriter() {}
23 virtual ~TraceWriter() {}
24
25 virtual Status Write(const Slice& data) = 0;
26 virtual Status Close() = 0;
27 virtual uint64_t GetFileSize() = 0;
28 };
29
30 // TraceReader allows reading RocksDB traces from any system, one operation at
31 // a time. A RocksDB Replayer could depend on this to replay opertions.
32 class TraceReader {
33 public:
34 TraceReader() {}
35 virtual ~TraceReader() {}
36
37 virtual Status Read(std::string* data) = 0;
38 virtual Status Close() = 0;
39 };
40
41 // Factory methods to read/write traces from/to a file.
42 Status NewFileTraceWriter(Env* env, const EnvOptions& env_options,
43 const std::string& trace_filename,
44 std::unique_ptr<TraceWriter>* trace_writer);
45 Status NewFileTraceReader(Env* env, const EnvOptions& env_options,
46 const std::string& trace_filename,
47 std::unique_ptr<TraceReader>* trace_reader);
48 } // namespace ROCKSDB_NAMESPACE