|
@@ -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";
|
|
|
int maxParallelism = kubernetesNodeTO.getMaxParallelism();
|
|
|
- String restParallelismKey = "node:" + name + ":parallelism";
|
|
|
String restParallelismString = stringRedisTemplate.opsForValue().get(restParallelismKey);
|
|
|
+
|
|
|
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++) {
|
|
|
|