nacos
nacos copied to clipboard
`NacosConnectionControlManager` 的 `check`方法中,并没有对`totalCountLimit == -1`这种特殊情况做不限制连接处理。
NacosConnectionControlManager 的 check方法中,并没有对totalCountLimit == -1这种特殊情况做不限制连接处理。
@Override
public ConnectionCheckResponse check(ConnectionCheckRequest connectionCheckRequest) {
ConnectionCheckResponse connectionCheckResponse = new ConnectionCheckResponse();
connectionCheckResponse.setSuccess(true);
connectionCheckResponse.setCode(ConnectionCheckCode.PASS_BY_TOTAL);
int totalCountLimit = connectionControlRule.getCountLimit();
// Get total connection from metrics
Map<String, Integer> metricsTotalCount = metricsCollectorList.stream().collect(
Collectors.toMap(ConnectionMetricsCollector::getName, ConnectionMetricsCollector::getTotalCount));
int totalCount = metricsTotalCount.values().stream().mapToInt(Integer::intValue).sum();
if (totalCount >= totalCountLimit) {
connectionCheckResponse.setSuccess(false);
connectionCheckResponse.setCode(ConnectionCheckCode.DENY_BY_TOTAL_OVER);
}
return connectionCheckResponse;
}