Skip to content

Commit

Permalink
[compile] update the braft to vesion v1.1.2
Browse files Browse the repository at this point in the history
Signed-off-by: tangwz <[email protected]>
  • Loading branch information
tangwz committed Nov 24, 2022
1 parent bf406a0 commit a9ad349
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion replace-curve-repo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/chunkserver/raftlog/curve_segment_log_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,8 @@ int CurveSegmentLogStorage::append_entry(const braft::LogEntry* entry) {
}

int CurveSegmentLogStorage::append_entries(
const std::vector<braft::LogEntry*>& entries) {
const std::vector<braft::LogEntry*>& entries,
braft::IOMetric* metric) {
if (entries.empty()) {
return 0;
}
Expand Down
6 changes: 4 additions & 2 deletions src/chunkserver/raftlog/curve_segment_log_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<braft::LogEntry*>& entries);
// append entries to log and update IOMetric, return success append number
virtual int append_entries(
const std::vector<braft::LogEntry*>& 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);
Expand Down
9 changes: 6 additions & 3 deletions test/chunkserver/raftlog/test_curve_segment_log_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class CurveSegmentLogStorageTest : public testing::Test {
}
void append_entries(std::shared_ptr<braft::LogStorage> storage,
int m, int n) {
braft::IOMetric metric;
for (int i = 0; i < m; i++) {
std::vector<braft::LogEntry*> entries;
for (int j = 0; j < n; j++) {
Expand All @@ -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<CurveSegmentLogStorage> storage,
Expand Down Expand Up @@ -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<braft::LogEntry*> entries;
for (int j = 0; j < 5; j++) {
Expand All @@ -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
Expand Down Expand Up @@ -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<braft::LogEntry*> entries;
for (int j = 0; j < 5; j++) {
Expand All @@ -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);
Expand Down

0 comments on commit a9ad349

Please sign in to comment.