예제 #1
0
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);
}
예제 #2
0
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);
}
예제 #3
0
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);
}
예제 #4
0
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);
}