[ISSUE #12072] Add logic that does not impose any limit when totalCountLimit is less than 0. (#12073)
* Fixed an issue where the maximum number of anti-fragile plug-ins implemented by default in Nacos is one more than the actual number of connections. * bug fix : 修改删除空服务实例时,服务名和分组名没有正确解析的问题 * Update ConfigChangeAspect.java 修改configChangeRequest.setArg()的key为serviceType * Update ConfigChangeAspect.java * Update ConfigChangeRequest.java * Update NacosConnectionControlManager.java Add logic to not impose any limit when totalCountLimit equals -1. * Update NacosConnectionControlManager.java * Update NacosConnectionControlManagerTest.java Add unit test cases when LimitCount is less than 0 * Update NacosConnectionControlManager.java Modify comment
This commit is contained in:
parent
4e2bcb9277
commit
15c9663d31
@ -58,6 +58,11 @@ public class NacosConnectionControlManager extends ConnectionControlManager {
|
||||
connectionCheckResponse.setSuccess(true);
|
||||
connectionCheckResponse.setCode(ConnectionCheckCode.PASS_BY_TOTAL);
|
||||
int totalCountLimit = connectionControlRule.getCountLimit();
|
||||
// If totalCountLimit less than 0, no limit is applied.
|
||||
if (totalCountLimit < 0) {
|
||||
return connectionCheckResponse;
|
||||
}
|
||||
|
||||
// Get total connection from metrics
|
||||
Map<String, Integer> metricsTotalCount = metricsCollectorList.stream().collect(
|
||||
Collectors.toMap(ConnectionMetricsCollector::getName, ConnectionMetricsCollector::getTotalCount));
|
||||
|
@ -55,4 +55,15 @@ public class NacosConnectionControlManagerTest {
|
||||
ConnectionCheckResponse connectionCheckResponse = nacosConnectionControlManager.check(connectionCheckRequest);
|
||||
Assert.assertTrue(connectionCheckResponse.isSuccess());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCheckLimitCountLessThanZero() {
|
||||
NacosConnectionControlManager nacosConnectionControlManager = new NacosConnectionControlManager();
|
||||
ConnectionControlRule connectionControlRule = new ConnectionControlRule();
|
||||
connectionControlRule.setCountLimit(-1);
|
||||
nacosConnectionControlManager.applyConnectionLimitRule(connectionControlRule);
|
||||
ConnectionCheckRequest connectionCheckRequest = new ConnectionCheckRequest("127.0.0.1", "test", "test");
|
||||
ConnectionCheckResponse connectionCheckResponse = nacosConnectionControlManager.check(connectionCheckRequest);
|
||||
Assert.assertTrue(connectionCheckResponse.isSuccess());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user