MCPcopy Create free account
hub / github.com/F-Stack/f-stack / createClusterNode

Function createClusterNode

app/redis-6.2.6/src/cluster.c:781–812  ·  view source on GitHub ↗

Create a new cluster node, with the specified flags. * If "nodename" is NULL this is considered a first handshake and a random * node name is assigned to this node (it will be fixed later when we'll * receive the first pong). * * The node is created and returned to the user, but it is not automatically * added to the nodes hash table. */

Source from the content-addressed store, hash-verified

779 * The node is created and returned to the user, but it is not automatically
780 * added to the nodes hash table. */
781clusterNode *createClusterNode(char *nodename, int flags) {
782 clusterNode *node = zmalloc(sizeof(*node));
783
784 if (nodename)
785 memcpy(node->name, nodename, CLUSTER_NAMELEN);
786 else
787 getRandomHexChars(node->name, CLUSTER_NAMELEN);
788 node->ctime = mstime();
789 node->configEpoch = 0;
790 node->flags = flags;
791 memset(node->slots,0,sizeof(node->slots));
792 node->slots_info = NULL;
793 node->numslots = 0;
794 node->numslaves = 0;
795 node->slaves = NULL;
796 node->slaveof = NULL;
797 node->ping_sent = node->pong_received = 0;
798 node->data_received = 0;
799 node->fail_time = 0;
800 node->link = NULL;
801 memset(node->ip,0,sizeof(node->ip));
802 node->port = 0;
803 node->cport = 0;
804 node->pport = 0;
805 node->fail_reports = listCreate();
806 node->voted_time = 0;
807 node->orphaned_time = 0;
808 node->repl_offset_time = 0;
809 node->repl_offset = 0;
810 listSetFreeMethod(node->fail_reports,zfree);
811 return node;
812}
813
814/* This function is called every time we get a failure report from a node.
815 * The side effect is to populate the fail_reports list (or to update

Callers 5

clusterLoadConfigFunction · 0.70
clusterInitFunction · 0.70
clusterStartHandshakeFunction · 0.70
clusterProcessPacketFunction · 0.70

Calls 6

zmallocFunction · 0.85
getRandomHexCharsFunction · 0.85
memsetFunction · 0.85
listCreateFunction · 0.85
mstimeFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected