Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
218cc5fc
You need to sign in or sign up before continuing.
Commit
218cc5fc
authored
Mar 18, 2014
by
antirez
Browse files
Sentinel: propagate down-after-ms changes to slaves and sentinels.
parent
bb6d8501
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
218cc5fc
...
@@ -1298,6 +1298,24 @@ sentinelAddr *sentinelGetCurrentMasterAddress(sentinelRedisInstance *master) {
...
@@ -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 ============================= */
/* ============================ Config handling ============================= */
char
*
sentinelHandleConfiguration
(
char
**
argv
,
int
argc
)
{
char
*
sentinelHandleConfiguration
(
char
**
argv
,
int
argc
)
{
sentinelRedisInstance
*
ri
;
sentinelRedisInstance
*
ri
;
...
@@ -1323,6 +1341,7 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
...
@@ -1323,6 +1341,7 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
ri
->
down_after_period
=
atoi
(
argv
[
2
]);
ri
->
down_after_period
=
atoi
(
argv
[
2
]);
if
(
ri
->
down_after_period
<=
0
)
if
(
ri
->
down_after_period
<=
0
)
return
"negative or zero time parameter."
;
return
"negative or zero time parameter."
;
sentinelPropagateDownAfterPeriod
(
ri
);
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"failover-timeout"
)
&&
argc
==
3
)
{
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"failover-timeout"
)
&&
argc
==
3
)
{
/* failover-timeout <name> <milliseconds> */
/* failover-timeout <name> <milliseconds> */
ri
=
sentinelGetMasterByName
(
argv
[
1
]);
ri
=
sentinelGetMasterByName
(
argv
[
1
]);
...
@@ -2762,6 +2781,7 @@ void sentinelSetCommand(redisClient *c) {
...
@@ -2762,6 +2781,7 @@ void sentinelSetCommand(redisClient *c) {
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<=
0
)
if
(
getLongLongFromObject
(
o
,
&
ll
)
==
REDIS_ERR
||
ll
<=
0
)
goto
badfmt
;
goto
badfmt
;
ri
->
down_after_period
=
ll
;
ri
->
down_after_period
=
ll
;
sentinelPropagateDownAfterPeriod
(
ri
);
changes
++
;
changes
++
;
}
else
if
(
!
strcasecmp
(
option
,
"failover-timeout"
))
{
}
else
if
(
!
strcasecmp
(
option
,
"failover-timeout"
))
{
/* failover-timeout <milliseconds> */
/* 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