Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
eos
QuarkDB
Commits
fdc6a9bd
Commit
fdc6a9bd
authored
Apr 15, 2020
by
Georgios Bitzes
Browse files
raft: re-implement performPreVote method
parent
b69be9ed
Pipeline
#1561234
passed with stages
in 143 minutes and 29 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/raft/RaftUtils.cc
View file @
fdc6a9bd
...
...
@@ -33,6 +33,41 @@
namespace
quarkdb
{
ElectionOutcome
RaftElection
::
performPreVote
(
RaftVoteRequest
votereq
,
RaftState
&
state
,
const
RaftContactDetails
&
contactDetails
)
{
if
(
!
votereq
.
candidate
.
empty
())
{
qdb_throw
(
"candidate member of votereq must be empty, it is filled out by this function"
);
}
votereq
.
candidate
=
state
.
getMyself
();
qdb_info
(
"Starting pre-vote round for term "
<<
votereq
.
term
);
std
::
chrono
::
steady_clock
::
time_point
broadcastTimepoint
=
std
::
chrono
::
steady_clock
::
now
();
std
::
vector
<
std
::
unique_ptr
<
RaftTalker
>>
talkers
;
std
::
map
<
RaftServer
,
std
::
future
<
redisReplyPtr
>>
futures
;
for
(
const
RaftServer
&
node
:
state
.
getNodes
())
{
if
(
node
!=
votereq
.
candidate
)
{
talkers
.
emplace_back
(
new
RaftTalker
(
node
,
contactDetails
,
"internal-vote-request"
));
futures
[
node
]
=
talkers
.
back
()
->
requestVote
(
votereq
,
true
);
}
}
std
::
chrono
::
steady_clock
::
time_point
deadline
=
broadcastTimepoint
+
contactDetails
.
getRaftTimeouts
().
getHeartbeatInterval
()
*
2
;
qdb_info
(
"Pre-vote requests have been sent off, will allow a window of "
<<
contactDetails
.
getRaftTimeouts
().
getLow
().
count
()
<<
"ms to receive replies."
);
RaftVoteRegistry
registry
(
votereq
.
term
,
true
);
for
(
auto
it
=
futures
.
begin
();
it
!=
futures
.
end
();
it
++
)
{
registry
.
registerVote
(
it
->
first
,
it
->
second
,
deadline
);
}
qdb_info
(
registry
.
describeOutcome
());
return
registry
.
determineOutcome
();
}
ElectionOutcome
RaftElection
::
perform
(
RaftVoteRequest
votereq
,
RaftState
&
state
,
RaftLease
&
lease
,
const
RaftContactDetails
&
contactDetails
)
{
if
(
!
votereq
.
candidate
.
empty
())
{
qdb_throw
(
"candidate member of votereq must be empty, it is filled out by this function"
);
...
...
src/raft/RaftUtils.hh
View file @
fdc6a9bd
...
...
@@ -50,6 +50,7 @@ public:
class
RaftElection
{
public:
static
ElectionOutcome
performPreVote
(
RaftVoteRequest
votereq
,
RaftState
&
state
,
const
RaftContactDetails
&
contactDetails
);
static
ElectionOutcome
perform
(
RaftVoteRequest
votereq
,
RaftState
&
state
,
RaftLease
&
lease
,
const
RaftContactDetails
&
contactDetails
);
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment