Commit 3dad8196 authored by antirez's avatar antirez
Browse files

Cluster: clusterUpdateState() function simplified.

Also the NEEDHELP Cluster state was removed as it will no longer be
used by Redis Cluster.
parent 042ed270
...@@ -1450,30 +1450,22 @@ int clusterDelSlot(int slot) { ...@@ -1450,30 +1450,22 @@ int clusterDelSlot(int slot) {
* Cluster state evaluation function * Cluster state evaluation function
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
void clusterUpdateState(void) { void clusterUpdateState(void) {
int ok = 1;
int j; int j;
/* Start assuming the state is OK. We'll turn it into FAIL if there
* are the right conditions. */
server.cluster->state = REDIS_CLUSTER_OK;
/* Check if all the slots are covered. */ /* Check if all the slots are covered. */
for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) { for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) {
if (server.cluster->slots[j] == NULL || if (server.cluster->slots[j] == NULL ||
server.cluster->slots[j]->flags & (REDIS_NODE_FAIL)) server.cluster->slots[j]->flags & (REDIS_NODE_FAIL))
{ {
ok = 0; server.cluster->state = REDIS_CLUSTER_FAIL;
break; break;
} }
} }
/* Update cluster->state accordingly. */
if (ok) {
if (server.cluster->state == REDIS_CLUSTER_NEEDHELP) {
server.cluster->state = REDIS_CLUSTER_NEEDHELP;
} else {
server.cluster->state = REDIS_CLUSTER_OK;
}
} else {
server.cluster->state = REDIS_CLUSTER_FAIL;
}
/* Compute the cluster size, that is the number of master nodes /* Compute the cluster size, that is the number of master nodes
* serving at least a single slot. */ * serving at least a single slot. */
{ {
......
...@@ -518,7 +518,6 @@ typedef struct redisOpArray { ...@@ -518,7 +518,6 @@ typedef struct redisOpArray {
#define REDIS_CLUSTER_SLOTS 16384 #define REDIS_CLUSTER_SLOTS 16384
#define REDIS_CLUSTER_OK 0 /* Everything looks ok */ #define REDIS_CLUSTER_OK 0 /* Everything looks ok */
#define REDIS_CLUSTER_FAIL 1 /* The cluster can't work */ #define REDIS_CLUSTER_FAIL 1 /* The cluster can't work */
#define REDIS_CLUSTER_NEEDHELP 2 /* The cluster works, but needs some help */
#define REDIS_CLUSTER_NAMELEN 40 /* sha1 hex length */ #define REDIS_CLUSTER_NAMELEN 40 /* sha1 hex length */
#define REDIS_CLUSTER_PORT_INCR 10000 /* Cluster port = baseport + PORT_INCR */ #define REDIS_CLUSTER_PORT_INCR 10000 /* Cluster port = baseport + PORT_INCR */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment