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
39f9f449
You need to sign in or sign up before continuing.
Commit
39f9f449
authored
Jan 10, 2014
by
antirez
Browse files
Sentinel: SENTINEL MONITOR command implemented.
It allows to add new masters to monitor at runtime.
parent
774f0bd4
Changes
1
Show whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
39f9f449
...
@@ -2486,6 +2486,40 @@ void sentinelCommand(redisClient *c) {
...
@@ -2486,6 +2486,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