redis 4.0 cluster方式
每隔一段时间去检查各个节点的状态,主要的函数如下:
cluster node信息的存放位置:server.cluster->nodes
server.c ->serverCron->
This is executed 10 times every second
cluster.c->clusterCron
遍历nodes的后通过网络的连接查看节点是否存活
fd = anetTcpNonBlockBindConnect(server.neterr, node->ip,node->cport, NET_FIRST_BIND_ADDR);
放入nio监听事件循环
aeCreateFileEvent(server.el,link->fd,AE_READABLE,clusterReadHandler,link);
发送ping命令
clusterSendPing(link, node->flags & CLUSTER_NODE_MEET ?CLUSTERMSG_TYPE_MEET : CLUSTERMSG_TYPE_PING);