timmylicheng commented on a change in pull request #668:
URL: https://github.com/apache/hadoop-ozone/pull/668#discussion_r411850501
##########
File path:
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/pipeline/PipelinePlacementPolicy.java
##########
@@ -316,36 +315,75 @@ DatanodeDetails fallBackPickNodes(
}
/**
- * Find a node from the healthy list and return it after removing it from the
- * list that we are operating on.
- *
- * @param healthyNodes - Set of healthy nodes we can choose from.
- * @return chosen datanodDetails
+ * Random pick two nodes and compare with the pipeline load.
+ * Return the node with lower pipeline load.
+ * @param healthyNodes healthy nodes
+ * @return node
*/
- @Override
- public DatanodeDetails chooseNode(
- List<DatanodeDetails> healthyNodes) {
- if (healthyNodes == null || healthyNodes.isEmpty()) {
- return null;
- }
+ private DatanodeDetails randomPick(List<DatanodeDetails> healthyNodes) {
+ DatanodeDetails datanodeDetails;
int firstNodeNdx = getRand().nextInt(healthyNodes.size());
int secondNodeNdx = getRand().nextInt(healthyNodes.size());
- DatanodeDetails datanodeDetails;
// There is a possibility that both numbers will be same.
// if that is so, we just return the node.
if (firstNodeNdx == secondNodeNdx) {
datanodeDetails = healthyNodes.get(firstNodeNdx);
} else {
DatanodeDetails firstNodeDetails = healthyNodes.get(firstNodeNdx);
DatanodeDetails secondNodeDetails = healthyNodes.get(secondNodeNdx);
- SCMNodeMetric firstNodeMetric =
- nodeManager.getNodeStat(firstNodeDetails);
- SCMNodeMetric secondNodeMetric =
- nodeManager.getNodeStat(secondNodeDetails);
- datanodeDetails = firstNodeMetric.isGreater(secondNodeMetric.get())
- ? firstNodeDetails : secondNodeDetails;
+ datanodeDetails = nodeManager.getPipelinesCount(firstNodeDetails)
+ >= nodeManager.getPipelinesCount(secondNodeDetails)
+ ? secondNodeDetails : firstNodeDetails;
}
+ return datanodeDetails;
+ }
+
+ /**
+ * Get a list of nodes with lower load than max pipeline number.
+ */
+ private List<DatanodeDetails> getLowerLoadNodes(
+ List<DatanodeDetails> nodes, int num) {
+ int maxPipelineUsage = nodes.size() * heavyNodeCriteria /
Review comment:
Removed and updated with new method.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]