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
b7dc3204
Commit
b7dc3204
authored
Jan 10, 2014
by
antirez
Browse files
Sentinel: SENTINEL MONITOR command implemented.
It allows to add new masters to monitor at runtime.
parent
2e0ba7bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
b7dc3204
...
@@ -2488,6 +2488,40 @@ void sentinelCommand(redisClient *c) {
...
@@ -2488,6 +2488,40 @@ void sentinelCommand(redisClient *c) {
if
(
c
->
argc
!=
2
)
goto
numargserr
;
if
(
c
->
argc
!=
2
)
goto
numargserr
;
sentinelPendingScriptsCommand
(
c
);
sentinelPendingScriptsCommand
(
c
);
}
else
if
(
!
strcasecmp
(
c
->
argv
[
1
]
->
ptr
,
"monitor"
))
{
/* SENTINEL MONITOR <name> <ip> <port> <quorum> */
long
quorum
,
port
;
char
buf
[
32
];
if
(
c
->
argc
!=
6
)
goto
numargserr
;
if
(
getLongFromObjectOrReply
(
c
,
c
->
argv
[
5
],
&
quorum
,
"Invalid quorum"
)
!=
REDIS_OK
)
return
;
if
(
getLongFromObjectOrReply
(
c
,
c
->
argv
[
4
],
&
port
,
"Invalid port"
)
!=
REDIS_OK
)
return
;
/* Make sure the IP field is actually a valid IP before passing it
* to createSentinelRedisInstance(), otherwise we may trigger a
* DNS lookup at runtime. */
if
(
anetResolveIP
(
NULL
,
c
->
argv
[
3
]
->
ptr
,
buf
,
sizeof
(
buf
))
==
ANET_ERR
)
{
addReplyError
(
c
,
"Invalid IP address specified"
);
return
;
}
if
(
createSentinelRedisInstance
(
c
->
argv
[
2
]
->
ptr
,
SRI_MASTER
,
c
->
argv
[
3
]
->
ptr
,
port
,
quorum
,
NULL
)
==
NULL
)
{
switch
(
errno
)
{
case
EBUSY
:
addReplyError
(
c
,
"Duplicated master name"
);
break
;
case
EINVAL
:
addReplyError
(
c
,
"Invalid port number"
);
break
;
default:
addReplyError
(
c
,
"Unspecified error adding the instance"
);
break
;
}
}
else
{
addReply
(
c
,
shared
.
ok
);
}
}
else
{
}
else
{
addReplyErrorFormat
(
c
,
"Unknown sentinel subcommand '%s'"
,
addReplyErrorFormat
(
c
,
"Unknown sentinel subcommand '%s'"
,
(
char
*
)
c
->
argv
[
1
]
->
ptr
);
(
char
*
)
c
->
argv
[
1
]
->
ptr
);
...
...
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