Skip to content

Commit

Permalink
Cluster refactor: fn renames + small compilation issue on ubuntu
Browse files Browse the repository at this point in the history
Signed-off-by: Josh Hershberg <[email protected]>
  • Loading branch information
Josh Hershberg committed Nov 22, 2023
1 parent 13b7548 commit 290f376
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 65 deletions.
26 changes: 13 additions & 13 deletions src/cluster.c
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ void clusterCommandHelp(client *c) {
NULL
};

addExtendedReplyHelp(c, help, clusterCommandSpecialHelp());
addExtendedReplyHelp(c, help, clusterCommandExtendedHelp());
}

void clusterCommand(client *c) {
Expand Down Expand Up @@ -911,9 +911,9 @@ void clusterCommand(client *c) {
}

/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
addReplyArrayLen(c, getNumSlaves(n));
for (j = 0; j < getNumSlaves(n); j++) {
sds ni = clusterGenNodeDescription(c, getSlave(n, j), shouldReturnTlsInfo());
addReplyArrayLen(c, clusterNodeNumSlaves(n));
for (j = 0; j < clusterNodeNumSlaves(n); j++) {
sds ni = clusterGenNodeDescription(c, clusterNodeGetSlave(n, j), shouldReturnTlsInfo());
addReplyBulkCString(c,ni);
sdsfree(ni);
}
Expand Down Expand Up @@ -1193,11 +1193,11 @@ void clusterRedirectClient(client *c, clusterNode *n, int hashslot, int error_co
error_code == CLUSTER_REDIR_ASK)
{
/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
int port = getNodeClientPort(n, shouldReturnTlsInfo());
int port = clusterNodeClientPort(n, shouldReturnTlsInfo());
addReplyErrorSds(c,sdscatprintf(sdsempty(),
"-%s %d %s:%d",
(error_code == CLUSTER_REDIR_ASK) ? "ASK" : "MOVED",
hashslot, getPreferredEndpoint(n), port));
hashslot, clusterNodePreferredEndpoint(n), port));
} else {
serverPanic("getNodeByQuery() unknown error.");
}
Expand Down Expand Up @@ -1285,7 +1285,7 @@ static int isReplicaAvailable(clusterNode *node) {
if (clusterNodeIsFailing(node)) {
return 0;
}
long long repl_offset = getReplOffset(node);
long long repl_offset = clusterNodeReplOffset(node);
if (clusterNodeIsMyself(node)) {
/* Nodes do not update their own information
* in the cluster node list. */
Expand All @@ -1312,7 +1312,7 @@ void addNodeToNodeReply(client *c, clusterNode *node) {
}

/* Report TLS ports to TLS client, and report non-TLS port to non-TLS client. */
addReplyLongLong(c, getNodeClientPort(node, shouldReturnTlsInfo()));
addReplyLongLong(c, clusterNodeClientPort(node, shouldReturnTlsInfo()));
addReplyBulkCBuffer(c, clusterNodeGetName(node), CLUSTER_NAMELEN);

/* Add the additional endpoint information, this is all the known networking information
Expand Down Expand Up @@ -1347,8 +1347,8 @@ void addNodeToNodeReply(client *c, clusterNode *node) {

void addNodeReplyForClusterSlot(client *c, clusterNode *node, int start_slot, int end_slot) {
int i, nested_elements = 3; /* slots (2) + master addr (1) */
for (i = 0; i < getNumSlaves(node); i++) {
if (!isReplicaAvailable(getSlave(node, i))) continue;
for (i = 0; i < clusterNodeNumSlaves(node); i++) {
if (!isReplicaAvailable(clusterNodeGetSlave(node, i))) continue;
nested_elements++;
}
addReplyArrayLen(c, nested_elements);
Expand All @@ -1357,11 +1357,11 @@ void addNodeReplyForClusterSlot(client *c, clusterNode *node, int start_slot, in
addNodeToNodeReply(c, node);

/* Remaining nodes in reply are replicas for slot range */
for (i = 0; i < getNumSlaves(node); i++) {
for (i = 0; i < clusterNodeNumSlaves(node); i++) {
/* This loop is copy/pasted from clusterGenNodeDescription()
* with modifications for per-slot node aggregation. */
if (!isReplicaAvailable(getSlave(node, i))) continue;
addNodeToNodeReply(c, getSlave(node, i));
if (!isReplicaAvailable(clusterNodeGetSlave(node, i))) continue;
addNodeToNodeReply(c, clusterNodeGetSlave(node, i));
nested_elements--;
}
serverAssert(nested_elements == 3); /* Original 3 elements */
Expand Down
18 changes: 9 additions & 9 deletions src/cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct clusterState;
/* ---------------------- API exported outside cluster.c -------------------- */
/* functions requiring mechanism specific implementations */
void clusterInit(void);
void clusterInitListeners(void);
void clusterInitLast(void);
void clusterCron(void);
void clusterBeforeSleep(void);
int verifyClusterConfigWithData(void);
Expand All @@ -59,10 +59,10 @@ sds clusterGenNodesDescription(client *c, int filter, int tls_primary);
sds genClusterInfoString(void);
/* handle implementation specific debug cluster commands. Return 1 if handled, 0 otherwise. */
int handleDebugClusterCommand(client *c);
const char **clusterDebugCommandHelp(void);
const char **clusterDebugCommandExtendedHelp(void);
/* handle implementation specific cluster commands. Return 1 if handled, 0 otherwise. */
int clusterCommandSpecial(client *c);
const char** clusterCommandSpecialHelp(void);
const char** clusterCommandExtendedHelp(void);

int clusterAllowFailoverCmd(client *c);
void clusterPromoteSelfToMaster(void);
Expand All @@ -81,9 +81,9 @@ clusterNode* getMyClusterNode(void);
char* getMyClusterId(void);
int getClusterSize(void);
char** getClusterNodesList(size_t *numnodes);
int nodeIsMaster(clusterNode *n);
int handleDebugClusterCommand(client *c);
int clusterNodePending(clusterNode *node);
int clusterNodeIsMaster(clusterNode *n);
char* clusterNodeIp(clusterNode *node);
int clusterNodeIsSlave(clusterNode *node);
clusterNode *clusterNodeGetSlaveof(clusterNode *node);
Expand All @@ -92,15 +92,15 @@ int clusterNodeTimedOut(clusterNode *node);
int clusterNodeIsFailing(clusterNode *node);
int clusterNodeIsNoFailover(clusterNode *node);
char* clusterNodeGetShardId(clusterNode *node);
int getNumSlaves(clusterNode *node);
clusterNode *getSlave(clusterNode *node, int slave_idx);
int clusterNodeNumSlaves(clusterNode *node);
clusterNode *clusterNodeGetSlave(clusterNode *node, int slave_idx);
clusterNode *getMigratingSlotDest(int slot);
clusterNode *getImportingSlotSource(int slot);
clusterNode *getNodeBySlot(int slot);
int getNodeClientPort(clusterNode *n, int use_tls);
int clusterNodeClientPort(clusterNode *n, int use_tls);
char* clusterNodeHostname(clusterNode *node);
const char *getPreferredEndpoint(clusterNode *n);
long long getReplOffset(clusterNode *node);
const char *clusterNodePreferredEndpoint(clusterNode *n);
long long clusterNodeReplOffset(clusterNode *node);
clusterNode *clusterLookupNode(const char *name, int length);

/* functions with shared implementations */
Expand Down
Loading

0 comments on commit 290f376

Please sign in to comment.