Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
eos
QuarkDB
Commits
a44d0dac
Commit
a44d0dac
authored
Jun 25, 2018
by
Georgios Bitzes
Browse files
Simplify RaftHandshake using qclient Handshake chaining
parent
9d5b106d
Pipeline
#425054
passed with stages
in 30 minutes and 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
qclient
@
417793db
Compare
0ef4113c
...
417793db
Subproject commit
0ef4113c8902d5b79893989a0eaef3354ac79e69
Subproject commit
417793db74422236b2f317229bcf42d06ede5223
src/raft/RaftTalker.cc
View file @
a44d0dac
...
...
@@ -34,29 +34,15 @@ public:
virtual
~
RaftHandshake
()
override
{}
RaftHandshake
(
const
RaftContactDetails
&
cd
)
:
contactDetails
(
cd
)
,
authHandshake
(
cd
.
getPassword
())
{
:
contactDetails
(
cd
)
{
restart
();
}
virtual
std
::
vector
<
std
::
string
>
provideHandshake
()
override
{
if
(
!
authHandshakeDone
)
{
return
authHandshake
.
provideHandshake
();
}
return
{
"RAFT_HANDSHAKE"
,
VERSION_FULL_STRING
,
contactDetails
.
getClusterID
(),
contactDetails
.
getRaftTimeouts
().
toString
()
};
}
virtual
Status
validateResponse
(
const
redisReplyPtr
&
reply
)
override
{
if
(
!
authHandshakeDone
)
{
Status
st
=
authHandshake
.
validateResponse
(
reply
);
if
(
st
==
Status
::
INVALID
)
return
Status
::
INVALID
;
if
(
st
==
Status
::
VALID_INCOMPLETE
)
return
Status
::
VALID_INCOMPLETE
;
qdb_assert
(
st
==
Status
::
VALID_COMPLETE
);
authHandshakeDone
=
true
;
return
Status
::
VALID_INCOMPLETE
;
}
if
(
!
reply
)
{
return
Status
::
INVALID
;
}
...
...
@@ -72,15 +58,10 @@ public:
return
Status
::
VALID_COMPLETE
;
}
virtual
void
restart
()
override
{
authHandshakeDone
=
contactDetails
.
getPassword
().
empty
();
authHandshake
.
restart
();
}
virtual
void
restart
()
override
{}
private:
const
RaftContactDetails
&
contactDetails
;
bool
authHandshakeDone
=
false
;
qclient
::
HmacAuthHandshake
authHandshake
;
};
...
...
@@ -92,7 +73,9 @@ RaftTalker::RaftTalker(const RaftServer &server_, const RaftContactDetails &cont
opts
.
transparentRedirects
=
false
;
opts
.
retryStrategy
=
qclient
::
RetryStrategy
::
NoRetries
();
opts
.
backpressureStrategy
=
qclient
::
BackpressureStrategy
::
Default
();
opts
.
handshake
.
reset
(
new
RaftHandshake
(
contactDetails
));
opts
.
chainHmacHandshake
(
contactDetails
.
getPassword
());
opts
.
chainHandshake
(
std
::
unique_ptr
<
Handshake
>
(
new
RaftHandshake
(
contactDetails
)));
qcl
.
reset
(
new
QClient
(
server
.
hostname
,
server
.
port
,
std
::
move
(
opts
)));
}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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