]>
git.proxmox.com Git - ceph.git/blob - 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).
8 #include "rocksdb/env.h"
10 namespace ROCKSDB_NAMESPACE
{
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
18 // TraceWriter allows exporting RocksDB traces to any system, one operation at
22 virtual ~TraceWriter() = default;
24 virtual Status
Write(const Slice
& data
) = 0;
25 virtual Status
Close() = 0;
26 virtual uint64_t GetFileSize() = 0;
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.
33 virtual ~TraceReader() = default;
35 virtual Status
Read(std::string
* data
) = 0;
36 virtual Status
Close() = 0;
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;
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
);
52 } // namespace ROCKSDB_NAMESPACE