Skip to content

Commit

Permalink
update method name and adds documentations.
Browse files Browse the repository at this point in the history
Signed-off-by: Roshan Khatri <[email protected]>
  • Loading branch information
roshkhatri committed May 13, 2024
1 parent a0415c8 commit d4c06b6
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ ConnectionType *connTypeOfCluster(void);

int isClusterSlotsResponseCached(connTypeForCaching conn_type);
sds getClusterSlotReply(connTypeForCaching conn_type);
void clearCachedClusterSlotsResp(void);
void clearCachedClusterSlotsResponse(void);
void cacheSlotsResponse(sds response_to_cache, connTypeForCaching conn_type);
void updateAllCachedNodesHealth(void);
int isNodeAvailable(clusterNode *node);
Expand Down
36 changes: 18 additions & 18 deletions src/cluster_legacy.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ sds getClusterSlotReply(connTypeForCaching conn_type) {
return server.cluster->cached_cluster_slot_info[conn_type];
}

void clearCachedClusterSlotsResp(void) {
void clearCachedClusterSlotsResponse(void) {
for (connTypeForCaching conn_type = CACHE_CONN_TCP; conn_type < CACHE_CONN_TYPE_MAX; conn_type++) {
if (server.cluster->cached_cluster_slot_info[conn_type]) {
sdsfree(server.cluster->cached_cluster_slot_info[conn_type]);
Expand Down Expand Up @@ -520,7 +520,7 @@ int clusterLoadConfig(char *filename) {
}
*p = '\0';
memcpy(n->ip,aux_argv[0],strlen(aux_argv[0])+1);
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
char *port = p+1;
char *busp = strchr(port,'@');
if (busp) {
Expand Down Expand Up @@ -916,7 +916,7 @@ void clusterUpdateMyselfIp(void) {
} else {
myself->ip[0] = '\0'; /* Force autodetection. */
}
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
}
}

Expand All @@ -934,7 +934,7 @@ static void updateAnnouncedHostname(clusterNode *node, char *new) {
} else if (sdslen(node->hostname) != 0) {
sdsclear(node->hostname);
}
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG);
}

Expand Down Expand Up @@ -1528,7 +1528,7 @@ int clusterNodeAddSlave(clusterNode *master, clusterNode *slave) {
master->numslaves++;
qsort(master->slaves, master->numslaves, sizeof(clusterNode *), clusterNodeNameComparator);
master->flags |= CLUSTER_NODE_MIGRATE_TO;
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
return C_OK;
}

Expand Down Expand Up @@ -1575,7 +1575,7 @@ void clusterAddNode(clusterNode *node) {
retval = dictAdd(server.cluster->nodes,
sdsnewlen(node->name,CLUSTER_NAMELEN), node);
serverAssert(retval == DICT_OK);
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
}

/* Remove a node from the cluster. The function performs the high level
Expand Down Expand Up @@ -1617,7 +1617,7 @@ void clusterDelNode(clusterNode *delnode) {

/* 3) Remove the node from the owning shard */
clusterRemoveNodeFromShard(delnode);
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();

/* 4) Free the node, unlinking it from the cluster. */
freeClusterNode(delnode);
Expand Down Expand Up @@ -2237,7 +2237,7 @@ void clusterProcessGossipSection(clusterMsg *hdr, clusterLink *link) {
node->tls_port = msg_tls_port;
node->cport = ntohs(g->cport);
node->flags &= ~CLUSTER_NODE_NOADDR;
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
}
} else if (!node) {
/* If it's not in NOADDR state and we don't have it, we
Expand Down Expand Up @@ -2333,7 +2333,7 @@ int nodeUpdateAddressIfNeeded(clusterNode *node, clusterLink *link,
serverLog(LL_NOTICE,"Address updated for node %.40s (%s), now %s:%d",
node->name, node->human_nodename, node->ip, getNodeDefaultClientPort(node));

clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
/* Check if this is our master and we have to change the
* replication target as well. */
if (nodeIsSlave(myself) && myself->slaveof == node)
Expand All @@ -2355,7 +2355,7 @@ void clusterSetNodeAsMaster(clusterNode *n) {
n->flags |= CLUSTER_NODE_MASTER;
n->slaveof = NULL;

clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
/* Update config and state. */
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG|
CLUSTER_TODO_UPDATE_STATE);
Expand Down Expand Up @@ -2401,7 +2401,7 @@ void clusterUpdateSlotsConfigWith(clusterNode *sender, uint64_t senderConfigEpoc
return;
}

clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();

for (j = 0; j < CLUSTER_SLOTS; j++) {
if (bitmapTestBit(slots,j)) {
Expand Down Expand Up @@ -3090,7 +3090,7 @@ int clusterProcessPacket(clusterLink *link) {
strcmp(ip,myself->ip))
{
memcpy(myself->ip,ip,NET_IP_STR_LEN);
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
serverLog(LL_NOTICE,"IP address for this node updated to %s",
myself->ip);
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG);
Expand Down Expand Up @@ -3176,7 +3176,7 @@ int clusterProcessPacket(clusterLink *link) {
link->node->cport = 0;
freeClusterLink(link);
clusterDoBeforeSleep(CLUSTER_TODO_SAVE_CONFIG);
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
return 0;
}
}
Expand Down Expand Up @@ -4491,7 +4491,7 @@ void clusterFailoverReplaceYourMaster(void) {
/* 3) Update state and save config. */
clusterUpdateState();
clusterSaveConfigOrDie(1);
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();

/* 4) Pong all the other nodes so that they can update the state
* accordingly and detect that we switched to master role. */
Expand Down Expand Up @@ -4546,7 +4546,7 @@ void clusterHandleSlaveFailover(void) {
server.cluster->cant_failover_reason = CLUSTER_CANT_FAILOVER_NONE;
return;
}
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();

/* Set data_age to the number of milliseconds we are disconnected from
* the master. */
Expand Down Expand Up @@ -5277,7 +5277,7 @@ int clusterAddSlot(clusterNode *n, int slot) {
if (server.cluster->slots[slot]) return C_ERR;
clusterNodeSetSlotBit(n,slot);
server.cluster->slots[slot] = n;
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
bitmapClearBit(server.cluster->owner_not_claiming_slot, slot);
return C_OK;
}
Expand All @@ -5297,7 +5297,7 @@ int clusterDelSlot(int slot) {
server.cluster->slots[slot] = NULL;
/* Make owner_not_claiming_slot flag consistent with slot ownership information. */
bitmapClearBit(server.cluster->owner_not_claiming_slot, slot);
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
return C_OK;
}

Expand Down Expand Up @@ -6954,7 +6954,7 @@ void updateAllCachedNodesHealth(void) {
}
}

if (overall_health_changed) clearCachedClusterSlotsResp();
if (overall_health_changed) clearCachedClusterSlotsResponse();
}

/* Replicate migrating and importing slot states to all replicas */
Expand Down
2 changes: 1 addition & 1 deletion src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -2588,7 +2588,7 @@ static int updateOOMScoreAdj(const char **err) {

int invalidateClusterSlotsResp(const char **err) {
UNUSED(err);
clearCachedClusterSlotsResp();
clearCachedClusterSlotsResponse();
return 1;
}

Expand Down
2 changes: 2 additions & 0 deletions src/networking.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ static sds getClientOutputBuffer(client *c) {
* It needs be paired with `stopCaching` function to stop caching. */
client *createCachedResponseClient(void) {
struct client *recording_client = createClient(NULL);
/* Allocationg the `conn` allows to prepare the caching client before adding more
* data to the clients output buffer by `prepareClientToWrite`. */
recording_client->conn = zcalloc(sizeof(connection));
return recording_client;
}
Expand Down

0 comments on commit d4c06b6

Please sign in to comment.