MCPcopy Create free account
hub / github.com/F-Stack/f-stack / clusterManagerCheckCluster

Function clusterManagerCheckCluster

app/redis-6.2.6/src/redis-cli.c:5262–5424  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5260}
5261
5262static int clusterManagerCheckCluster(int quiet) {
5263 listNode *ln = listFirst(cluster_manager.nodes);
5264 if (!ln) return 0;
5265 clusterManagerNode *node = ln->value;
5266 clusterManagerLogInfo(">>> Performing Cluster Check (using node %s:%d)\n",
5267 node->ip, node->port);
5268 int result = 1, consistent = 0;
5269 int do_fix = config.cluster_manager_command.flags &
5270 CLUSTER_MANAGER_CMD_FLAG_FIX;
5271 if (!quiet) clusterManagerShowNodes();
5272 consistent = clusterManagerIsConfigConsistent();
5273 if (!consistent) {
5274 sds err = sdsnew("[ERR] Nodes don't agree about configuration!");
5275 clusterManagerOnError(err);
5276 result = 0;
5277 } else {
5278 clusterManagerLogOk("[OK] All nodes agree about slots "
5279 "configuration.\n");
5280 }
5281 /* Check open slots */
5282 clusterManagerLogInfo(">>> Check for open slots...\n");
5283 listIter li;
5284 listRewind(cluster_manager.nodes, &li);
5285 int i;
5286 dict *open_slots = NULL;
5287 while ((ln = listNext(&li)) != NULL) {
5288 clusterManagerNode *n = ln->value;
5289 if (n->migrating != NULL) {
5290 if (open_slots == NULL)
5291 open_slots = dictCreate(&clusterManagerDictType, NULL);
5292 sds errstr = sdsempty();
5293 errstr = sdscatprintf(errstr,
5294 "[WARNING] Node %s:%d has slots in "
5295 "migrating state ",
5296 n->ip,
5297 n->port);
5298 for (i = 0; i < n->migrating_count; i += 2) {
5299 sds slot = n->migrating[i];
5300 dictReplace(open_slots, slot, sdsdup(n->migrating[i + 1]));
5301 char *fmt = (i > 0 ? ",%S" : "%S");
5302 errstr = sdscatfmt(errstr, fmt, slot);
5303 }
5304 errstr = sdscat(errstr, ".");
5305 clusterManagerOnError(errstr);
5306 }
5307 if (n->importing != NULL) {
5308 if (open_slots == NULL)
5309 open_slots = dictCreate(&clusterManagerDictType, NULL);
5310 sds errstr = sdsempty();
5311 errstr = sdscatprintf(errstr,
5312 "[WARNING] Node %s:%d has slots in "
5313 "importing state ",
5314 n->ip,
5315 n->port);
5316 for (i = 0; i < n->importing_count; i += 2) {
5317 sds slot = n->importing[i];
5318 dictReplace(open_slots, slot, sdsdup(n->importing[i + 1]));
5319 char *fmt = (i > 0 ? ",%S" : "%S");

Calls 15

clusterManagerShowNodesFunction · 0.85
sdsnewFunction · 0.85
clusterManagerOnErrorFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
sdsemptyFunction · 0.85
sdscatprintfFunction · 0.85
sdsdupFunction · 0.85
sdscatfmtFunction · 0.85
sdscatFunction · 0.85
sdsfreeFunction · 0.85

Tested by

no test coverage detected