From 426ea6268741480b12a488611f9adde61a03fa08 Mon Sep 17 00:00:00 2001 From: lintanghui Date: Thu, 20 Feb 2025 14:45:34 +0800 Subject: [PATCH] update comment --- src/braft/fsm_caller.cpp | 4 ---- src/braft/fsm_caller.h | 1 - src/braft/node.cpp | 5 ----- src/braft/node.h | 3 --- src/braft/raft.cpp | 1 - src/braft/raft.h | 5 ----- src/braft/replicator.cpp | 2 +- 7 files changed, 1 insertion(+), 20 deletions(-) diff --git a/src/braft/fsm_caller.cpp b/src/braft/fsm_caller.cpp index 8be576b6..98913eea 100644 --- a/src/braft/fsm_caller.cpp +++ b/src/braft/fsm_caller.cpp @@ -496,10 +496,6 @@ void FSMCaller::do_stop_following(const LeaderChangeContext& stop_following_cont _fsm->on_stop_following(stop_following_context); } -void FSMCaller::on_pre_send_snapshot(const PeerId& peer_id) { - _fsm->on_pre_send_snapshot(peer_id); -} - void FSMCaller::describe(std::ostream &os, bool use_html) { const char* newline = (use_html) ? "
" : "\n"; TaskType cur_task = _cur_task; diff --git a/src/braft/fsm_caller.h b/src/braft/fsm_caller.h index 6ad1c84e..897a50f9 100644 --- a/src/braft/fsm_caller.h +++ b/src/braft/fsm_caller.h @@ -116,7 +116,6 @@ class BAIDU_CACHELINE_ALIGNMENT FSMCaller { int on_leader_start(int64_t term, int64_t lease_epoch); int on_start_following(const LeaderChangeContext& start_following_context); int on_stop_following(const LeaderChangeContext& stop_following_context); - void on_pre_send_snapshot(const PeerId& peer_id); BRAFT_MOCK int on_error(const Error& e); int64_t last_applied_index() const { return _last_applied_index.load(butil::memory_order_relaxed); diff --git a/src/braft/node.cpp b/src/braft/node.cpp index 863f5444..02f56a27 100644 --- a/src/braft/node.cpp +++ b/src/braft/node.cpp @@ -1367,11 +1367,6 @@ void NodeImpl::on_error(const Error& e) { lck.unlock(); } -void NodeImpl::pre_send_snapshot(const PeerId& peer_id) { - _fsm_caller->on_pre_send_snapshot(peer_id); -} - - void NodeImpl::handle_vote_timeout() { std::unique_lock lck(_mutex); diff --git a/src/braft/node.h b/src/braft/node.h index e6230f02..b9dd3e82 100644 --- a/src/braft/node.h +++ b/src/braft/node.h @@ -241,9 +241,6 @@ friend class VoteBallotCtx; bool disable_cli() const { return _options.disable_cli; } bool is_witness() const { return _options.witness; } - - // Called when leader start to send snapshot to remote peer - void pre_send_snapshot(const PeerId& peer_id); private: friend class butil::RefCountedThreadSafe; diff --git a/src/braft/raft.cpp b/src/braft/raft.cpp index c7c66ef6..6069f706 100644 --- a/src/braft/raft.cpp +++ b/src/braft/raft.cpp @@ -313,7 +313,6 @@ void StateMachine::on_configuration_committed(const Configuration& conf, int64_t void StateMachine::on_stop_following(const LeaderChangeContext&) {} void StateMachine::on_start_following(const LeaderChangeContext&) {} -void StateMachine::on_pre_send_snapshot(const PeerId& peer_id) {} BootstrapOptions::BootstrapOptions() : last_log_index(0) diff --git a/src/braft/raft.h b/src/braft/raft.h index c73b97e4..08d8a89b 100644 --- a/src/braft/raft.h +++ b/src/braft/raft.h @@ -265,11 +265,6 @@ class StateMachine { // the very leader whom the follower starts to follow. // User can reset the node's information as it starts to follow some leader. virtual void on_start_following(const ::braft::LeaderChangeContext& ctx); - - // Invoked when the leader start to send snapshot to |peer_id| - // Default: Do nothing - virtual void on_pre_send_snapshot(const PeerId& peer_id); - }; enum State { diff --git a/src/braft/replicator.cpp b/src/braft/replicator.cpp index 48d87f92..5b66bc04 100644 --- a/src/braft/replicator.cpp +++ b/src/braft/replicator.cpp @@ -635,7 +635,7 @@ int Replicator::_prepare_entry(int offset, EntryMeta* em, butil::IOBuf *data) { } else { CHECK(entry->type != ENTRY_TYPE_CONFIGURATION) << "log_index=" << log_index; } - // 优先使用group级别的配置 + // use group-level configuration preferentially if (is_witness() && !_options.send_data_to_witness) { entry->Release(); return 0;