You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/08/14 06:13:42 UTC

[GitHub] liubao68 closed pull request #867: [SCB-832] modify the errorThresholdPercentage from 20 to 0

liubao68 closed pull request #867: [SCB-832] modify the errorThresholdPercentage from 20 to 0
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/867
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/Configuration.java b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/Configuration.java
index bdc38317f..f2f8f624d 100644
--- a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/Configuration.java
+++ b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/Configuration.java
@@ -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 {
diff --git a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java
index b8d45b577..6cfadb79c 100644
--- a/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java
+++ b/handlers/handler-loadbalance/src/main/java/org/apache/servicecomb/loadbalance/filter/IsolationDiscoveryFilter.java
@@ -161,6 +161,9 @@ private boolean checkThresholdAllowed(Settings settings, ServiceCombServerStats
       }
     }
 
+    if (settings.errorThresholdPercentage == 0) {
+      return true;
+    }
     if (serverStats.getFailedRate() >= settings.errorThresholdPercentage) {
       return false;
     }
diff --git a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
index a0c3c1015..b5262b54c 100644
--- a/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
+++ b/handlers/handler-loadbalance/src/test/java/org/apache/servicecomb/loadbalance/TestLoadBalanceHandler2.java
@@ -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();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services