Lookup a slave in a master Redis instance, by ip and port. */
| 1418 | |
| 1419 | /* Lookup a slave in a master Redis instance, by ip and port. */ |
| 1420 | sentinelRedisInstance *sentinelRedisInstanceLookupSlave( |
| 1421 | sentinelRedisInstance *ri, char *slave_addr, int port) |
| 1422 | { |
| 1423 | sds key; |
| 1424 | sentinelRedisInstance *slave; |
| 1425 | sentinelAddr *addr; |
| 1426 | |
| 1427 | serverAssert(ri->flags & SRI_MASTER); |
| 1428 | |
| 1429 | /* We need to handle a slave_addr that is potentially a hostname. |
| 1430 | * If that is the case, depending on configuration we either resolve |
| 1431 | * it and use the IP addres or fail. |
| 1432 | */ |
| 1433 | addr = createSentinelAddr(slave_addr, port); |
| 1434 | if (!addr) return NULL; |
| 1435 | key = announceSentinelAddrAndPort(addr); |
| 1436 | releaseSentinelAddr(addr); |
| 1437 | |
| 1438 | slave = (sentinelRedisInstance*)dictFetchValue(ri->slaves,key); |
| 1439 | sdsfree(key); |
| 1440 | return slave; |
| 1441 | } |
| 1442 | |
| 1443 | /* Return the name of the type of the instance as a string. */ |
| 1444 | const char *sentinelRedisInstanceTypeStr(sentinelRedisInstance *ri) { |
no test coverage detected