Skip to content

Commit

Permalink
Refactor Binlog (OpenAtomFoundation#807)
Browse files Browse the repository at this point in the history
* Move binlog_io_error_ check to inside check of class Binlog
  • Loading branch information
whoiami committed Mar 20, 2020
1 parent 9c93002 commit f470408
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions include/pika_binlog.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ class Binlog {
return filename_;
}

bool IsBinlogError() {
return binlog_io_error_;
}

private:
void Close();
Status Put(const char* item, int len);
Expand Down Expand Up @@ -110,6 +114,8 @@ class Binlog {
uint64_t file_size_;

std::string filename_;

std::atomic<bool> binlog_io_error_;
// Not use
//int32_t retry_;

Expand Down
9 changes: 7 additions & 2 deletions src/pika_binlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ Binlog::Binlog(const std::string& binlog_path, const int file_size) :
pool_(NULL),
exit_all_consume_(false),
binlog_path_(binlog_path),
file_size_(file_size) {
file_size_(file_size),
binlog_io_error_(false) {

// To intergrate with old version, we don't set mmap file size to 100M;
//slash::SetMmapBoundSize(file_size);
Expand Down Expand Up @@ -178,7 +179,11 @@ Status Binlog::Put(const std::string &item) {
if (!opened_.load()) {
return Status::Busy("Binlog is not open yet");
}
return Put(item.c_str(), item.size());
Status s = Put(item.c_str(), item.size());
if (!s.ok()) {
binlog_io_error_.store(true);
}
return s;
}

// Note: mutex lock should be held
Expand Down

0 comments on commit f470408

Please sign in to comment.