Check for disconnected cluster links. It returns a dict whose keys * are the unreachable node addresses and the values are lists of * node addresses that cannot reach the unreachable node. */
| 4519 | * are the unreachable node addresses and the values are lists of |
| 4520 | * node addresses that cannot reach the unreachable node. */ |
| 4521 | static dict *clusterManagerGetLinkStatus(void) { |
| 4522 | if (cluster_manager.nodes == NULL) return NULL; |
| 4523 | dict *status = dictCreate(&clusterManagerLinkDictType, NULL); |
| 4524 | listIter li; |
| 4525 | listNode *ln; |
| 4526 | listRewind(cluster_manager.nodes, &li); |
| 4527 | while ((ln = listNext(&li)) != NULL) { |
| 4528 | clusterManagerNode *node = ln->value; |
| 4529 | list *links = clusterManagerGetDisconnectedLinks(node); |
| 4530 | if (links) { |
| 4531 | listIter lli; |
| 4532 | listNode *lln; |
| 4533 | listRewind(links, &lli); |
| 4534 | while ((lln = listNext(&lli)) != NULL) { |
| 4535 | clusterManagerLink *link = lln->value; |
| 4536 | list *from = NULL; |
| 4537 | dictEntry *entry = dictFind(status, link->node_addr); |
| 4538 | if (entry) from = dictGetVal(entry); |
| 4539 | else { |
| 4540 | from = listCreate(); |
| 4541 | dictAdd(status, sdsdup(link->node_addr), from); |
| 4542 | } |
| 4543 | sds myaddr = sdsempty(); |
| 4544 | myaddr = sdscatfmt(myaddr, "%s:%u", node->ip, node->port); |
| 4545 | listAddNodeTail(from, myaddr); |
| 4546 | sdsfree(link->node_name); |
| 4547 | sdsfree(link->node_addr); |
| 4548 | zfree(link); |
| 4549 | } |
| 4550 | listRelease(links); |
| 4551 | } |
| 4552 | } |
| 4553 | return status; |
| 4554 | } |
| 4555 | |
| 4556 | /* Add the error string to cluster_manager.errors and print it. */ |
| 4557 | static void clusterManagerOnError(sds err) { |
no test coverage detected