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

raft: drop unused struct

parent 38c2ef10
Pipeline #1560309 passed with stages
in 118 minutes and 38 seconds
...@@ -127,20 +127,19 @@ void RaftDirector::runForLeader() { ...@@ -127,20 +127,19 @@ void RaftDirector::runForLeader() {
// it could have changed in-between // it could have changed in-between
RaftStateSnapshotPtr snapshot = state.getSnapshot(); RaftStateSnapshotPtr snapshot = state.getSnapshot();
// advance the term by one, become a candidate.
if(!state.observed(snapshot->term+1, {})) return;
if(!state.becomeCandidate(snapshot->term+1)) return;
// prepare vote request // prepare vote request
RaftVoteRequest votereq; RaftVoteRequest votereq;
votereq.term = snapshot->term+1; votereq.term = snapshot->term+1;
votereq.lastIndex = journal.getLogSize()-1; votereq.lastIndex = journal.getLogSize()-1;
if(!journal.fetch(votereq.lastIndex, votereq.lastTerm).ok()) { if(!journal.fetch(votereq.lastIndex, votereq.lastTerm).ok()) {
qdb_critical("Unable to fetch journal entry " << votereq.lastIndex << " when running for leader"); qdb_critical("Unable to fetch journal entry " << votereq.lastIndex << " when running for leader");
state.dropOut(snapshot->term+1);
return; return;
} }
// advance the term by one, become a candidate.
if(!state.observed(snapshot->term+1, {})) return;
if(!state.becomeCandidate(snapshot->term+1)) return;
ElectionOutcome electionOutcome = RaftElection::perform(votereq, state, lease, contactDetails); ElectionOutcome electionOutcome = RaftElection::perform(votereq, state, lease, contactDetails);
if(electionOutcome != ElectionOutcome::kElected) { if(electionOutcome != ElectionOutcome::kElected) {
......
...@@ -48,14 +48,6 @@ public: ...@@ -48,14 +48,6 @@ public:
static bool fetchLastResponse(const qclient::redisReplyPtr &source, std::vector<RaftEntry> &entries); static bool fetchLastResponse(const qclient::redisReplyPtr &source, std::vector<RaftEntry> &entries);
}; };
struct ElectionSingleTally {
bool timeout;
bool error;
RaftVoteResponse resp;
};
using ElectionTally = std::map<RaftServer, ElectionSingleTally>;
class RaftElection { class RaftElection {
public: public:
static ElectionOutcome perform(RaftVoteRequest votereq, RaftState &state, RaftLease &lease, const RaftContactDetails &contactDetails); static ElectionOutcome perform(RaftVoteRequest votereq, RaftState &state, RaftLease &lease, const RaftContactDetails &contactDetails);
......
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