|
|
@@ -1,6 +1,5 @@ |
|
|
package com.ruoyi.platform.service.impl; |
|
|
package com.ruoyi.platform.service.impl; |
|
|
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException; |
|
|
|
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
import com.ruoyi.common.security.utils.SecurityUtils; |
|
|
import com.ruoyi.platform.domain.Experiment; |
|
|
import com.ruoyi.platform.domain.Experiment; |
|
|
import com.ruoyi.platform.domain.ExperimentIns; |
|
|
import com.ruoyi.platform.domain.ExperimentIns; |
|
|
@@ -8,10 +7,7 @@ import com.ruoyi.platform.mapper.ExperimentDao; |
|
|
import com.ruoyi.platform.mapper.ExperimentInsDao; |
|
|
import com.ruoyi.platform.mapper.ExperimentInsDao; |
|
|
import com.ruoyi.platform.service.ExperimentInsService; |
|
|
import com.ruoyi.platform.service.ExperimentInsService; |
|
|
import com.ruoyi.platform.service.WorkflowService; |
|
|
import com.ruoyi.platform.service.WorkflowService; |
|
|
import com.ruoyi.platform.utils.DateUtils; |
|
|
|
|
|
import com.ruoyi.platform.utils.HttpUtils; |
|
|
|
|
|
import com.ruoyi.platform.utils.JsonUtils; |
|
|
|
|
|
import com.ruoyi.platform.utils.MinioUtil; |
|
|
|
|
|
|
|
|
import com.ruoyi.platform.utils.*; |
|
|
import com.ruoyi.platform.vo.LogRequestVo; |
|
|
import com.ruoyi.platform.vo.LogRequestVo; |
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
import com.ruoyi.system.api.model.LoginUser; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
@@ -53,6 +49,8 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { |
|
|
private String argoWorkflowLog; |
|
|
private String argoWorkflowLog; |
|
|
@Value("${argo.workflowRealTimeLog}") |
|
|
@Value("${argo.workflowRealTimeLog}") |
|
|
private String argoWorkflowRealTimeLog; |
|
|
private String argoWorkflowRealTimeLog; |
|
|
|
|
|
@Value("${argo.workflowPodLog}") |
|
|
|
|
|
private String argoWorkflowPodLog; |
|
|
private final MinioUtil minioUtil; |
|
|
private final MinioUtil minioUtil; |
|
|
|
|
|
|
|
|
public ExperimentInsServiceImpl(MinioUtil minioUtil) { |
|
|
public ExperimentInsServiceImpl(MinioUtil minioUtil) { |
|
|
@@ -457,7 +455,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public String getRealtimeWorkflowLog(LogRequestVo logRequest) { |
|
|
|
|
|
|
|
|
public Map<String, Object> getRealtimeWorkflowLog(LogRequestVo logRequest) { |
|
|
|
|
|
|
|
|
String componentId = logRequest.getComponentId(); |
|
|
String componentId = logRequest.getComponentId(); |
|
|
String nameSpace = logRequest.getNamespace(); |
|
|
String nameSpace = logRequest.getNamespace(); |
|
|
@@ -482,7 +480,10 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { |
|
|
if (StringUtils.isEmpty(req)) { |
|
|
if (StringUtils.isEmpty(req)) { |
|
|
throw new RuntimeException("响应内容为空"); |
|
|
throw new RuntimeException("响应内容为空"); |
|
|
} |
|
|
} |
|
|
return req; |
|
|
|
|
|
|
|
|
// 使用JacksonUtil将响应字符串转换为Map |
|
|
|
|
|
Map<String, Object> tempMap = JacksonUtil.parseJSONStr2Map(req); |
|
|
|
|
|
//去掉中间多余的data层 |
|
|
|
|
|
return (Map<String, Object>) tempMap.get("data"); |
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
throw new RuntimeException("查询实验日志失败: " + e.getMessage(), e); |
|
|
throw new RuntimeException("查询实验日志失败: " + e.getMessage(), e); |
|
|
@@ -490,6 +491,29 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public Map<String, Object> getRealtimePodLog(String podName, String startTime) { |
|
|
|
|
|
Map<String,Object> requestData = new HashMap<>(); |
|
|
|
|
|
requestData.put("pod_name",podName); |
|
|
|
|
|
requestData.put("start_time",startTime); |
|
|
|
|
|
try { |
|
|
|
|
|
// 将Map转换为JSON字符串 |
|
|
|
|
|
String req = HttpUtils.sendPost(argoUrl + argoWorkflowPodLog, JsonUtils.mapToJson(requestData)); |
|
|
|
|
|
// 检查响应是否为空或无内容 |
|
|
|
|
|
if (StringUtils.isEmpty(req)) { |
|
|
|
|
|
throw new RuntimeException("响应内容为空"); |
|
|
|
|
|
} |
|
|
|
|
|
// 使用JacksonUtil将响应字符串转换为Map |
|
|
|
|
|
Map<String, Object> tempMap = JacksonUtil.parseJSONStr2Map(req); |
|
|
|
|
|
//去掉中间多余的data层 |
|
|
|
|
|
return (Map<String, Object>) tempMap.get("data"); |
|
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
throw new RuntimeException("查询pod实时日志失败: " + e.getMessage(), e); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private boolean isTerminatedState(ExperimentIns ins) throws IOException { |
|
|
private boolean isTerminatedState(ExperimentIns ins) throws IOException { |
|
|
// 定义终止态的列表,例如 "Succeeded", "Failed" 等 |
|
|
// 定义终止态的列表,例如 "Succeeded", "Failed" 等 |
|
|
String status = ins.getStatus(); |
|
|
String status = ins.getStatus(); |
|
|
|