|
@@ -3,10 +3,7 @@ package com.css.simulation.resource.scheduler.consumer;
|
|
|
|
|
|
import api.common.pojo.constants.DictConstants;
|
|
import api.common.pojo.constants.DictConstants;
|
|
import api.common.pojo.dto.ProjectMessageDTO;
|
|
import api.common.pojo.dto.ProjectMessageDTO;
|
|
-import api.common.util.FileUtil;
|
|
|
|
-import api.common.util.JsonUtil;
|
|
|
|
-import api.common.util.LinuxUtil;
|
|
|
|
-import api.common.util.TimeUtil;
|
|
|
|
|
|
+import api.common.util.*;
|
|
import com.css.simulation.resource.scheduler.mapper.*;
|
|
import com.css.simulation.resource.scheduler.mapper.*;
|
|
import com.css.simulation.resource.scheduler.pojo.po.*;
|
|
import com.css.simulation.resource.scheduler.pojo.po.*;
|
|
import com.css.simulation.resource.scheduler.service.ManualProjectService;
|
|
import com.css.simulation.resource.scheduler.service.ManualProjectService;
|
|
@@ -15,6 +12,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import lombok.SneakyThrows;
|
|
import lombok.SneakyThrows;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
|
import org.apache.kafka.clients.consumer.ConsumerRecord;
|
|
|
|
+import org.apache.sshd.client.SshClient;
|
|
|
|
+import org.apache.sshd.client.session.ClientSession;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
@@ -71,6 +70,13 @@ public class ManualProjectConsumer {
|
|
@Value("${scheduler.manual-project.job-yaml}")
|
|
@Value("${scheduler.manual-project.job-yaml}")
|
|
String jobYaml;
|
|
String jobYaml;
|
|
|
|
|
|
|
|
+ @Value("${scheduler.score.hostname}")
|
|
|
|
+ String hostname;
|
|
|
|
+ @Value("${scheduler.score.username}")
|
|
|
|
+ String username;
|
|
|
|
+ @Value("${scheduler.score.password}")
|
|
|
|
+ String password;
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 任务运行前首先判断用户是否拥有可分配资源
|
|
* 任务运行前首先判断用户是否拥有可分配资源
|
|
@@ -174,7 +180,13 @@ public class ManualProjectConsumer {
|
|
String replace8 = replace7.replace("1atch/v1", "batch/v1");
|
|
String replace8 = replace7.replace("1atch/v1", "batch/v1");
|
|
log.info("------- ManualProjectConsumer 开始执行 yaml 文件" + replace8);
|
|
log.info("------- ManualProjectConsumer 开始执行 yaml 文件" + replace8);
|
|
FileUtil.writeStringToLocalFile(replace8, jobTemplateYamlPathTarget);
|
|
FileUtil.writeStringToLocalFile(replace8, jobTemplateYamlPathTarget);
|
|
- LinuxUtil.execute("kubectl apply -f " + jobTemplateYamlPathTarget);
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ SshClient client = SshUtil.getClient();
|
|
|
|
+ ClientSession session = SshUtil.getSession(client, hostname, username, password);
|
|
|
|
+ SshUtil.execute(session, "kubectl apply -f " + jobTemplateYamlPathTarget);
|
|
|
|
+ session.close();
|
|
|
|
+ client.stop();
|
|
}
|
|
}
|
|
|
|
|
|
@KafkaListener(groupId = "simulation-resource-scheduler", topics = "${scheduler.manual-project.stop-topic}")
|
|
@KafkaListener(groupId = "simulation-resource-scheduler", topics = "${scheduler.manual-project.stop-topic}")
|