Skip to content

Commit

Permalink
🎨 node权重
Browse files Browse the repository at this point in the history
  • Loading branch information
adlered committed Dec 20, 2024
1 parent bc3973c commit fa7f025
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,12 @@ public void getNode(final RequestContext context) {
.append(", 期望客户端数: ").append(String.format("%.2f", expectedClients))
.append(", 比值: ").append(String.format("%.2f", ratio)).append("\n");

// 选择比值最小的节点
if (selectedNode == null || ratio < selectedNode.getValue()) {
// 选择比值最小的节点,比值相同时,选择权重更高的节点
if (selectedNode == null || ratio < selectedNode.getValue() ||
(ratio == selectedNode.getValue() && weight > NodeUtil.nodeWeights.get(selectedNode.getKey()))) {
selectedNode = new AbstractMap.SimpleEntry<>(node, ratio);
}

}

// 分配选中的节点
Expand Down

0 comments on commit fa7f025

Please sign in to comment.