|
@@ -62,17 +62,16 @@ public class ProjectUtil {
|
|
|
ApiClient apiClient;
|
|
|
|
|
|
@SneakyThrows
|
|
|
- public void deleteYamlByProjectId(String projectId){
|
|
|
+ public void deleteYamlByProjectId(String projectId) {
|
|
|
List<String> absolutePathList = FileUtil.listAbsolutePath(podYamlDirectory);
|
|
|
for (String absolutePath : absolutePathList) {
|
|
|
- if(absolutePath.contains(projectId)){
|
|
|
+ if (absolutePath.contains(projectId)) {
|
|
|
boolean delete = new File(absolutePath).delete();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
public List<NodeTO> getNodeListToCount(Map<String, Integer> nodeMap) {
|
|
|
List<NodeTO> result = new ArrayList<>();
|
|
|
nodeMap.forEach((nodeName, parallelism) -> {
|
|
@@ -169,7 +168,7 @@ public class ProjectUtil {
|
|
|
deletePod(lastPodName);
|
|
|
List<String> list = FileUtil.listAbsolutePath(podYamlDirectory);
|
|
|
Iterator<String> iterator1 = list.iterator();
|
|
|
- while (iterator1.hasNext()){
|
|
|
+ while (iterator1.hasNext()) {
|
|
|
String absolutePath = iterator1.next();
|
|
|
if (absolutePath.contains(nodeName) && absolutePath.contains(lastPodName)) {
|
|
|
FileUtil.rm(absolutePath);
|
|
@@ -179,7 +178,7 @@ public class ProjectUtil {
|
|
|
}
|
|
|
for (String absolutePath : list) {
|
|
|
if (absolutePath.contains(nodeName) && absolutePath.contains(projectId)) {
|
|
|
- createPod2(projectId, absolutePath);
|
|
|
+ createPod2(nodeName, absolutePath);
|
|
|
log.info("ProjectUtil--createNextPod 创建项目 " + projectId + " 的下一个 pod。");
|
|
|
return;
|
|
|
}
|
|
@@ -208,11 +207,11 @@ public class ProjectUtil {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @param nodeName 节点名称
|
|
|
+ * @param nodeName 节点名称
|
|
|
* @param podYamlPath pod 文件内容
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
- public void createPod2(String nodeName, String podYamlPath) {
|
|
|
+ public void createPod2(String nodeName, String podYamlPath) {
|
|
|
String podName = podYamlPath.split("#")[1].split("\\.")[0];
|
|
|
stringRedisTemplate.opsForValue().set("pod:" + podName + ":node", nodeName); // 将 pod 运行在哪个 node 上记录到 redis
|
|
|
KubernetesUtil.createNs(apiClient, kubernetesConfiguration.getNamespace());
|
|
@@ -220,7 +219,6 @@ public class ProjectUtil {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
public String getProjectTypeByProjectId(String projectId) {
|
|
|
String projectType = null;
|
|
|
ProjectPO manualProjectPO = manualProjectMapper.selectById(projectId);
|
|
@@ -559,7 +557,7 @@ public class ProjectUtil {
|
|
|
public void addOneParallelismToNode(String nodeName) {
|
|
|
String key = "node:" + nodeName + ":parallelism";
|
|
|
String parallelismString = stringRedisTemplate.opsForValue().get(key);
|
|
|
- if(StringUtil.isEmpty(parallelismString)){
|
|
|
+ if (StringUtil.isEmpty(parallelismString)) {
|
|
|
throw new RuntimeException("ProjectUtil--addOneParallelismToNode redisKey " + key + " 为空。");
|
|
|
}
|
|
|
int parallelism = Integer.parseInt(parallelismString);
|