Commit a60e13bc authored by Georgios Bitzes's avatar Georgios Bitzes
Browse files

raft: implement pre-vote RPC

parent 647ac661
Pipeline #1508356 failed with stages
in 84 minutes and 7 seconds
......@@ -128,6 +128,7 @@ struct cmdMapInit {
redis_cmd_map["raft_info"] = {RedisCommand::RAFT_INFO, CommandType::RAFT};
redis_cmd_map["raft_leader_info"] = {RedisCommand::RAFT_LEADER_INFO, CommandType::RAFT};
redis_cmd_map["raft_request_vote"] = {RedisCommand::RAFT_REQUEST_VOTE, CommandType::RAFT};
redis_cmd_map["raft_request_pre_vote"] = {RedisCommand::RAFT_REQUEST_PRE_VOTE, CommandType::RAFT};
redis_cmd_map["raft_fetch"] = {RedisCommand::RAFT_FETCH, CommandType::RAFT};
redis_cmd_map["raft_attempt_coup"] = {RedisCommand::RAFT_ATTEMPT_COUP, CommandType::RAFT};
redis_cmd_map["raft_add_observer"] = {RedisCommand::RAFT_ADD_OBSERVER, CommandType::RAFT};
......
......@@ -135,6 +135,7 @@ enum class RedisCommand {
RAFT_INFO,
RAFT_LEADER_INFO,
RAFT_REQUEST_VOTE,
RAFT_REQUEST_PRE_VOTE,
RAFT_FETCH,
RAFT_ATTEMPT_COUP,
RAFT_ADD_OBSERVER,
......
......@@ -177,6 +177,16 @@ LinkStatus RaftDispatcher::dispatch(Connection *conn, RedisRequest &req) {
journal.setFsyncPolicy(policy);
return conn->ok();
}
case RedisCommand::RAFT_REQUEST_PRE_VOTE: {
if(!conn->raftAuthorization) return conn->err("not authorized to issue raft commands");
RaftVoteRequest votereq;
if(!RaftParser::voteRequest(req, votereq)) {
return conn->err("malformed request");
}
RaftVoteResponse resp = requestVote(votereq, true);
return conn->vector(resp.toVector());
}
case RedisCommand::RAFT_REQUEST_VOTE: {
if(!conn->raftAuthorization) return conn->err("not authorized to issue raft commands");
RaftVoteRequest votereq;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment