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

Function clusterManagerCommandCall

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

Source from the content-addressed store, hash-verified

6668}
6669
6670static int clusterManagerCommandCall(int argc, char **argv) {
6671 int port = 0, i;
6672 char *ip = NULL;
6673 if (!getClusterHostFromCmdArgs(1, argv, &ip, &port)) goto invalid_args;
6674 clusterManagerNode *refnode = clusterManagerNewNode(ip, port);
6675 if (!clusterManagerLoadInfoFromNode(refnode, 0)) return 0;
6676 argc--;
6677 argv++;
6678 size_t *argvlen = zmalloc(argc*sizeof(size_t));
6679 clusterManagerLogInfo(">>> Calling");
6680 for (i = 0; i < argc; i++) {
6681 argvlen[i] = strlen(argv[i]);
6682 printf(" %s", argv[i]);
6683 }
6684 printf("\n");
6685 listIter li;
6686 listNode *ln;
6687 listRewind(cluster_manager.nodes, &li);
6688 while ((ln = listNext(&li)) != NULL) {
6689 clusterManagerNode *n = ln->value;
6690 if ((config.cluster_manager_command.flags & CLUSTER_MANAGER_CMD_FLAG_MASTERS_ONLY)
6691 && (n->replicate != NULL)) continue; // continue if node is slave
6692 if ((config.cluster_manager_command.flags & CLUSTER_MANAGER_CMD_FLAG_SLAVES_ONLY)
6693 && (n->replicate == NULL)) continue; // continue if node is master
6694 if (!n->context && !clusterManagerNodeConnect(n)) continue;
6695 redisReply *reply = NULL;
6696 redisAppendCommandArgv(n->context, argc, (const char **) argv, argvlen);
6697 int status = redisGetReply(n->context, (void **)(&reply));
6698 if (status != REDIS_OK || reply == NULL )
6699 printf("%s:%d: Failed!\n", n->ip, n->port);
6700 else {
6701 sds formatted_reply = cliFormatReplyRaw(reply);
6702 printf("%s:%d: %s\n", n->ip, n->port, (char *) formatted_reply);
6703 sdsfree(formatted_reply);
6704 }
6705 if (reply != NULL) freeReplyObject(reply);
6706 }
6707 zfree(argvlen);
6708 return 1;
6709invalid_args:
6710 fprintf(stderr, CLUSTER_MANAGER_INVALID_HOST_ARG);
6711 return 0;
6712}
6713
6714static int clusterManagerCommandBackup(int argc, char **argv) {
6715 UNUSED(argc);

Callers

nothing calls this directly

Calls 14

clusterManagerNewNodeFunction · 0.85
zmallocFunction · 0.85
listRewindFunction · 0.85
listNextFunction · 0.85
redisAppendCommandArgvFunction · 0.85
redisGetReplyFunction · 0.85
cliFormatReplyRawFunction · 0.85
sdsfreeFunction · 0.85
freeReplyObjectFunction · 0.85

Tested by

no test coverage detected