提交 290ddaf2 编写于 作者: baowanyu's avatar baowanyu 提交者: Jiangtao Hu

framework: change record file postfix from .record.1 to .record.00001

上级 a3c62ba9
......@@ -17,6 +17,7 @@
#include "cybertron/record/record_writer.h"
#include <iostream>
#include <iomanip>
#include "cybertron/common/log.h"
......@@ -33,7 +34,11 @@ RecordWriter::~RecordWriter() { Close(); }
bool RecordWriter::Open(const std::string& file) {
file_ = file;
path_ = file_;
file_index_ = 0;
sstream_.str(std::string());
sstream_.clear();
sstream_ << "." << std::setw(5) << std::setfill('0') << file_index_++;
path_ = file_ + sstream_.str();
file_writer_.reset(new RecordFileWriter());
if (!file_writer_->Open(path_)) {
AERROR << "open outfile failed. file: " << path_;
......@@ -53,7 +58,14 @@ void RecordWriter::Close() {
void RecordWriter::SplitOutfile() {
file_writer_.reset(new RecordFileWriter());
path_ = file_ + "." + std::to_string(++file_index_);
if (file_index_ > 99999) {
AWARN << "More than 9999 files had bean recored, will restart counting at 00000.";
file_index_ = 0;
}
sstream_.str(std::string());
sstream_.clear();
sstream_ << "." << std::setw(5) << std::setfill('0') << file_index_++;
path_ = file_ + sstream_.str();
segment_raw_size_ = 0;
segment_begin_time_ = 0;
file_writer_->Open(path_);
......
......@@ -21,6 +21,7 @@
#include <memory>
#include <mutex>
#include <string>
#include <sstream>
#include <unordered_map>
#include "cybertron/common/log.h"
......@@ -83,13 +84,14 @@ class RecordWriter : public RecordBase {
uint64_t segment_raw_size_ = 0;
uint64_t segment_begin_time_ = 0;
uint64_t file_index_ = 0;
uint32_t file_index_ = 0;
MessageNumberMap channel_message_number_map_;
MessageTypeMap channel_message_type_map_;
MessageProtoDescMap channel_proto_desc_map_;
FileWriterPtr file_writer_ = nullptr;
FileWriterPtr file_writer_backup_ = nullptr;
std::mutex mutex_;
std::stringstream sstream_;
};
template <>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册