mirror of
https://github.com/fluencelabs/redis
synced 2025-04-01 15:21:03 +00:00
Sentinel: role reporting fixed and added in SENTINEL output.
This commit is contained in:
parent
a0afa66f4b
commit
ddaad9fe2d
@ -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) {
|
|||||||
|
|
||||||
/* 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) {
|
|||||||
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 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user