mirror of https://github.com/citusdata/citus.git
Merge pull request #4053 from citusdata/unify_node_comparisions
Unify node sort orderingpull/4052/head
commit
d03c4aff2d
|
@ -1931,16 +1931,8 @@ WorkerPoolCompare(const void *lhsKey, const void *rhsKey)
|
||||||
const WorkerPool *workerLhs = *(const WorkerPool **) lhsKey;
|
const WorkerPool *workerLhs = *(const WorkerPool **) lhsKey;
|
||||||
const WorkerPool *workerRhs = *(const WorkerPool **) rhsKey;
|
const WorkerPool *workerRhs = *(const WorkerPool **) rhsKey;
|
||||||
|
|
||||||
int nameCompare = strncmp(workerLhs->nodeName, workerRhs->nodeName,
|
return NodeNamePortCompare(workerLhs->nodeName, workerRhs->nodeName,
|
||||||
WORKER_LENGTH);
|
workerLhs->nodePort, workerRhs->nodePort);
|
||||||
|
|
||||||
if (nameCompare != 0)
|
|
||||||
{
|
|
||||||
return nameCompare;
|
|
||||||
}
|
|
||||||
|
|
||||||
int portCompare = workerLhs->nodePort - workerRhs->nodePort;
|
|
||||||
return portCompare;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -584,15 +584,30 @@ WorkerNodeCompare(const void *lhsKey, const void *rhsKey, Size keySize)
|
||||||
const WorkerNode *workerLhs = (const WorkerNode *) lhsKey;
|
const WorkerNode *workerLhs = (const WorkerNode *) lhsKey;
|
||||||
const WorkerNode *workerRhs = (const WorkerNode *) rhsKey;
|
const WorkerNode *workerRhs = (const WorkerNode *) rhsKey;
|
||||||
|
|
||||||
|
return NodeNamePortCompare(workerLhs->workerName, workerRhs->workerName,
|
||||||
|
workerLhs->workerPort, workerRhs->workerPort);
|
||||||
|
}
|
||||||
|
|
||||||
int nameCompare = strncmp(workerLhs->workerName, workerRhs->workerName,
|
|
||||||
WORKER_LENGTH);
|
/*
|
||||||
|
* NodeNamePortCompare implements the common logic for comparing two nodes
|
||||||
|
* with their given nodeNames and ports.
|
||||||
|
*
|
||||||
|
* This function is useful for ensuring consistency of sort operations between
|
||||||
|
* different representations of nodes in the cluster such as WorkerNode and
|
||||||
|
* WorkerPool.
|
||||||
|
*/
|
||||||
|
int
|
||||||
|
NodeNamePortCompare(const char *workerLhsName, const char *workerRhsName,
|
||||||
|
int workerLhsPort, int workerRhsPort)
|
||||||
|
{
|
||||||
|
int nameCompare = strncmp(workerLhsName, workerRhsName, WORKER_LENGTH);
|
||||||
if (nameCompare != 0)
|
if (nameCompare != 0)
|
||||||
{
|
{
|
||||||
return nameCompare;
|
return nameCompare;
|
||||||
}
|
}
|
||||||
|
|
||||||
int portCompare = workerLhs->workerPort - workerRhs->workerPort;
|
int portCompare = workerLhsPort - workerRhsPort;
|
||||||
return portCompare;
|
return portCompare;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,5 +96,7 @@ extern WorkerNode * GetFirstPrimaryWorkerNode(void);
|
||||||
/* Function declarations for worker node utilities */
|
/* Function declarations for worker node utilities */
|
||||||
extern int CompareWorkerNodes(const void *leftElement, const void *rightElement);
|
extern int CompareWorkerNodes(const void *leftElement, const void *rightElement);
|
||||||
extern int WorkerNodeCompare(const void *lhsKey, const void *rhsKey, Size keySize);
|
extern int WorkerNodeCompare(const void *lhsKey, const void *rhsKey, Size keySize);
|
||||||
|
extern int NodeNamePortCompare(const char *workerLhsName, const char *workerRhsName,
|
||||||
|
int workerLhsPort, int workerRhsPort);
|
||||||
|
|
||||||
#endif /* WORKER_MANAGER_H */
|
#endif /* WORKER_MANAGER_H */
|
||||||
|
|
Loading…
Reference in New Issue