提交 68cf249f 编写于 作者: A antirez

Cluster: use server.cluster_node_timeout directly.

We used to copy this value into the server.cluster structure, however this
was not necessary.

The reason why we don't directly use server.cluster->node_timeout is
that things that can be configured via redis.conf need to be directly
available in the server structure as server.cluster is allocated later
only if needed in order to reduce the memory footprint of non-cluster
instances.
上级 ef4f25ff
......@@ -231,7 +231,6 @@ void clusterInit(void) {
server.cluster->state = REDIS_CLUSTER_FAIL;
server.cluster->size = 1;
server.cluster->nodes = dictCreate(&clusterNodesDictType,NULL);
server.cluster->node_timeout = server.cluster_node_timeout;
server.cluster->failover_auth_time = 0;
server.cluster->failover_auth_count = 0;
memset(server.cluster->migrating_slots_to,0,
......@@ -403,7 +402,7 @@ void clusterNodeCleanupFailureReports(clusterNode *node) {
listNode *ln;
listIter li;
clusterNodeFailReport *fr;
time_t maxtime = server.cluster->node_timeout *
time_t maxtime = server.cluster_node_timeout *
REDIS_CLUSTER_FAIL_REPORT_VALIDITY_MULT;
time_t now = time(NULL);
......@@ -639,7 +638,7 @@ void clearNodeFailureIfNeeded(clusterNode *node) {
if (node->flags & REDIS_NODE_MASTER &&
node->numslots > 0 &&
(now - node->fail_time) >
(server.cluster->node_timeout * REDIS_CLUSTER_FAIL_UNDO_TIME_MULT +
(server.cluster_node_timeout * REDIS_CLUSTER_FAIL_UNDO_TIME_MULT +
REDIS_CLUSTER_FAIL_UNDO_TIME_ADD))
{
redisLog(REDIS_NOTICE,
......@@ -1422,7 +1421,7 @@ void clusterHandleSlaveFailover(void) {
* constant of ten times the node timeout since the cluster should
* react much faster to a master down. */
if (data_age >
server.cluster->node_timeout * REDIS_CLUSTER_SLAVE_VALIDITY_MULT)
server.cluster_node_timeout * REDIS_CLUSTER_SLAVE_VALIDITY_MULT)
return;
/* TODO: check if we are the first slave as well? Or just rely on the
......@@ -1432,7 +1431,7 @@ void clusterHandleSlaveFailover(void) {
* is a pending auth request that's too old, reset it. */
if (server.cluster->failover_auth_time == 0 ||
auth_age >
server.cluster->node_timeout * REDIS_CLUSTER_FAILOVER_AUTH_RETRY_MULT)
server.cluster_node_timeout * REDIS_CLUSTER_FAILOVER_AUTH_RETRY_MULT)
{
redisLog(REDIS_WARNING,"Asking masters if I can failover...");
server.cluster->failover_auth_time = time(NULL);
......@@ -1555,7 +1554,7 @@ void clusterCron(void) {
/* If our ping is older than half the cluster timeout (may happen
* in a cluster with many nodes), send a new ping. */
if (node->link &&
(now - node->ping_sent) > server.cluster->node_timeout/2)
(now - node->ping_sent) > server.cluster_node_timeout/2)
{
clusterSendPing(node->link, CLUSTERMSG_TYPE_PING);
continue;
......@@ -1574,7 +1573,7 @@ void clusterCron(void) {
delay = now - node->ping_sent;
}
if (delay < server.cluster->node_timeout) {
if (delay < server.cluster_node_timeout) {
/* The PFAIL condition can be reversed without external
* help if it is not transitive (that is, if it does not
* turn into a FAIL state).
......
......@@ -583,7 +583,6 @@ typedef struct {
clusterNode *myself; /* This node */
int state; /* REDIS_CLUSTER_OK, REDIS_CLUSTER_FAIL, ... */
int size; /* Num of master nodes with at least one slot */
int node_timeout;
dict *nodes; /* Hash table of name -> clusterNode structures */
clusterNode *migrating_slots_to[REDIS_CLUSTER_SLOTS];
clusterNode *importing_slots_from[REDIS_CLUSTER_SLOTS];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册