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 2020/12/03 07:58:17 UTC

[GitHub] [servicecomb-java-chassis] wujimin commented on a change in pull request #2098: [SCB-2135]provider flow control support for operation to any client s…

wujimin commented on a change in pull request #2098:
URL: https://github.com/apache/servicecomb-java-chassis/pull/2098#discussion_r534856711



##########
File path: handlers/handler-flowcontrol-qps/src/main/java/org/apache/servicecomb/qps/QpsControllerManager.java
##########
@@ -31,41 +32,85 @@
 import org.slf4j.LoggerFactory;
 
 import com.netflix.config.DynamicProperty;
-import org.apache.commons.lang3.StringUtils;
 
 public class QpsControllerManager {
   private static final Logger LOGGER = LoggerFactory.getLogger(QpsControllerManager.class);
 
+  public static final String SEPARATOR = ".";
+
   /**
    * Describe the relationship between configuration and qpsController.
    */
-  protected final Map<String, AbstractQpsStrategy> configQpsControllerMap = new ConcurrentHashMapEx<>();
+  private final Map<String, AbstractQpsStrategy> configQpsControllerMap = new ConcurrentHashMapEx<>();
 
   /**
    * Describe the relationship between qualifiedKey(format is "microservice.schema.operation") and qpsController.
    */
-  protected final Map<String, AbstractQpsStrategy> qualifiedNameControllerMap = new ConcurrentHashMapEx<>();
+  private final Map<String, AbstractQpsStrategy> qualifiedNameControllerMap = new ConcurrentHashMapEx<>();
 
-  protected AbstractQpsStrategy globalQpsStrategy;
+  private AbstractQpsStrategy globalQpsStrategy;
 
-  public static final String SEPARATOR = ".";
+  private final String limitKeyPrefix;
 
-  private String limitKeyPrefix;
+  private final String bucketKeyPrefix;
 
-  private String bucketKeyPrefix;
+  private final String globalLimitKey;
+
+  private final String globalBucketKey;
+
+  public QpsControllerManager(boolean isProvider) {
+    if (isProvider) {
+      limitKeyPrefix = Config.PROVIDER_LIMIT_KEY_PREFIX;
+      bucketKeyPrefix = Config.PROVIDER_BUCKET_KEY_PREFIX;
+      globalLimitKey = Config.PROVIDER_LIMIT_KEY_GLOBAL;
+      globalBucketKey = Config.PROVIDER_BUCKET_KEY_GLOBAL;
+    } else {
+      limitKeyPrefix = Config.CONSUMER_LIMIT_KEY_PREFIX;
+      bucketKeyPrefix = Config.CONSUMER_BUCKET_KEY_PREFIX;
+      globalLimitKey = Config.CONSUMER_LIMIT_KEY_GLOBAL;
+      globalBucketKey = Config.CONSUMER_BUCKET_KEY_GLOBAL;
+    }
+
+    initGlobalQpsController();
+  }
 
   public QpsStrategy getOrCreate(String microserviceName, Invocation invocation) {
+    final String name = validatedName(microserviceName);
     return qualifiedNameControllerMap
         .computeIfAbsent(
-            microserviceName + SEPARATOR + invocation.getOperationMeta().getSchemaQualifiedName(),
-            key -> create(key, microserviceName, invocation));
+            name + SEPARATOR + invocation.getOperationMeta().getSchemaQualifiedName(),

Review comment:
       `name + SEPARATOR + invocation.getOperationMeta().getSchemaQualifiedName()`
   equals `invocation.getMicroserviceQualifiedName()`?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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