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
1bbce5bf
Commit
1bbce5bf
authored
Nov 19, 2013
by
antirez
Browse files
Sentinel: when writing config on disk, remember sentinels runid.
parent
679dc8b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
1bbce5bf
...
@@ -1322,10 +1322,11 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
...
@@ -1322,10 +1322,11 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
{
{
return
"Wrong hostname or port for slave."
;
return
"Wrong hostname or port for slave."
;
}
}
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"known-sentinel"
)
&&
argc
==
4
)
{
}
else
if
(
!
strcasecmp
(
argv
[
0
],
"known-sentinel"
)
&&
(
argc
==
4
||
argc
==
5
))
{
sentinelRedisInstance
*
si
;
sentinelRedisInstance
*
si
;
/* known-sentinel <name> <ip> <port> */
/* known-sentinel <name> <ip> <port>
[runid]
*/
ri
=
sentinelGetMasterByName
(
argv
[
1
]);
ri
=
sentinelGetMasterByName
(
argv
[
1
]);
if
(
!
ri
)
return
"No such master with specified name."
;
if
(
!
ri
)
return
"No such master with specified name."
;
if
((
si
=
createSentinelRedisInstance
(
NULL
,
SRI_SENTINEL
,
argv
[
2
],
if
((
si
=
createSentinelRedisInstance
(
NULL
,
SRI_SENTINEL
,
argv
[
2
],
...
@@ -1333,6 +1334,7 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
...
@@ -1333,6 +1334,7 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
{
{
return
"Wrong hostname or port for sentinel."
;
return
"Wrong hostname or port for sentinel."
;
}
}
if
(
argc
==
5
)
si
->
runid
=
sdsnew
(
argv
[
4
]);
}
else
{
}
else
{
return
"Unrecognized sentinel configuration statement."
;
return
"Unrecognized sentinel configuration statement."
;
}
}
...
@@ -1444,8 +1446,10 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
...
@@ -1444,8 +1446,10 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
while
((
de
=
dictNext
(
di2
))
!=
NULL
)
{
while
((
de
=
dictNext
(
di2
))
!=
NULL
)
{
ri
=
dictGetVal
(
de
);
ri
=
dictGetVal
(
de
);
line
=
sdscatprintf
(
sdsempty
(),
line
=
sdscatprintf
(
sdsempty
(),
"sentinel known-sentinel %s %s %d"
,
"sentinel known-sentinel %s %s %d%s%s"
,
master
->
name
,
ri
->
addr
->
ip
,
ri
->
addr
->
port
);
master
->
name
,
ri
->
addr
->
ip
,
ri
->
addr
->
port
,
ri
->
runid
?
" "
:
""
,
ri
->
runid
?
ri
->
runid
:
""
);
rewriteConfigRewriteLine
(
state
,
"sentinel"
,
line
,
1
);
rewriteConfigRewriteLine
(
state
,
"sentinel"
,
line
,
1
);
}
}
dictReleaseIterator
(
di2
);
dictReleaseIterator
(
di2
);
...
...
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