MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / clusterManagerCommandSetTimeout

Function clusterManagerCommandSetTimeout

src/redis-cli.c:5544–5600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5542}
5543
5544static int clusterManagerCommandSetTimeout(int argc, char **argv) {
5545 UNUSED(argc);
5546 int port = 0;
5547 char *ip = NULL;
5548 if (!getClusterHostFromCmdArgs(1, argv, &ip, &port)) goto invalid_args;
5549 int timeout = atoi(argv[1]);
5550 if (timeout < 100) {
5551 fprintf(stderr, "Setting a node timeout of less than 100 "
5552 "milliseconds is a bad idea.\n");
5553 return 0;
5554 }
5555 // Load cluster information
5556 clusterManagerNode *node = clusterManagerNewNode(ip, port);
5557 if (!clusterManagerLoadInfoFromNode(node, 0)) return 0;
5558 int ok_count = 0, err_count = 0;
5559
5560 clusterManagerLogInfo(">>> Reconfiguring node timeout in every "
5561 "cluster node...\n");
5562 listIter li;
5563 listNode *ln;
5564 listRewind(cluster_manager.nodes, &li);
5565 while ((ln = listNext(&li)) != NULL) {
5566 clusterManagerNode *n = ln->value;
5567 char *err = NULL;
5568 redisReply *reply = CLUSTER_MANAGER_COMMAND(n, "CONFIG %s %s %d",
5569 "SET",
5570 "cluster-node-timeout",
5571 timeout);
5572 if (reply == NULL) goto reply_err;
5573 int ok = clusterManagerCheckRedisReply(n, reply, &err);
5574 freeReplyObject(reply);
5575 if (!ok) goto reply_err;
5576 reply = CLUSTER_MANAGER_COMMAND(n, "CONFIG %s", "REWRITE");
5577 if (reply == NULL) goto reply_err;
5578 ok = clusterManagerCheckRedisReply(n, reply, &err);
5579 freeReplyObject(reply);
5580 if (!ok) goto reply_err;
5581 clusterManagerLogWarn("*** New timeout set for %s:%d\n", n->ip,
5582 n->port);
5583 ok_count++;
5584 continue;
5585reply_err:;
5586 int need_free = 0;
5587 if (err == NULL) err = "";
5588 else need_free = 1;
5589 clusterManagerLogErr("ERR setting node-timeot for %s:%d: %s\n", n->ip,
5590 n->port, err);
5591 if (need_free) zfree(err);
5592 err_count++;
5593 }
5594 clusterManagerLogInfo(">>> New node timeout set. %d OK, %d ERR.\n",
5595 ok_count, err_count);
5596 return 1;
5597invalid_args:
5598 fprintf(stderr, CLUSTER_MANAGER_INVALID_HOST_ARG);
5599 return 0;
5600}
5601

Callers

nothing calls this directly

Calls 8

clusterManagerNewNodeFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
freeReplyObjectFunction · 0.85
zfreeFunction · 0.85

Tested by

no test coverage detected