Skip to content

Commit

Permalink
[SCB-832] modify the default errorThresholdPercentage to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
weichao666 authored and liubao68 committed Aug 14, 2018
1 parent f72bf03 commit 5812342
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public boolean isIsolationFilterOpen(String microservice) {
}

public int getErrorThresholdPercentage(String microservice) {
final int defaultValue = 20;
String p = getStringProperty("20",
final int defaultValue = 0;
String p = getStringProperty("0",
PROP_ROOT + microservice + "." + FILTER_ISOLATION + FILTER_ERROR_PERCENTAGE,
PROP_ROOT + FILTER_ISOLATION + FILTER_ERROR_PERCENTAGE);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ private boolean checkThresholdAllowed(Settings settings, ServiceCombServerStats
}
}

if (settings.errorThresholdPercentage == 0) {
return true;
}
if (serverStats.getFailedRate() >= settings.errorThresholdPercentage) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,15 @@ public void testZoneAwareAndIsolationFilterWorks() {
ServiceCombLoadBalancerStats.INSTANCE.markSuccess(server);
ServiceCombLoadBalancerStats.INSTANCE.markSuccess(server);
ServiceCombLoadBalancerStats.INSTANCE.markFailure(server);

//if errorThresholdPercentage is 0,that means errorThresholdPercentage is not active.
ArchaiusUtils.setProperty("servicecomb.loadbalance.isolation.errorThresholdPercentage", "0");
loadBalancer = handler.getOrCreateLoadBalancer(invocation);
server = (ServiceCombServer) loadBalancer.chooseServer();
Assert.assertEquals(server.getEndpoint().getEndpoint(), "rest://localhost:9090");

//if errorThresholdPercentage greater than 0, it will activate.
ArchaiusUtils.setProperty("servicecomb.loadbalance.isolation.errorThresholdPercentage", "20");
ServiceCombServer server2 = server;
loadBalancer = handler.getOrCreateLoadBalancer(invocation);
server = (ServiceCombServer) loadBalancer.chooseServer();
Expand Down

0 comments on commit 5812342

Please sign in to comment.