Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
5b4020fb
Commit
5b4020fb
authored
Jan 30, 2014
by
antirez
Browse files
Cluster: swap two code blocks to have a more obvious flow.
parent
4beaaff8
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
5b4020fb
...
@@ -1964,14 +1964,6 @@ void clusterHandleSlaveFailover(void) {
...
@@ -1964,14 +1964,6 @@ void clusterHandleSlaveFailover(void) {
int
needed_quorum
=
(
server
.
cluster
->
size
/
2
)
+
1
;
int
needed_quorum
=
(
server
.
cluster
->
size
/
2
)
+
1
;
int
j
;
int
j
;
/* Set data_age to the number of seconds we are disconnected from
* the master. */
if
(
server
.
repl_state
==
REDIS_REPL_CONNECTED
)
{
data_age
=
(
server
.
unixtime
-
server
.
master
->
lastinteraction
)
*
1000
;
}
else
{
data_age
=
(
server
.
unixtime
-
server
.
repl_down_since
)
*
1000
;
}
/* Pre conditions to run the function:
/* Pre conditions to run the function:
* 1) We are a slave.
* 1) We are a slave.
* 2) Our master is flagged as FAIL.
* 2) Our master is flagged as FAIL.
...
@@ -1981,6 +1973,14 @@ void clusterHandleSlaveFailover(void) {
...
@@ -1981,6 +1973,14 @@ void clusterHandleSlaveFailover(void) {
!
nodeFailed
(
myself
->
slaveof
)
||
!
nodeFailed
(
myself
->
slaveof
)
||
myself
->
slaveof
->
numslots
==
0
)
return
;
myself
->
slaveof
->
numslots
==
0
)
return
;
/* Set data_age to the number of seconds we are disconnected from
* the master. */
if
(
server
.
repl_state
==
REDIS_REPL_CONNECTED
)
{
data_age
=
(
server
.
unixtime
-
server
.
master
->
lastinteraction
)
*
1000
;
}
else
{
data_age
=
(
server
.
unixtime
-
server
.
repl_down_since
)
*
1000
;
}
/* Remove the node timeout from the data age as it is fine that we are
/* Remove the node timeout from the data age as it is fine that we are
* disconnected from our master at least for the time it was down to be
* disconnected from our master at least for the time it was down to be
* flagged as FAIL, that's the baseline. */
* flagged as FAIL, that's the baseline. */
...
...
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