int RaftConsensus::onReceivedRequestVote(const Connection::Ptr& pConnection, msg_requestvote_t& data) { OSS::mutex_lock lock(_raftMutex); int ret = 0; msg_requestvote_response_t response; ret = raft_recv_requestvote(_raft, pConnection->getNode().node(), &data, &response); if (ret != 0) { return ret; } return pConnection->onSendRequestVoteResponse(response); }
int RaftConsensus::onReceivedAppendEntries(const Connection::Ptr& pConnection, msg_appendentries_t& data) { OSS::mutex_lock lock(_raftMutex); int ret = 0; msg_appendentries_response_t response; ret = raft_recv_appendentries(_raft, pConnection->getNode().node(), &data, &response); if (ret != 0) { return ret; } return pConnection->onSendAppendEntriesResponse(response); }
int RaftConsensus::onReceivedAppendEntriesResponse(const Connection::Ptr& pConnection, msg_appendentries_response_t& data) { OSS::mutex_lock lock(_raftMutex); return raft_recv_appendentries_response(_raft, pConnection->getNode().node(), &data); }
int RaftConsensus::onReceivedRequestVoteResponse(const Connection::Ptr& pConnection, msg_requestvote_response_t& data) { OSS::mutex_lock lock(_raftMutex); return raft_recv_requestvote_response(_raft, pConnection->getNode().node(), &data); }