| 4000 | } |
| 4001 | |
| 4002 | int clusterManagerIsConfigConsistent(int fLog) { |
| 4003 | if (cluster_manager.nodes == NULL) return 0; |
| 4004 | int consistent = (listLength(cluster_manager.nodes) <= 1); |
| 4005 | // If the Cluster has only one node, it's always consistent |
| 4006 | if (consistent) return 1; |
| 4007 | sds first_cfg = NULL; |
| 4008 | const char *firstNode = NULL; |
| 4009 | listIter li; |
| 4010 | listNode *ln; |
| 4011 | listRewind(cluster_manager.nodes, &li); |
| 4012 | while ((ln = listNext(&li)) != NULL) { |
| 4013 | clusterManagerNode *node = ln->value; |
| 4014 | sds cfg = clusterManagerGetConfigSignature(node); |
| 4015 | if (cfg == NULL) { |
| 4016 | consistent = 0; |
| 4017 | break; |
| 4018 | } |
| 4019 | if (first_cfg == NULL) { |
| 4020 | first_cfg = cfg; |
| 4021 | firstNode = node->name; |
| 4022 | } else { |
| 4023 | consistent = !sdscmp(first_cfg, cfg); |
| 4024 | sdsfree(cfg); |
| 4025 | if (fLog && !consistent) |
| 4026 | clusterManagerLogInfo("\tNode %s (%s:%d) is inconsistent with %s\n", node->name, node->ip, node->port, firstNode); |
| 4027 | if (!consistent) break; |
| 4028 | } |
| 4029 | } |
| 4030 | if (first_cfg != NULL) sdsfree(first_cfg); |
| 4031 | return consistent; |
| 4032 | } |
| 4033 | |
| 4034 | /* Add the error string to cluster_manager.errors and print it. */ |
| 4035 | void clusterManagerOnError(sds err) { |
no test coverage detected