From c285862621b2db70ec9152f5e081a091d49a0a45 Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 29 Jan 2016 12:00:38 +0100 Subject: [PATCH] Cluster: include node IDs in SLOTS output. CLUSTER SLOTS now includes IDs in the nodes description associated with a given slot range. Certain client libraries implementations need a way to reference a node in an unique way, so they were relying on CLUSTER NODES, that is not a stable API and may change frequently depending on Redis Cluster future requirements. --- src/cluster.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 51cd3e216..387f45a62 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -3774,8 +3774,10 @@ void clusterReplyMultiBulkSlots(client *c) { * 2) end slot * 3) 1) master IP * 2) master port + * 3) node ID * 4) 1) replica IP * 2) replica port + * 3) node ID * ... continued until done */ @@ -3816,18 +3818,20 @@ void clusterReplyMultiBulkSlots(client *c) { start = -1; /* First node reply position is always the master */ - addReplyMultiBulkLen(c, 2); + addReplyMultiBulkLen(c, 3); addReplyBulkCString(c, node->ip); addReplyLongLong(c, node->port); + addReplyBulkCBuffer(c, node->name, CLUSTER_NAMELEN); /* Remaining nodes in reply are replicas for slot range */ for (i = 0; i < node->numslaves; i++) { /* This loop is copy/pasted from clusterGenNodeDescription() * with modifications for per-slot node aggregation */ if (nodeFailed(node->slaves[i])) continue; - addReplyMultiBulkLen(c, 2); + addReplyMultiBulkLen(c, 3); addReplyBulkCString(c, node->slaves[i]->ip); addReplyLongLong(c, node->slaves[i]->port); + addReplyBulkCBuffer(c, node->slaves[i]->name, CLUSTER_NAMELEN); nested_elements++; } setDeferredMultiBulkLength(c, nested_replylen, nested_elements);