|
@@ -6,7 +6,6 @@ import api.common.util.*;
|
|
import com.css.simulation.resource.scheduler.configuration.esmini.EsminiConfiguration;
|
|
import com.css.simulation.resource.scheduler.configuration.esmini.EsminiConfiguration;
|
|
import com.css.simulation.resource.scheduler.configuration.kubernetes.KubernetesConfiguration;
|
|
import com.css.simulation.resource.scheduler.configuration.kubernetes.KubernetesConfiguration;
|
|
import com.css.simulation.resource.scheduler.configuration.redis.CustomRedisClient;
|
|
import com.css.simulation.resource.scheduler.configuration.redis.CustomRedisClient;
|
|
-import com.css.simulation.resource.scheduler.controller.TaskController;
|
|
|
|
import com.css.simulation.resource.scheduler.entity.*;
|
|
import com.css.simulation.resource.scheduler.entity.*;
|
|
import com.css.simulation.resource.scheduler.mapper.AutoSubProjectMapper;
|
|
import com.css.simulation.resource.scheduler.mapper.AutoSubProjectMapper;
|
|
import com.css.simulation.resource.scheduler.mapper.ClusterMapper;
|
|
import com.css.simulation.resource.scheduler.mapper.ClusterMapper;
|
|
@@ -36,12 +35,6 @@ public class ProjectUtil {
|
|
|
|
|
|
@Value("${scheduler.linux-path.pod-yaml-directory}")
|
|
@Value("${scheduler.linux-path.pod-yaml-directory}")
|
|
private String podYamlDirectory;
|
|
private String podYamlDirectory;
|
|
- @Value("${scheduler.host.hostname}")
|
|
|
|
- private String hostname;
|
|
|
|
- @Value("${scheduler.host.username}")
|
|
|
|
- private String username;
|
|
|
|
- @Value("${scheduler.host.password}")
|
|
|
|
- private String password;
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
private ManualProjectMapper manualProjectMapper;
|
|
private ManualProjectMapper manualProjectMapper;
|
|
@@ -157,7 +150,7 @@ public class ProjectUtil {
|
|
final String replace = read.replace("cpu-order", "\"" + cpuOrderString + "\"");
|
|
final String replace = read.replace("cpu-order", "\"" + cpuOrderString + "\"");
|
|
FileUtil.writeStringToLocalFile(replace, absolutePath);
|
|
FileUtil.writeStringToLocalFile(replace, absolutePath);
|
|
// 创建 pod
|
|
// 创建 pod
|
|
- createPod3(projectId, yamlPathCacheKey, cpuOrderString);
|
|
|
|
|
|
+ createPod(projectId, yamlPathCacheKey, cpuOrderString);
|
|
log.info("创建项目 " + projectId + " 在节点 " + nodeName + " 的下一个 pod,使用 cpu 编号为 " + cpuOrderString);
|
|
log.info("创建项目 " + projectId + " 在节点 " + nodeName + " 的下一个 pod,使用 cpu 编号为 " + cpuOrderString);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -174,14 +167,14 @@ public class ProjectUtil {
|
|
String nodeName = new File(podYamlPath).getName().split("#")[0];
|
|
String nodeName = new File(podYamlPath).getName().split("#")[0];
|
|
String podName = podYamlPath.split("#")[1].split("\\.")[0];
|
|
String podName = podYamlPath.split("#")[1].split("\\.")[0];
|
|
stringRedisTemplate.opsForValue().set("project:" + projectId + ":pod:" + podName + ":node", nodeName); // 将 pod 运行在哪个 node 上记录到 redis
|
|
stringRedisTemplate.opsForValue().set("project:" + projectId + ":pod:" + podName + ":node", nodeName); // 将 pod 运行在哪个 node 上记录到 redis
|
|
- new Thread(() -> KubernetesUtil.applyYaml(hostname, username, password, podYamlPath), "apply-" + podName).start();
|
|
|
|
|
|
+ new Thread(() -> KubernetesUtil.applyYaml( podYamlPath), "apply-" + podName).start();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param redisKey yaml 地址的缓存 key
|
|
* @param redisKey yaml 地址的缓存 key
|
|
*/
|
|
*/
|
|
- public void createPod3(String projectId, String redisKey, String cpuOrderString) {
|
|
|
|
|
|
+ public void createPod(String projectId, String redisKey, String cpuOrderString) {
|
|
final String podYamlPath = stringRedisTemplate.opsForValue().get(redisKey);
|
|
final String podYamlPath = stringRedisTemplate.opsForValue().get(redisKey);
|
|
if (podYamlPath == null) {
|
|
if (podYamlPath == null) {
|
|
throw new RuntimeException("根据缓存 key 获取 yaml 地址为 null:" + redisKey);
|
|
throw new RuntimeException("根据缓存 key 获取 yaml 地址为 null:" + redisKey);
|
|
@@ -191,7 +184,7 @@ public class ProjectUtil {
|
|
String podName = podYamlPath.split("#")[1].split("\\.")[0];
|
|
String podName = podYamlPath.split("#")[1].split("\\.")[0];
|
|
stringRedisTemplate.opsForValue().set("project:" + projectId + ":pod:" + podName + ":node", nodeName); // 将 pod 运行在哪个 node 上记录到 redis
|
|
stringRedisTemplate.opsForValue().set("project:" + projectId + ":pod:" + podName + ":node", nodeName); // 将 pod 运行在哪个 node 上记录到 redis
|
|
stringRedisTemplate.opsForValue().set("project:" + projectId + ":pod:" + podName + ":cpu", cpuOrderString); // 将 pod 运行在哪个 node 上记录到 redis
|
|
stringRedisTemplate.opsForValue().set("project:" + projectId + ":pod:" + podName + ":cpu", cpuOrderString); // 将 pod 运行在哪个 node 上记录到 redis
|
|
- new Thread(() -> KubernetesUtil.applyYaml(hostname, username, password, podYamlPath), "create-" + podName).start();
|
|
|
|
|
|
+ new Thread(() -> KubernetesUtil.applyYaml(podYamlPath), "create-" + podName).start();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -290,7 +283,7 @@ public class ProjectUtil {
|
|
restNodeList.add(kubernetesNodeCopy);
|
|
restNodeList.add(kubernetesNodeCopy);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- log.info("ProjectUtil--getRestParallelism 集群剩余并行度为:" + restNodeList);
|
|
|
|
|
|
+ log.info(" 集群剩余并行度为:" + restNodeList);
|
|
return restNodeList.size() == 0 ? 0 : restNodeList.stream().mapToInt(GpuNodeEntity::getParallelism).sum();
|
|
return restNodeList.size() == 0 ? 0 : restNodeList.stream().mapToInt(GpuNodeEntity::getParallelism).sum();
|
|
}
|
|
}
|
|
|
|
|