LingxinMeng vor 2 Jahren
Ursprung
Commit
5a965d22b9

+ 1 - 1
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/scheduler/ProjectScheduler.java

@@ -27,7 +27,7 @@ public class ProjectScheduler {
     /**
      * 调度项目启动
      */
-    @Scheduled(fixedDelay = 1000)
+    @Scheduled(fixedDelay = 60000)
     public void dispatchProject() {
         List<String> projectMessageKeys = projectUtil.getWaitingProjectMessageKeys();
         if (!CollectionUtil.isEmpty(projectMessageKeys)) {

+ 5 - 5
simulation-resource-scheduler/src/main/java/com/css/simulation/resource/scheduler/util/ProjectUtil.java

@@ -659,18 +659,18 @@ public class ProjectUtil {
     public void releaseLicense(String projectUserId, String modelType, int parallelism) {
         final String clusterUserId = getClusterUserIdByProjectUserId(projectUserId);
         if (DictConstants.MODEL_TYPE_VTD.equals(modelType)) {
-            releaseLicense("user:" + clusterUserId + ":using-license:simulation",parallelism);
+            releaseLicense("user:" + clusterUserId + ":using-license:simulation", parallelism);
         } else if (DictConstants.MODEL_TYPE_CARSIM.equals(modelType)) {
-            releaseLicense("user:" + clusterUserId + ":using-license:simulation",parallelism);
-            releaseLicense("user:" + clusterUserId + ":using-license:dynamic",parallelism);
+            releaseLicense("user:" + clusterUserId + ":using-license:simulation", parallelism);
+            releaseLicense("user:" + clusterUserId + ":using-license:dynamic", parallelism);
         } else {
             throw new RuntimeException("未知模型类型:" + modelType);
         }
     }
 
-    private void releaseLicense(String key, int number){
+    private void releaseLicense(String key, int number) {
         final String usingLicense = customRedisClient.get(key);
-        if (StringUtil.isEmpty(usingLicense)) {
+        if (StringUtil.isEmpty(usingLicense) || Integer.parseInt(usingLicense) <= number) {
             customRedisClient.set(key, "0");
         } else {
             customRedisClient.decrement(key, number);