diff options
author | antirez <antirez@gmail.com> | 2013-11-13 16:36:40 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2013-11-21 15:20:25 +0100 |
commit | e98d82c6398724b88242b0e65a83a9e2d0e3bb9a (patch) | |
tree | 5c30c6fc4f94a3f7d226a33577a3172d255db1bc | |
parent | be19e5450cf088d93efe0410f4774d5ca31420ec (diff) | |
download | redis-e98d82c6398724b88242b0e65a83a9e2d0e3bb9a.tar.gz |
Sentinel: role reporting fixed and added in SENTINEL output.
-rw-r--r-- | src/sentinel.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/sentinel.c b/src/sentinel.c index 6858683bd..d1e844a7d 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -1549,9 +1549,9 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) { * thing we can do is to follow the events and redirect to the new * master, always. */ 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 = SRI_MASTER; + ri->role_reported = SRI_SLAVE; } if (ri->slave_master_host) { @@ -1567,9 +1567,9 @@ void sentinelRefreshInstanceInfo(sentinelRedisInstance *ri, const char *info) { /* Handle slave -> master role switch. */ 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 = SRI_SLAVE; + ri->role_reported = SRI_MASTER; } /* If this is a promoted slave we can change state to the @@ -2006,6 +2006,15 @@ void addReplySentinelRedisInstance(redisClient *c, sentinelRedisInstance *ri) { addReplyBulkCString(c,"info-refresh"); addReplyBulkLongLong(c,mstime() - ri->info_refresh); 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 */ |