提交 8f18345e 编写于 作者: A antirez

Cluster: basic data structures for nodes black list.

上级 3db825fd
...@@ -260,6 +260,8 @@ void clusterInit(void) { ...@@ -260,6 +260,8 @@ void clusterInit(void) {
server.cluster->state = REDIS_CLUSTER_FAIL; server.cluster->state = REDIS_CLUSTER_FAIL;
server.cluster->size = 1; server.cluster->size = 1;
server.cluster->nodes = dictCreate(&clusterNodesDictType,NULL); server.cluster->nodes = dictCreate(&clusterNodesDictType,NULL);
server.cluster->nodes_black_list =
dictCreate(&clusterNodesBlackListDictType,NULL);
server.cluster->failover_auth_time = 0; server.cluster->failover_auth_time = 0;
server.cluster->failover_auth_count = 0; server.cluster->failover_auth_count = 0;
server.cluster->failover_auth_epoch = 0; server.cluster->failover_auth_epoch = 0;
......
...@@ -78,6 +78,7 @@ typedef struct clusterState { ...@@ -78,6 +78,7 @@ typedef struct clusterState {
int state; /* REDIS_CLUSTER_OK, REDIS_CLUSTER_FAIL, ... */ int state; /* REDIS_CLUSTER_OK, REDIS_CLUSTER_FAIL, ... */
int size; /* Num of master nodes with at least one slot */ int size; /* Num of master nodes with at least one slot */
dict *nodes; /* Hash table of name -> clusterNode structures */ dict *nodes; /* Hash table of name -> clusterNode structures */
dict *nodes_black_list; /* Nodes we don't re-add for a few seconds. */
clusterNode *migrating_slots_to[REDIS_CLUSTER_SLOTS]; clusterNode *migrating_slots_to[REDIS_CLUSTER_SLOTS];
clusterNode *importing_slots_from[REDIS_CLUSTER_SLOTS]; clusterNode *importing_slots_from[REDIS_CLUSTER_SLOTS];
clusterNode *slots[REDIS_CLUSTER_SLOTS]; clusterNode *slots[REDIS_CLUSTER_SLOTS];
......
...@@ -583,6 +583,18 @@ dictType clusterNodesDictType = { ...@@ -583,6 +583,18 @@ dictType clusterNodesDictType = {
NULL /* val destructor */ NULL /* val destructor */
}; };
/* Cluster re-addition blacklist. This maps node IDs to the time
* we can re-add this node. The goal is to avoid readding a removed
* node for some time. */
dictType clusterNodesBlackListDictType = {
dictSdsCaseHash, /* hash function */
NULL, /* key dup */
NULL, /* val dup */
dictSdsKeyCaseCompare, /* key compare */
dictSdsDestructor, /* key destructor */
NULL /* val destructor */
};
/* Migrate cache dict type. */ /* Migrate cache dict type. */
dictType migrateCacheDictType = { dictType migrateCacheDictType = {
dictSdsHash, /* hash function */ dictSdsHash, /* hash function */
......
...@@ -884,6 +884,7 @@ extern struct sharedObjectsStruct shared; ...@@ -884,6 +884,7 @@ extern struct sharedObjectsStruct shared;
extern dictType setDictType; extern dictType setDictType;
extern dictType zsetDictType; extern dictType zsetDictType;
extern dictType clusterNodesDictType; extern dictType clusterNodesDictType;
extern dictType clusterNodesBlackListDictType;
extern dictType dbDictType; extern dictType dbDictType;
extern dictType shaScriptObjectDictType; extern dictType shaScriptObjectDictType;
extern double R_Zero, R_PosInf, R_NegInf, R_Nan; extern double R_Zero, R_PosInf, R_NegInf, R_Nan;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册