Skip to content

Commit

Permalink
Cluster: CLUSTER SLAVES subcommand added.
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jan 22, 2014
1 parent 603e480 commit 5383ab0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -2939,6 +2939,28 @@ void clusterCommand(redisClient *c) {
clusterSetMaster(n);
clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE|CLUSTER_TODO_SAVE_CONFIG);
addReply(c,shared.ok);
} else if (!strcasecmp(c->argv[1]->ptr,"slaves") && c->argc == 3) {
/* CLUSTER SLAVES <NODE ID> */
clusterNode *n = clusterLookupNode(c->argv[2]->ptr);
int j;

/* Lookup the specified node in our table. */
if (!n) {
addReplyErrorFormat(c,"Unknown node %s", (char*)c->argv[2]->ptr);
return;
}

if (n->flags & REDIS_NODE_SLAVE) {
addReplyError(c,"The specified node is not a master");
return;
}

addReplyMultiBulkLen(c,n->numslaves);
for (j = 0; j < n->numslaves; j++) {
sds ni = clusterGenNodeDescription(n->slaves[j]);
addReplyBulkCString(c,ni);
sdsfree(ni);
}
} else {
addReplyError(c,"Wrong CLUSTER subcommand or number of arguments");
}
Expand Down

0 comments on commit 5383ab0

Please sign in to comment.