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
ddaad9fe
Commit
ddaad9fe
authored
Nov 13, 2013
by
antirez
Browse files
Sentinel: role reporting fixed and added in SENTINEL output.
parent
a0afa66f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/sentinel.c
View file @
ddaad9fe
...
@@ -1547,9 +1547,9 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
...
@@ -1547,9 +1547,9 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
* thing we can do is to follow the events and redirect to the new
* thing we can do is to follow the events and redirect to the new
* master, always. */
* master, always. */
if ((ri->flags & SRI_MASTER) && role == SRI_SLAVE) {
if ((ri->flags & SRI_MASTER) && role == SRI_SLAVE) {
if
(
ri
->
role_reported
!=
SRI_
MASTER
)
{
if (ri->role_reported != SRI_
SLAVE
) {
ri->role_reported_time = mstime();
ri->role_reported_time = mstime();
ri
->
role_reported
=
SRI_
MASTER
;
ri->role_reported = SRI_
SLAVE
;
}
}
if (ri->slave_master_host) {
if (ri->slave_master_host) {
...
@@ -1565,9 +1565,9 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
...
@@ -1565,9 +1565,9 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) {
/* Handle slave -> master role switch. */
/* Handle slave -> master role switch. */
if ((ri->flags & SRI_SLAVE) && role == SRI_MASTER) {
if ((ri->flags & SRI_SLAVE) && role == SRI_MASTER) {
if
(
ri
->
role_reported
!=
SRI_
SLAVE
)
{
if (ri->role_reported != SRI_
MASTER
) {
ri->role_reported_time = mstime();
ri->role_reported_time = mstime();
ri
->
role_reported
=
SRI_
SLAVE
;
ri->role_reported = SRI_
MASTER
;
}
}
/* If this is a promoted slave we can change state to the
/* If this is a promoted slave we can change state to the
...
@@ -2004,6 +2004,15 @@ void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) {
...
@@ -2004,6 +2004,15 @@ void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) {
addReplyBulkCString(c,"info-refresh");
addReplyBulkCString(c,"info-refresh");
addReplyBulkLongLong(c,mstime() - ri->info_refresh);
addReplyBulkLongLong(c,mstime() - ri->info_refresh);
fields++;
fields++;
addReplyBulkCString(c,"role-reported");
addReplyBulkCString(c, (ri->role_reported == SRI_MASTER) ? "master" :
"slave");
fields++;
addReplyBulkCString(c,"role-reported-time");
addReplyBulkLongLong(c,mstime() - ri->role_reported_time);
fields++;
}
}
/* Only masters */
/* Only masters */
...
...
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