You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by ni...@apache.org on 2018/01/08 07:34:24 UTC

[incubator-servicecomb-java-chassis] 01/03: [SCB-180] Hystrixcommand setter not set by dynamic configuration

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

ningjiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-java-chassis.git

commit 5a9acb959171ead2f3c171cb373564a18663f466
Author: donglzh168 <14...@qq.com>
AuthorDate: Fri Jan 5 17:40:19 2018 +0800

    [SCB-180] Hystrixcommand setter not set by dynamic configuration
---
 .../io/servicecomb/bizkeeper/BizkeeperHandler.java | 62 +---------------------
 .../bizkeeper/HystrixCommandPropertiesExt.java     | 45 ++++++++++++----
 2 files changed, 36 insertions(+), 71 deletions(-)

diff --git a/handlers/handler-bizkeeper/src/main/java/io/servicecomb/bizkeeper/BizkeeperHandler.java b/handlers/handler-bizkeeper/src/main/java/io/servicecomb/bizkeeper/BizkeeperHandler.java
index 5c3f166..9a2d5ca 100644
--- a/handlers/handler-bizkeeper/src/main/java/io/servicecomb/bizkeeper/BizkeeperHandler.java
+++ b/handlers/handler-bizkeeper/src/main/java/io/servicecomb/bizkeeper/BizkeeperHandler.java
@@ -21,7 +21,6 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.netflix.hystrix.HystrixCommandProperties;
-import com.netflix.hystrix.HystrixCommandProperties.ExecutionIsolationStrategy;
 import com.netflix.hystrix.HystrixInvokable;
 import com.netflix.hystrix.HystrixObservable;
 import com.netflix.hystrix.strategy.HystrixPlugins;
@@ -43,12 +42,6 @@ public abstract class BizkeeperHandler implements Handler {
 
   protected final String groupname;
 
-  private static final int WINDOW_IN_MILLISECONDS = 10000;
-
-  private static final int WINDOW_BUCKETS = 10;
-
-  private static final int SNAPSHOT_INTERVAL = 1000;
-
   static {
     try {
       HystrixPlugins.getInstance().registerPropertiesStrategy(HystrixPropertiesStrategyExt.getInstance());
@@ -57,6 +50,7 @@ public abstract class BizkeeperHandler implements Handler {
     }
     try {
       HystrixPlugins.getInstance().registerCommandExecutionHook(new HystrixCommandExecutionHook() {
+        @Override
         public <T> Exception onExecutionError(HystrixInvokable<T> commandInstance, Exception e) {
           LOG.warn("bizkeeper execution error", e);
           return e; //by default, just pass through
@@ -99,59 +93,5 @@ public abstract class BizkeeperHandler implements Handler {
   }
 
   protected void setCommonProperties(Invocation invocation, HystrixCommandProperties.Setter setter) {
-    setter.withExecutionTimeoutInMilliseconds(Configuration.INSTANCE
-        .getIsolationTimeoutInMilliseconds(groupname,
-            invocation.getMicroserviceName(),
-            invocation.getOperationMeta().getMicroserviceQualifiedName()))
-        .withExecutionIsolationSemaphoreMaxConcurrentRequests(Configuration.INSTANCE
-            .getIsolationMaxConcurrentRequests(groupname,
-                invocation.getMicroserviceName(),
-                invocation.getOperationMeta()
-                    .getMicroserviceQualifiedName()))
-        .withExecutionTimeoutEnabled(
-            Configuration.INSTANCE.getIsolationTimeoutEnabled(groupname,
-                invocation.getMicroserviceName(),
-                invocation.getOperationMeta()
-                    .getMicroserviceQualifiedName()))
-        .withCircuitBreakerEnabled(Configuration.INSTANCE.isCircuitBreakerEnabled(groupname,
-            invocation.getMicroserviceName(),
-            invocation.getOperationMeta()
-                .getMicroserviceQualifiedName()))
-        .withCircuitBreakerForceOpen(Configuration.INSTANCE.isCircuitBreakerForceOpen(groupname,
-            invocation.getMicroserviceName(),
-            invocation.getOperationMeta()
-                .getMicroserviceQualifiedName()))
-        .withCircuitBreakerForceClosed(Configuration.INSTANCE.isCircuitBreakerForceClosed(groupname,
-            invocation.getMicroserviceName(),
-            invocation.getOperationMeta()
-                .getMicroserviceQualifiedName()))
-        .withCircuitBreakerSleepWindowInMilliseconds(
-            Configuration.INSTANCE.getCircuitBreakerSleepWindowInMilliseconds(groupname,
-                invocation.getMicroserviceName(),
-                invocation.getOperationMeta()
-                    .getMicroserviceQualifiedName()))
-        .withCircuitBreakerRequestVolumeThreshold(
-            Configuration.INSTANCE.getCircuitBreakerRequestVolumeThreshold(groupname,
-                invocation.getMicroserviceName(),
-                invocation.getOperationMeta()
-                    .getMicroserviceQualifiedName()))
-        .withCircuitBreakerErrorThresholdPercentage(
-            Configuration.INSTANCE.getCircuitBreakerErrorThresholdPercentage(groupname,
-                invocation.getMicroserviceName(),
-                invocation.getOperationMeta()
-                    .getMicroserviceQualifiedName()))
-        .withFallbackEnabled(
-            Configuration.INSTANCE.isFallbackEnabled(groupname,
-                invocation.getMicroserviceName(),
-                invocation.getOperationMeta().getMicroserviceQualifiedName()))
-        .withExecutionIsolationStrategy(ExecutionIsolationStrategy.SEMAPHORE)
-        .withMetricsRollingPercentileEnabled(false)
-        .withMetricsRollingStatisticalWindowInMilliseconds(WINDOW_IN_MILLISECONDS)
-        .withMetricsRollingStatisticalWindowBuckets(WINDOW_BUCKETS)
-        .withMetricsHealthSnapshotIntervalInMilliseconds(SNAPSHOT_INTERVAL)
-        .withFallbackIsolationSemaphoreMaxConcurrentRequests(Configuration.INSTANCE
-            .getFallbackMaxConcurrentRequests(groupname,
-                invocation.getMicroserviceName(),
-                invocation.getOperationMeta().getMicroserviceQualifiedName()));
   }
 }
diff --git a/handlers/handler-bizkeeper/src/main/java/io/servicecomb/bizkeeper/HystrixCommandPropertiesExt.java b/handlers/handler-bizkeeper/src/main/java/io/servicecomb/bizkeeper/HystrixCommandPropertiesExt.java
index 0c4e36a..3a07c45 100644
--- a/handlers/handler-bizkeeper/src/main/java/io/servicecomb/bizkeeper/HystrixCommandPropertiesExt.java
+++ b/handlers/handler-bizkeeper/src/main/java/io/servicecomb/bizkeeper/HystrixCommandPropertiesExt.java
@@ -47,9 +47,9 @@ public class HystrixCommandPropertiesExt extends HystrixCommandProperties {
   // must occur before statistics matter
   private static final Integer DEFAULT_CIRCUITBREAKERREQUESTVOLUMETHRESHOLD = 20;
 
-  // default => sleepWindow: 5000 = 5 seconds that we will sleep before trying
+  // default => sleepWindow: 15000 = 15 seconds that we will sleep before trying
   // again after tripping the circuit
-  private static final Integer DEFAULT_CIRCUITBREAKERSLEEPWINDOWINMILLISECONDS = 5000;
+  private static final Integer DEFAULT_CIRCUITBREAKERSLEEPWINDOWINMILLISECONDS = 15000;
 
   // default => errorThresholdPercentage = 50 = if 50%+ of requests in 10
   // seconds are failures or latent then we will trip the circuit
@@ -62,16 +62,16 @@ public class HystrixCommandPropertiesExt extends HystrixCommandProperties {
   // default => ignoreErrors = false
   static final Boolean DEFAULT_CIRCUITBREAKERFORCECLOSED = false;
 
-  // default => executionTimeoutInMilliseconds: 1000 = 1 second
-  private static final Integer DEFAULT_EXECUTIONTIMEOUTINMILLISECONDS = 1000;
+  // default => executionTimeoutInMilliseconds: 30000 = 30 second
+  private static final Integer DEFAULT_EXECUTIONTIMEOUTINMILLISECONDS = 30000;
 
-  private static final Boolean DEFAULT_EXECUTIONTIMEOUTENABLED = true;
+  private static final Boolean DEFAULT_EXECUTIONTIMEOUTENABLED = false;
 
-  private static final ExecutionIsolationStrategy DEFAULT_ISOLATIONSTRATEGY = ExecutionIsolationStrategy.THREAD;
+  private static final ExecutionIsolationStrategy DEFAULT_ISOLATIONSTRATEGY = ExecutionIsolationStrategy.SEMAPHORE;
 
   private static final Boolean DEFAULT_EXECUTIONISOLATIONTHREADINTERRUPTONTIMEOUT = true;
 
-  private static final Boolean DEFAULT_METRICSROLLINGPERCENTILEENABLED = true;
+  private static final Boolean DEFAULT_METRICSROLLINGPERCENTILEENABLED = false;
 
   private static final Boolean DEFAULT_REQUESTCACHEENABLED = true;
 
@@ -79,7 +79,7 @@ public class HystrixCommandPropertiesExt extends HystrixCommandProperties {
 
   private static final Boolean DEFAULT_FALLBACKENABLED = true;
 
-  private static final Integer DEFAULT_EXECUTIONISOLATIONSEMAPHOREMAXCONCURRENTREQUESTS = 10;
+  private static final Integer DEFAULT_EXECUTIONISOLATIONSEMAPHOREMAXCONCURRENTREQUESTS = 1000;
 
   private static final Boolean DEFAULT_REQUESTLOGENABLED = true;
 
@@ -94,9 +94,9 @@ public class HystrixCommandPropertiesExt extends HystrixCommandProperties {
   // default to 100 values max per bucket
   private static final Integer DEFAULT_METRICSROLLINGPERCENTILEBUCKETSIZE = 100;
 
-  // default to 500ms as max frequency between allowing snapshots of health
+  // default to 1000ms as max frequency between allowing snapshots of health
   // (error percentage etc)
-  private static final Integer DEFAULT_METRICSHEALTHSNAPSHOTINTERVALINMILLISECONDS = 500;
+  private static final Integer DEFAULT_METRICSHEALTHSNAPSHOTINTERVALINMILLISECONDS = 1000;
 
   private static final int COMMAND_KEY_LENGTH = 3;
 
@@ -328,103 +328,128 @@ public class HystrixCommandPropertiesExt extends HystrixCommandProperties {
         .build();
   }
 
+  @Override
   public HystrixProperty<Boolean> circuitBreakerEnabled() {
     return circuitBreakerEnabled;
   }
 
+  @Override
   public HystrixProperty<Integer> circuitBreakerErrorThresholdPercentage() {
     return circuitBreakerErrorThresholdPercentage;
   }
 
+  @Override
   public HystrixProperty<Boolean> circuitBreakerForceClosed() {
     return circuitBreakerForceClosed;
   }
 
+  @Override
   public HystrixProperty<Boolean> circuitBreakerForceOpen() {
     return circuitBreakerForceOpen;
   }
 
+  @Override
   public HystrixProperty<Integer> circuitBreakerRequestVolumeThreshold() {
     return circuitBreakerRequestVolumeThreshold;
   }
 
+  @Override
   public HystrixProperty<Integer> circuitBreakerSleepWindowInMilliseconds() {
     return circuitBreakerSleepWindowInMilliseconds;
   }
 
+  @Override
   public HystrixProperty<Integer> executionIsolationSemaphoreMaxConcurrentRequests() {
     return executionIsolationSemaphoreMaxConcurrentRequests;
   }
 
+  @Override
   public HystrixProperty<ExecutionIsolationStrategy> executionIsolationStrategy() {
     return executionIsolationStrategy;
   }
 
+  @Override
   public HystrixProperty<Boolean> executionIsolationThreadInterruptOnTimeout() {
     return executionIsolationThreadInterruptOnTimeout;
   }
 
+  @Override
   public HystrixProperty<String> executionIsolationThreadPoolKeyOverride() {
     return executionIsolationThreadPoolKeyOverride;
   }
 
+  @Override
   @Deprecated // prefer {@link #executionTimeoutInMilliseconds}
   public HystrixProperty<Integer> executionIsolationThreadTimeoutInMilliseconds() {
     return executionTimeoutInMilliseconds;
   }
 
+  @Override
   public HystrixProperty<Integer> executionTimeoutInMilliseconds() {
     return executionIsolationThreadTimeoutInMilliseconds();
   }
 
+  @Override
   public HystrixProperty<Boolean> executionTimeoutEnabled() {
     return executionTimeoutEnabled;
   }
 
+  @Override
   public HystrixProperty<Integer> fallbackIsolationSemaphoreMaxConcurrentRequests() {
     return fallbackIsolationSemaphoreMaxConcurrentRequests;
   }
 
+  @Override
   public HystrixProperty<Boolean> fallbackEnabled() {
     return fallbackEnabled;
   }
 
+  @Override
   public HystrixProperty<Integer> metricsHealthSnapshotIntervalInMilliseconds() {
     return metricsHealthSnapshotIntervalInMilliseconds;
   }
 
+  @Override
   public HystrixProperty<Integer> metricsRollingPercentileBucketSize() {
     return metricsRollingPercentileBucketSize;
   }
 
+  @Override
   public HystrixProperty<Boolean> metricsRollingPercentileEnabled() {
     return metricsRollingPercentileEnabled;
   }
 
+  @Override
   public HystrixProperty<Integer> metricsRollingPercentileWindow() {
     return metricsRollingPercentileWindowInMilliseconds;
   }
 
+  @Override
   public HystrixProperty<Integer> metricsRollingPercentileWindowInMilliseconds() {
     return metricsRollingPercentileWindowInMilliseconds;
   }
 
+  @Override
   public HystrixProperty<Integer> metricsRollingPercentileWindowBuckets() {
     return metricsRollingPercentileWindowBuckets;
   }
 
+  @Override
   public HystrixProperty<Integer> metricsRollingStatisticalWindowInMilliseconds() {
     return metricsRollingStatisticalWindowInMilliseconds;
   }
 
+  @Override
   public HystrixProperty<Integer> metricsRollingStatisticalWindowBuckets() {
     return metricsRollingStatisticalWindowBuckets;
   }
 
+  @Override
   public HystrixProperty<Boolean> requestCacheEnabled() {
     return requestCacheEnabled;
   }
 
+  @Override
   public HystrixProperty<Boolean> requestLogEnabled() {
     return requestLogEnabled;
   }

-- 
To stop receiving notification emails like this one, please contact
"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>.