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 2019/04/01 06:53:53 UTC

[GitHub] [servicecomb-java-chassis] liubao68 commented on a change in pull request #1161: [SCB-1232] make GroupExecutor configuration compatible to old version

liubao68 commented on a change in pull request #1161: [SCB-1232] make GroupExecutor configuration compatible to old version
URL: https://github.com/apache/servicecomb-java-chassis/pull/1161#discussion_r270733331
 
 

 ##########
 File path: core/src/main/java/org/apache/servicecomb/core/executor/GroupExecutor.java
 ##########
 @@ -83,25 +83,31 @@ public void init() {
   }
 
   public void initConfig() {
-    groupCount = DynamicPropertyFactory.getInstance().getIntProperty(KEY_GROUP, 2).get();
-    coreThreads = DynamicPropertyFactory.getInstance().getIntProperty(KEY_CORE_THREADS, 25).get();
-
-    maxThreads = DynamicPropertyFactory.getInstance().getIntProperty(KEY_MAX_THREADS, -1).get();
-    if (maxThreads <= 0) {
-      maxThreads = DynamicPropertyFactory.getInstance().getIntProperty(KEY_THREAD, -1).get();
-      if (maxThreads > 0) {
-        LOGGER.warn("{} is deprecated, recommended to use {}.", KEY_THREAD, KEY_MAX_THREADS);
-      } else {
-        maxThreads = 100;
-      }
-    }
-    if (coreThreads > maxThreads) {
-      LOGGER.warn("coreThreads is bigger than maxThreads, change from {} to {}.", coreThreads, maxThreads);
+    LOGGER.info("JDK standard thread pool rules:\n"
+        + "1.use core threads.\n"
+        + "2.if all core threads are busy, then queue the request.\n"
+        + "3.if queue is full, then create new thread util reach the limit of max threads.\n"
+        + "4.if queue is full, and threads count is max, then reject the request.");
+
+    // the complex logic is to keep compatible
+    // otherwise can throw exception if configuration is invalid.
+    coreThreads = DynamicPropertyFactory.getInstance().getIntProperty(KEY_CORE_THREADS, -1).get();
+
+    int oldMaxThreads = DynamicPropertyFactory.getInstance().getIntProperty(KEY_OLD_MAX_THREAD, -1).get();
+    maxThreads = DynamicPropertyFactory.getInstance().getIntProperty(KEY_MAX_THREADS, oldMaxThreads).get();
+    maxThreads = Math.max(coreThreads, maxThreads);
+    maxThreads = maxThreads <= 0 ? 100 : maxThreads;
+
+    maxQueueSize = DynamicPropertyFactory.getInstance().getIntProperty(KEY_MAX_QUEUE_SIZE, Integer.MAX_VALUE).get();
+    if (maxQueueSize == Integer.MAX_VALUE) {
       coreThreads = maxThreads;
+      LOGGER.info("not configured {},  make coreThreads and maxThreads to be {}.", KEY_MAX_QUEUE_SIZE, maxThreads);
+    } else {
+      coreThreads = coreThreads <= 0 ? 25 : coreThreads;
 
 Review comment:
   This statement should be calculated before 
               maxThreads = Math.max(coreThreads, maxThreads);
   

----------------------------------------------------------------
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


With regards,
Apache Git Services