This is an automated email from the ASF dual-hosted git repository.

liubao pushed a commit to branch 2.8.x
in repository https://gitbox.apache.org/repos/asf/servicecomb-java-chassis.git


The following commit(s) were added to refs/heads/2.8.x by this push:
     new dbe4522ea [SCB-2844] Adding a configuration that controls the retry 
interval for load balance (#4141)
dbe4522ea is described below

commit dbe4522ea8d8cc1cb6338cca58aab5a53a8ceeec
Author: yanghao <[email protected]>
AuthorDate: Thu Dec 21 19:38:22 2023 +0800

    [SCB-2844] Adding a configuration that controls the retry interval for load 
balance (#4141)
---
 .../core/governance/GovernanceConfiguration.java        | 17 +++++++++++++++++
 .../core/provider/consumer/InvokerUtils.java            |  2 +-
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/servicecomb/core/governance/GovernanceConfiguration.java
 
b/core/src/main/java/org/apache/servicecomb/core/governance/GovernanceConfiguration.java
index eff944fff..84a869815 100644
--- 
a/core/src/main/java/org/apache/servicecomb/core/governance/GovernanceConfiguration.java
+++ 
b/core/src/main/java/org/apache/servicecomb/core/governance/GovernanceConfiguration.java
@@ -28,6 +28,8 @@ public class GovernanceConfiguration {
 
   public static final String RETRY_ON_SAME = "retryOnSame";
 
+  public static final String WITH_DURATION = "waitDuration";
+
   public static boolean isRetryEnabled(String microservice) {
     String p = getStringProperty("false",
         ROOT + microservice + "." + RETRY_ENABLED,
@@ -43,6 +45,21 @@ public class GovernanceConfiguration {
     return getRetryServer(microservice, RETRY_ON_SAME);
   }
 
+  public static long getWithDuration(String microservice) {
+    final long defaultValue = 0;
+    String duration = getStringProperty("0", ROOT + microservice + "." + 
WITH_DURATION,
+            ROOT + WITH_DURATION);
+    try {
+      long result = Long.parseLong(duration);
+      if (result > 0) {
+        return result;
+      }
+      return defaultValue;
+    } catch (NumberFormatException e) {
+      return defaultValue;
+    }
+  }
+
   private static int getRetryServer(String microservice, String retryType) {
     final int defaultValue = 0;
     String p = getStringProperty("0",
diff --git 
a/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
 
b/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
index 80776636a..083a552aa 100644
--- 
a/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
+++ 
b/core/src/main/java/org/apache/servicecomb/core/provider/consumer/InvokerUtils.java
@@ -296,7 +296,7 @@ public final class InvokerUtils {
             + 
GovernanceConfiguration.getRetrySameServer(invocation.getMicroserviceName()) + 
1)
         .retryOnResult(InvokerUtils::canRetryForStatusCode)
         .retryOnException(InvokerUtils::canRetryForException)
-        .waitDuration(Duration.ofMillis(0))
+        
.waitDuration(Duration.ofMillis(GovernanceConfiguration.getWithDuration(invocation.getMicroserviceName())))
         .build();
     RetryRegistry retryRegistry = RetryRegistry.of(retryConfig);
     return retryRegistry.retry(invocation.getMicroserviceName());

Reply via email to