mirror of
https://github.com/fluencelabs/redis
synced 2025-06-13 01:01:22 +00:00
Cluster: clusterUpdateState() function simplified.
Also the NEEDHELP Cluster state was removed as it will no longer be used by Redis Cluster.
This commit is contained in:
@ -1450,30 +1450,22 @@ int clusterDelSlot(int slot) {
|
||||
* Cluster state evaluation function
|
||||
* -------------------------------------------------------------------------- */
|
||||
void clusterUpdateState(void) {
|
||||
int ok = 1;
|
||||
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. */
|
||||
for (j = 0; j < REDIS_CLUSTER_SLOTS; j++) {
|
||||
if (server.cluster->slots[j] == NULL ||
|
||||
server.cluster->slots[j]->flags & (REDIS_NODE_FAIL))
|
||||
{
|
||||
ok = 0;
|
||||
server.cluster->state = REDIS_CLUSTER_FAIL;
|
||||
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
|
||||
* serving at least a single slot. */
|
||||
{
|
||||
|
Reference in New Issue
Block a user