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
0a35f653
Commit
0a35f653
authored
Nov 19, 2013
by
antirez
Browse files
Sentinel: when writing config on disk, remember sentinels runid.
parent
5450833d
Changes
1
Show whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
0a35f653
...
@@ -1320,10 +1320,11 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
...
@@ -1320,10 +1320,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],
...
@@ -1331,6 +1332,7 @@ char *sentinelHandleConfiguration(char **argv, int argc) {
...
@@ -1331,6 +1332,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.";
}
}
...
@@ -1442,8 +1444,10 @@ void rewriteConfigSentinelOption(struct rewriteConfigState *state) {
...
@@ -1442,8 +1444,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