|
@@ -108,44 +108,6 @@ public class ProjectUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 根据并行度获取用于执行的节点列表
|
|
|
- * 根据剩余可用并行度降序排序
|
|
|
- *
|
|
|
- * @return 节点映射(节点名,并行度)
|
|
|
- */
|
|
|
- public KubernetesNodeTO getNodeWithMaxRestParallelism() {
|
|
|
- List<KubernetesNodeTO> initialNodeList = kubernetesConfiguration.getNodeList(); // 预设并行度的节点列表
|
|
|
- List<KubernetesNodeTO> restNodeList = new ArrayList<>(); // 剩余并行度的节点列表
|
|
|
- for (KubernetesNodeTO kubernetesNodeTO : initialNodeList) {
|
|
|
- String name = kubernetesNodeTO.getName();
|
|
|
- int maxParallelism = kubernetesNodeTO.getMaxParallelism();
|
|
|
- String restParallelismKey = "node:" + name + ":parallelism";
|
|
|
- String restParallelismString = stringRedisTemplate.opsForValue().get(restParallelismKey);
|
|
|
- int restParallelism;
|
|
|
- if (restParallelismString == null) { // 如果剩余可用并行度没有值,说明是第一次查询,则重置成最大并行度的预设值
|
|
|
- restParallelism = maxParallelism;
|
|
|
- stringRedisTemplate.opsForValue().set(restParallelismKey, restParallelism + "");
|
|
|
- } else {
|
|
|
- restParallelism = Integer.parseInt(restParallelismString);
|
|
|
- kubernetesNodeTO.setMaxParallelism(restParallelism);
|
|
|
- }
|
|
|
- if (restParallelism > 0) {
|
|
|
- restNodeList.add(kubernetesNodeTO);
|
|
|
- }
|
|
|
- }
|
|
|
- int restNodeNumber = restNodeList.size();
|
|
|
- if (restNodeNumber > 1) {
|
|
|
- restNodeList.sort((o1, o2) -> o2.getMaxParallelism() - o1.getMaxParallelism());
|
|
|
- return restNodeList.get(0);
|
|
|
- } else if (restNodeNumber == 1) {
|
|
|
- return restNodeList.get(0);
|
|
|
- } else {
|
|
|
- return null;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* 根据并行度获取节点列表以及剩余可用并行度
|
|
|
* 根据剩余可用并行度降序排序
|
|
@@ -182,13 +144,15 @@ public class ProjectUtil {
|
|
|
*/
|
|
|
public Map<String, Integer> getNodeMapToUse(long parallelism) {
|
|
|
List<KubernetesNodeTO> initialNodeList = kubernetesConfiguration.getNodeList(); // 预设并行度的节点列表
|
|
|
+ log.info("ProjectUtil--getNodeMapToUse 预设并行度的节点列表为:" + initialNodeList);
|
|
|
+ // 遍历所有节点,获取还有剩余并行度的节点
|
|
|
List<KubernetesNodeTO> restNodeList = new ArrayList<>(); // 剩余并行度的节点列表
|
|
|
- Map<String, Integer> resultNodeMap = new HashMap<>(); // 用于执行的节点映射(节点名,并行度)
|
|
|
for (KubernetesNodeTO kubernetesNodeTO : initialNodeList) {
|
|
|
- String name = kubernetesNodeTO.getName();
|
|
|
+ String nodeName = kubernetesNodeTO.getName(); // 节点名称
|
|
|
+ String restParallelismKey = "node:" + nodeName + ":parallelism"; // 获取节点剩余并行度的 key
|
|
|
int maxParallelism = kubernetesNodeTO.getMaxParallelism();
|
|
|
- String restParallelismKey = "node:" + name + ":parallelism";
|
|
|
String restParallelismString = stringRedisTemplate.opsForValue().get(restParallelismKey);
|
|
|
+ // -------------------------------- Comment --------------------------------
|
|
|
int restParallelism;
|
|
|
if (restParallelismString == null) { // 如果剩余可用并行度没有值,说明是第一次查询,则重置成最大并行度的预设值
|
|
|
restParallelism = maxParallelism;
|
|
@@ -199,9 +163,10 @@ public class ProjectUtil {
|
|
|
}
|
|
|
if (restParallelism > 0) {
|
|
|
restNodeList.add(kubernetesNodeTO);
|
|
|
- resultNodeMap.put(name, 0);
|
|
|
}
|
|
|
}
|
|
|
+ log.info("ProjectUtil--getNodeMapToUse 剩余并行度的节点列表为:" + initialNodeList);
|
|
|
+ Map<String, Integer> resultNodeMap = new HashMap<>(); // 用于执行的节点映射(节点名,并行度)
|
|
|
if (!CollectionUtil.isEmpty(restNodeList)) {
|
|
|
for (int i = 0; i < parallelism; i++) {
|
|
|
// 每次降序排序都取剩余并行度最大的一个。
|