| @@ -65,8 +65,8 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| //获取实例当前状态 | //获取实例当前状态 | ||||
| String currentStatus = experimentIns.getStatus(); | String currentStatus = experimentIns.getStatus(); | ||||
| // 检查是否需要调用接口查询状态:当原本状态为null或running或Pending时调用argo接口 | |||||
| if (StringUtils.isEmpty(currentStatus) || StringUtils.equals(currentStatus, "Running") || StringUtils.equals(currentStatus,"Pending")) { | |||||
| // 检查是否需要调用接口查询状态:当原本状态为null或非终止态时调用argo接口 | |||||
| if (StringUtils.isEmpty(currentStatus) || !isTerminatedState(currentStatus)) { | |||||
| String newStatus = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName(), id ); | String newStatus = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName(), id ); | ||||
| // 如果新状态不是null,并且与旧状态不同,则更新状态 | // 如果新状态不是null,并且与旧状态不同,则更新状态 | ||||
| @@ -91,12 +91,12 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| public List<ExperimentIns> getByExperimentId(Integer experimentId) { | public List<ExperimentIns> getByExperimentId(Integer experimentId) { | ||||
| List<ExperimentIns> experimentInsList = experimentInsDao.getByExperimentId(experimentId); | List<ExperimentIns> experimentInsList = experimentInsDao.getByExperimentId(experimentId); | ||||
| for (ExperimentIns experimentIns: experimentInsList) { | for (ExperimentIns experimentIns: experimentInsList) { | ||||
| if ( experimentIns!=null && (StringUtils.isEmpty(experimentIns.getStatus())) || StringUtils.equals(experimentIns.getStatus(), "Running") || StringUtils.equals(experimentIns.getStatus(),"Pending")) { | |||||
| // //当原本状态为null或running或Pending时才调用argo接口 | |||||
| //当原本状态为null或非终止态时才调用argo接口 | |||||
| if ( experimentIns!=null && (StringUtils.isEmpty(experimentIns.getStatus())) || !isTerminatedState(experimentIns.getStatus())) { | |||||
| String newStatus = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName(),experimentIns.getId()); | String newStatus = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName(),experimentIns.getId()); | ||||
| experimentIns.setStatus(newStatus); | experimentIns.setStatus(newStatus); | ||||
| //只有当新状态是终止态时才更新数据库 | //只有当新状态是终止态时才更新数据库 | ||||
| if (!(StringUtils.equals(newStatus, "Running") || StringUtils.equals(newStatus,"Pending"))) { | |||||
| if (isTerminatedState(newStatus)) { | |||||
| this.update(experimentIns); | this.update(experimentIns); | ||||
| } | } | ||||
| } | } | ||||
| @@ -393,4 +393,10 @@ public class ExperimentInsServiceImpl implements ExperimentInsService { | |||||
| } | } | ||||
| } | } | ||||
| private boolean isTerminatedState(String state) { | |||||
| // 定义终止态的列表,例如 "Succeeded", "Failed" 等 | |||||
| List<String> terminatedStates = Arrays.asList("Succeeded", "Failed", "Terminated"); | |||||
| return terminatedStates.contains(state); | |||||
| } | |||||
| } | } | ||||