mirror of
https://github.com/facebook/rocksdb.git
synced 2024-12-02 01:16:16 +00:00
7125e24619
Summary: If user do not end the trace manually, the tracing will continue which can potential use up all the storage space and cause problem. In this PR, the max trace file size is added to the TraceOptions and user can set the value if they need or the default is 64GB. Pull Request resolved: https://github.com/facebook/rocksdb/pull/4610 Differential Revision: D12893400 Pulled By: zhichao-cao fbshipit-source-id: acf4b5a6076bb691778bdfbac4864e1006758953
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
// (found in the LICENSE.Apache file in the root directory).
|
|
|
|
#pragma once
|
|
|
|
#include "rocksdb/trace_reader_writer.h"
|
|
|
|
namespace rocksdb {
|
|
|
|
class RandomAccessFileReader;
|
|
class WritableFileWriter;
|
|
|
|
// FileTraceReader allows reading RocksDB traces from a file.
|
|
class FileTraceReader : public TraceReader {
|
|
public:
|
|
explicit FileTraceReader(std::unique_ptr<RandomAccessFileReader>&& reader);
|
|
~FileTraceReader();
|
|
|
|
virtual Status Read(std::string* data) override;
|
|
virtual Status Close() override;
|
|
|
|
private:
|
|
std::unique_ptr<RandomAccessFileReader> file_reader_;
|
|
Slice result_;
|
|
size_t offset_;
|
|
char* const buffer_;
|
|
|
|
static const unsigned int kBufferSize;
|
|
};
|
|
|
|
// FileTraceWriter allows writing RocksDB traces to a file.
|
|
class FileTraceWriter : public TraceWriter {
|
|
public:
|
|
explicit FileTraceWriter(std::unique_ptr<WritableFileWriter>&& file_writer)
|
|
: file_writer_(std::move(file_writer)) {}
|
|
~FileTraceWriter();
|
|
|
|
virtual Status Write(const Slice& data) override;
|
|
virtual Status Close() override;
|
|
virtual uint64_t GetFileSize() override;
|
|
|
|
private:
|
|
std::unique_ptr<WritableFileWriter> file_writer_;
|
|
};
|
|
|
|
} // namespace rocksdb
|