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
0774d492
Commit
0774d492
authored
Mar 18, 2014
by
antirez
Browse files
Sentinel: propagate down-after-ms changes to slaves and sentinels.
parent
a86e24de
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
0774d492
...
...
@@ -1298,6 +1298,24 @@ sentinelAddr *sentinelGetCurrentMasterAddress(sentinelRedisInstance *master) {
}
}
/* This function sets the down_after_period field value in 'master' to all
* the slaves and sentinel instances connected to this master. */
void
sentinelPropagateDownAfterPeriod
(
sentinelRedisInstance
*
master
)
{
dictIterator
*
di
;
dictEntry
*
de
;
int
j
;
dict
*
d
[]
=
{
master
->
slaves
,
master
->
sentinels
,
NULL
};
for
(
j
=
0
;
d
[
j
];
j
++
)
{
di
=
dictGetIterator
(
d
[
j
]);
while
((
de
=
dictNext
(
di
))
!=
NULL
)
{
sentinelRedisInstance
*
ri
=
dictGetVal
(
de
);
ri
->
down_after_period
=
master
->
down_after_period
;
}
dictReleaseIterator
(
di
);
}
}
/* ============================ Config handling ============================= */
char
*
sentinelHandleConfiguration
(
char
**
argv
,
int
argc
)
{
sentinelRedisInstance
*
ri
;
...
...
@@ -1323,6 +1341,7 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
ri
->
down_after_period
=
atoi
(
argv
[
2
]);
if
(
ri
->
down_after_period
<=
0
)
return
"negative or zero time parameter."
;
sentinelPropagateDownAfterPeriod
(
ri
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"failover-timeout"
)
&&
argc
==
3
)
{
/* failover-timeout <name> <milliseconds> */
ri
=
sentinelGetMasterByName
(
argv
[
1
]);
...
...
@@ -2762,6 +2781,7 @@ void sentinelSetCommand(redisClient *c) {
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<=
0
)
goto
badfmt
;
ri
->
down_after_period
=
ll
;
sentinelPropagateDownAfterPeriod
(
ri
);
changes
++
;
}
else
if
(
!
strcasecmp
(
option
,
"failover-timeout"
))
{
/* failover-timeout <milliseconds> */
...
...
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