Redis instance to Redis protocol representation. */
| 3276 | |
| 3277 | /* Redis instance to Redis protocol representation. */ |
| 3278 | void addReplySentinelRedisInstance(client *c, sentinelRedisInstance *ri) { |
| 3279 | char *flags = sdsempty(); |
| 3280 | void *mbl; |
| 3281 | int fields = 0; |
| 3282 | |
| 3283 | mbl = addReplyDeferredLen(c); |
| 3284 | |
| 3285 | addReplyBulkCString(c,"name"); |
| 3286 | addReplyBulkCString(c,ri->name); |
| 3287 | fields++; |
| 3288 | |
| 3289 | addReplyBulkCString(c,"ip"); |
| 3290 | addReplyBulkCString(c,announceSentinelAddr(ri->addr)); |
| 3291 | fields++; |
| 3292 | |
| 3293 | addReplyBulkCString(c,"port"); |
| 3294 | addReplyBulkLongLong(c,ri->addr->port); |
| 3295 | fields++; |
| 3296 | |
| 3297 | addReplyBulkCString(c,"runid"); |
| 3298 | addReplyBulkCString(c,ri->runid ? ri->runid : ""); |
| 3299 | fields++; |
| 3300 | |
| 3301 | addReplyBulkCString(c,"flags"); |
| 3302 | if (ri->flags & SRI_S_DOWN) flags = sdscat(flags,"s_down,"); |
| 3303 | if (ri->flags & SRI_O_DOWN) flags = sdscat(flags,"o_down,"); |
| 3304 | if (ri->flags & SRI_MASTER) flags = sdscat(flags,"master,"); |
| 3305 | if (ri->flags & SRI_SLAVE) flags = sdscat(flags,"slave,"); |
| 3306 | if (ri->flags & SRI_SENTINEL) flags = sdscat(flags,"sentinel,"); |
| 3307 | if (ri->link->disconnected) flags = sdscat(flags,"disconnected,"); |
| 3308 | if (ri->flags & SRI_MASTER_DOWN) flags = sdscat(flags,"master_down,"); |
| 3309 | if (ri->flags & SRI_FAILOVER_IN_PROGRESS) |
| 3310 | flags = sdscat(flags,"failover_in_progress,"); |
| 3311 | if (ri->flags & SRI_PROMOTED) flags = sdscat(flags,"promoted,"); |
| 3312 | if (ri->flags & SRI_RECONF_SENT) flags = sdscat(flags,"reconf_sent,"); |
| 3313 | if (ri->flags & SRI_RECONF_INPROG) flags = sdscat(flags,"reconf_inprog,"); |
| 3314 | if (ri->flags & SRI_RECONF_DONE) flags = sdscat(flags,"reconf_done,"); |
| 3315 | if (ri->flags & SRI_FORCE_FAILOVER) flags = sdscat(flags,"force_failover,"); |
| 3316 | if (ri->flags & SRI_SCRIPT_KILL_SENT) flags = sdscat(flags,"script_kill_sent,"); |
| 3317 | |
| 3318 | if (sdslen(flags) != 0) sdsrange(flags,0,-2); /* remove last "," */ |
| 3319 | addReplyBulkCString(c,flags); |
| 3320 | sdsfree(flags); |
| 3321 | fields++; |
| 3322 | |
| 3323 | addReplyBulkCString(c,"link-pending-commands"); |
| 3324 | addReplyBulkLongLong(c,ri->link->pending_commands); |
| 3325 | fields++; |
| 3326 | |
| 3327 | addReplyBulkCString(c,"link-refcount"); |
| 3328 | addReplyBulkLongLong(c,ri->link->refcount); |
| 3329 | fields++; |
| 3330 | |
| 3331 | if (ri->flags & SRI_FAILOVER_IN_PROGRESS) { |
| 3332 | addReplyBulkCString(c,"failover-state"); |
| 3333 | addReplyBulkCString(c,(char*)sentinelFailoverStateStr(ri->failover_state)); |
| 3334 | fields++; |
| 3335 | } |
no test coverage detected