]> git.saurik.com Git - redis.git/blobdiff - src/cluster.c
Merge branch 'unstable' of github.com:antirez/redis into unstable
[redis.git] / src / cluster.c
index 6a693d6e90491a1e6f3c845f7f64ccdaa194864f..4e3cf74658141494810abe69a4e5997561fd1a4d 100644 (file)
@@ -134,6 +134,7 @@ int clusterLoadConfig(char *filename) {
     redisAssert(server.cluster.myself != NULL);
     redisLog(REDIS_NOTICE,"Node configuration loaded, I'm %.40s",
         server.cluster.myself->name);
+    clusterUpdateState();
     return REDIS_OK;
 
 fmterr:
@@ -631,7 +632,8 @@ int clusterProcessPacket(clusterLink *link) {
         clusterNode *failing;
 
         failing = clusterLookupNode(hdr->data.fail.about.nodename);
-        if (failing && !(failing->flags & REDIS_NODE_FAIL)) {
+        if (failing && !(failing->flags & (REDIS_NODE_FAIL|REDIS_NODE_MYSELF)))
+        {
             redisLog(REDIS_NOTICE,
                 "FAIL message received from %.40s about %.40s",
                 hdr->sender, hdr->data.fail.about.nodename);
@@ -941,6 +943,7 @@ void clusterCron(void) {
                 node->flags &= ~REDIS_NODE_PFAIL;
             } else if (node->flags & REDIS_NODE_FAIL && !node->numslaves) {
                 node->flags &= ~REDIS_NODE_FAIL;
+                clusterUpdateState();
             }
         } else {
             /* Timeout reached. Set the noad se possibly failing if it is
@@ -990,7 +993,7 @@ int clusterNodeGetSlotBit(clusterNode *n, int slot) {
  * an error and REDIS_ERR is returned. */
 int clusterAddSlot(clusterNode *n, int slot) {
     redisAssert(clusterNodeSetSlotBit(n,slot) == 0);
-    server.cluster.slots[slot] = server.cluster.myself;
+    server.cluster.slots[slot] = n;
     printf("SLOT %d added to %.40s\n", slot, n->name);
     return REDIS_OK;
 }
@@ -1190,11 +1193,13 @@ void clusterCommand(redisClient *c) {
             "cluster_slots_ok:%d\r\n"
             "cluster_slots_pfail:%d\r\n"
             "cluster_slots_fail:%d\r\n"
+            "cluster_known_nodes:%lu\r\n"
             , statestr[server.cluster.state],
             slots_assigned,
             slots_ok,
             slots_pfail,
-            slots_fail
+            slots_fail,
+            dictSize(server.cluster.nodes)
         );
         addReplySds(c,sdscatprintf(sdsempty(),"$%lu\r\n",
             (unsigned long)sdslen(info)));