diff --git a/WORKSPACE b/WORKSPACE index d5a2b86409..f231086494 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -34,7 +34,7 @@ bazel_skylib_workspace() git_repository( name = "com_github_baidu_braft", remote = "https://github.com/baidu/braft", - commit = "d0277bf2aea66908d1fd7376d191bd098371966e", + commit = "d12de388c97998f5ccd5cb97ed0da728815ef438", ) bind( diff --git a/replace-curve-repo.sh b/replace-curve-repo.sh index ec058ea2da..7705bf0088 100755 --- a/replace-curve-repo.sh +++ b/replace-curve-repo.sh @@ -6,7 +6,7 @@ sed -i "s;https://dl.google.com/go/go1.12.8.linux-amd64.tar.gz;https://curve-bui sed -i "s;https://github.com/etcd-io/etcd;https://gitee.com/mirrors/etcd;g" thirdparties/etcdclient/Makefile # braft -sed -i "s;https://github.com/baidu/braft;https://gitee.com/baidu/braft;g" WORKSPACE +sed -i "s;https://github.com/baidu/braft;https://gitee.com/NetEase_Curve/braft;g" WORKSPACE # zlib sed -i "s;https://zlib.net/zlib-1.2.11.tar.gz;https://curve-build.nos-eastchina1.126.net/zlib-1.2.11.tar.gz;g" WORKSPACE diff --git a/src/chunkserver/raftlog/curve_segment_log_storage.cpp b/src/chunkserver/raftlog/curve_segment_log_storage.cpp index 453a50ea35..c9552e5c3f 100644 --- a/src/chunkserver/raftlog/curve_segment_log_storage.cpp +++ b/src/chunkserver/raftlog/curve_segment_log_storage.cpp @@ -422,7 +422,8 @@ int CurveSegmentLogStorage::append_entry(const braft::LogEntry* entry) { } int CurveSegmentLogStorage::append_entries( - const std::vector& entries) { + const std::vector& entries, + braft::IOMetric* metric) { if (entries.empty()) { return 0; } diff --git a/src/chunkserver/raftlog/curve_segment_log_storage.h b/src/chunkserver/raftlog/curve_segment_log_storage.h index 50aea348e3..0d970577a6 100644 --- a/src/chunkserver/raftlog/curve_segment_log_storage.h +++ b/src/chunkserver/raftlog/curve_segment_log_storage.h @@ -139,8 +139,10 @@ class CurveSegmentLogStorage : public braft::LogStorage { // append entry to log int append_entry(const braft::LogEntry* entry); - // append entries to log, return success append number - virtual int append_entries(const std::vector& entries); + // append entries to log and update IOMetric, return success append number + virtual int append_entries( + const std::vector& entries, + braft::IOMetric* metric); // delete logs from storage's head, [1, first_index_kept) will be discarded virtual int truncate_prefix(const int64_t first_index_kept); diff --git a/test/chunkserver/raftlog/test_curve_segment_log_storage.cpp b/test/chunkserver/raftlog/test_curve_segment_log_storage.cpp index 88b3816a47..253b124ac3 100644 --- a/test/chunkserver/raftlog/test_curve_segment_log_storage.cpp +++ b/test/chunkserver/raftlog/test_curve_segment_log_storage.cpp @@ -79,6 +79,7 @@ class CurveSegmentLogStorageTest : public testing::Test { } void append_entries(std::shared_ptr storage, int m, int n) { + braft::IOMetric metric; for (int i = 0; i < m; i++) { std::vector entries; for (int j = 0; j < n; j++) { @@ -95,7 +96,7 @@ class CurveSegmentLogStorageTest : public testing::Test { entries.push_back(entry); } - ASSERT_EQ(n, storage->append_entries(entries)); + ASSERT_EQ(n, storage->append_entries(entries, &metric)); } } void read_entries(std::shared_ptr storage, @@ -294,6 +295,7 @@ TEST_F(CurveSegmentLogStorageTest, append_close_load_append) { path = kRaftLogDataDir; butil::string_appendf(&path, "/" CURVE_SEGMENT_OPEN_PATTERN, 4097); ASSERT_EQ(0, prepare_segment(path)); + braft::IOMetric metric; for (int i = 600; i < 1000; i++) { std::vector entries; for (int j = 0; j < 5; j++) { @@ -310,7 +312,7 @@ TEST_F(CurveSegmentLogStorageTest, append_close_load_append) { entries.push_back(entry); } - ASSERT_EQ(5, storage->append_entries(entries)); + ASSERT_EQ(5, storage->append_entries(entries, &metric)); } // check and read @@ -393,6 +395,7 @@ TEST_F(CurveSegmentLogStorageTest, compatibility) { std::string path = kRaftLogDataDir; butil::string_appendf(&path, "/" CURVE_SEGMENT_OPEN_PATTERN, 3001); ASSERT_EQ(0, prepare_segment(path)); + braft::IOMetric metric; for (int i = 600; i < 1000; i++) { std::vector entries; for (int j = 0; j < 5; j++) { @@ -409,7 +412,7 @@ TEST_F(CurveSegmentLogStorageTest, compatibility) { entries.push_back(entry); } - ASSERT_EQ(5, storage2->append_entries(entries)); + ASSERT_EQ(5, storage2->append_entries(entries, &metric)); } // check and read ASSERT_EQ(storage2->first_log_index(), 1);