|
@@ -29,6 +29,7 @@ import org.springframework.stereotype.Component;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -89,11 +90,15 @@ public class ProjectScheduler {
|
|
}
|
|
}
|
|
int simulationLicenseNumber = clusterPO.getNumSimulationLicense();
|
|
int simulationLicenseNumber = clusterPO.getNumSimulationLicense();
|
|
// 获取该用户正在运行的项目数量
|
|
// 获取该用户正在运行的项目数量
|
|
- Set<String> runningProjectSet = redisTemplate.keys(redisPrefix.getClusterRunningPrefix() + "*");
|
|
|
|
-
|
|
|
|
|
|
+ Set<String> keySet = redisTemplate.keys(redisPrefix.getClusterRunningPrefix() + "*");
|
|
|
|
+ if (CollectionUtil.isEmpty(keySet)) {
|
|
|
|
+ log.error("ProjectScheduler--dispatchProject 正在运行的项目 " + projectId + " 没有对应的缓存数据!");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // cluster:${clusterId}:running:${projectId}
|
|
|
|
+ List<String> runningProjectSet = keySet.stream().filter(key -> StringUtil.countSubString(key, ":") == 3).collect(Collectors.toList());
|
|
if (CollectionUtil.isNotEmpty(runningProjectSet)) {
|
|
if (CollectionUtil.isNotEmpty(runningProjectSet)) {
|
|
long parallelismSum = 0;
|
|
long parallelismSum = 0;
|
|
- // cluster:${clusterId}:running:${projectId}
|
|
|
|
for (String runningProjectKey : runningProjectSet) {
|
|
for (String runningProjectKey : runningProjectSet) {
|
|
parallelismSum += JsonUtil.jsonToBean(redisTemplate.opsForValue().get(runningProjectKey), ProjectMessageDTO.class).getParallelism();
|
|
parallelismSum += JsonUtil.jsonToBean(redisTemplate.opsForValue().get(runningProjectKey), ProjectMessageDTO.class).getParallelism();
|
|
}
|
|
}
|