[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:
Happy-26 2024-05-15 10:39:26 +08:00 committed by GitHub
parent 4e2bcb9277
commit 15c9663d31
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View File

@ -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));

View File

@ -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());
}
}