健壮性增加
This commit is contained in:
parent
c548e4e150
commit
f07c0ea801
|
|
@ -59,7 +59,7 @@ public interface ExperimentInsService {
|
||||||
/**
|
/**
|
||||||
* 逻辑删除数据
|
* 逻辑删除数据
|
||||||
*/
|
*/
|
||||||
boolean removeById(Integer id);
|
String removeById(Integer id);
|
||||||
/**
|
/**
|
||||||
* 通过主键删除数据
|
* 通过主键删除数据
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,13 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public ExperimentIns queryById(Integer id) {
|
public ExperimentIns queryById(Integer id) {
|
||||||
return this.experimentInsDao.queryById(id);
|
ExperimentIns experimentIns = this.experimentInsDao.queryById(id);
|
||||||
|
if (experimentIns!=null && StringUtils.isEmpty(experimentIns.getStatus())) {
|
||||||
|
String status = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName());
|
||||||
|
experimentIns.setStatus(status);
|
||||||
|
this.update(experimentIns);
|
||||||
|
}
|
||||||
|
return experimentIns;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -74,7 +80,15 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<ExperimentIns> getByExperimentId(Integer experimentId) {
|
public List<ExperimentIns> getByExperimentId(Integer experimentId) {
|
||||||
return experimentInsDao.getByExperimentId(experimentId);
|
List<ExperimentIns> experimentInsList = experimentInsDao.getByExperimentId(experimentId);
|
||||||
|
for (ExperimentIns experimentIns: experimentInsList) {
|
||||||
|
if (experimentIns!=null && StringUtils.isEmpty(experimentIns.getStatus())) {
|
||||||
|
String status = this.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName());
|
||||||
|
experimentIns.setStatus(status);
|
||||||
|
this.update(experimentIns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return experimentInsList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -87,7 +101,15 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
|
||||||
@Override
|
@Override
|
||||||
public Page<ExperimentIns> queryByPage(ExperimentIns experimentIns, PageRequest pageRequest) {
|
public Page<ExperimentIns> queryByPage(ExperimentIns experimentIns, PageRequest pageRequest) {
|
||||||
long total = this.experimentInsDao.count(experimentIns);
|
long total = this.experimentInsDao.count(experimentIns);
|
||||||
return new PageImpl<>(this.experimentInsDao.queryAllByLimit(experimentIns, pageRequest), pageRequest, total);
|
List<ExperimentIns> experimentInsList = this.experimentInsDao.queryAllByLimit(experimentIns, pageRequest);
|
||||||
|
for (ExperimentIns ins: experimentInsList) {
|
||||||
|
if (experimentIns!=null && StringUtils.isEmpty(experimentIns.getStatus())) {
|
||||||
|
String status = this.queryStatusFromArgo(ins.getArgoInsNs(), ins.getArgoInsName());
|
||||||
|
ins.setStatus(status);
|
||||||
|
this.update(experimentIns);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new PageImpl<>(experimentInsList, pageRequest, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -124,10 +146,19 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean removeById(Integer id) {
|
public String removeById(Integer id) {
|
||||||
ExperimentIns experimentIns = experimentInsDao.queryById(id);
|
ExperimentIns experimentIns = experimentInsDao.queryById(id);
|
||||||
|
if (experimentIns == null){
|
||||||
|
return "实验实例不存在";
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(experimentIns.getStatus())){
|
||||||
|
experimentIns.setStatus(queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName()));
|
||||||
|
}
|
||||||
|
if (StringUtils.equals(experimentIns.getStatus(),"Running")){
|
||||||
|
return "实验实例正在运行,不可删除";
|
||||||
|
}
|
||||||
experimentIns.setState(0);
|
experimentIns.setState(0);
|
||||||
return this.experimentInsDao.update(experimentIns)>0;
|
return this.experimentInsDao.update(experimentIns)>0?"删除成功":"删除失败";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -206,7 +237,7 @@ public class ExperimentInsServiceImpl implements ExperimentInsService {
|
||||||
String name = experimentIns.getArgoInsName();
|
String name = experimentIns.getArgoInsName();
|
||||||
String namespace = experimentIns.getArgoInsNs();
|
String namespace = experimentIns.getArgoInsNs();
|
||||||
// 获取当前状态,如果为空,则从Argo查询
|
// 获取当前状态,如果为空,则从Argo查询
|
||||||
if (currentStatus == null || currentStatus.isEmpty()) {
|
if (StringUtils.isEmpty(currentStatus)) {
|
||||||
currentStatus = queryStatusFromArgo(namespace, name);
|
currentStatus = queryStatusFromArgo(namespace, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,13 +59,6 @@ public class ExperimentServiceImpl implements ExperimentService {
|
||||||
@Override
|
@Override
|
||||||
public Experiment queryById(Integer id) {
|
public Experiment queryById(Integer id) {
|
||||||
List<ExperimentIns> experimentInsList = this.experimentInsService.getByExperimentId(id);
|
List<ExperimentIns> experimentInsList = this.experimentInsService.getByExperimentId(id);
|
||||||
for (ExperimentIns experimentIns: experimentInsList) {
|
|
||||||
if (!(StringUtils.equals(experimentIns.getStatus(),"Succeeded") || StringUtils.equals(experimentIns.getStatus(),"Failed"))) {
|
|
||||||
String status = this.experimentInsService.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName());
|
|
||||||
experimentIns.setStatus(status);
|
|
||||||
this.experimentInsService.update(experimentIns);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Experiment experiment = this.experimentDao.queryById(id);
|
Experiment experiment = this.experimentDao.queryById(id);
|
||||||
if (experiment == null) {
|
if (experiment == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
@ -91,14 +84,6 @@ public class ExperimentServiceImpl implements ExperimentService {
|
||||||
//对于每一个从Experiment表中查询出来的id,可能有多个实例,每个实例的实验id是不同的
|
//对于每一个从Experiment表中查询出来的id,可能有多个实例,每个实例的实验id是不同的
|
||||||
for (Experiment exp: experimentList) {
|
for (Experiment exp: experimentList) {
|
||||||
List<ExperimentIns> experimentInsList = this.experimentInsService.getByExperimentId(exp.getId());
|
List<ExperimentIns> experimentInsList = this.experimentInsService.getByExperimentId(exp.getId());
|
||||||
for (ExperimentIns experimentIns: experimentInsList) {
|
|
||||||
if (!(experimentIns.getStatus().equals("Succeeded") || experimentIns.getStatus().equals("Failed") || experimentIns.getStatus().equals("Terminated"))) {
|
|
||||||
String status = this.experimentInsService.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName());
|
|
||||||
experimentIns.setStatus(status);
|
|
||||||
this.experimentInsService.update(experimentIns);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
exp.setExperimentInsList(experimentInsList);
|
exp.setExperimentInsList(experimentInsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -120,20 +105,9 @@ public class ExperimentServiceImpl implements ExperimentService {
|
||||||
//对于每一个从Experiment表中查询出来的id,可能有多个实例,每个实例的实验id是不同的
|
//对于每一个从Experiment表中查询出来的id,可能有多个实例,每个实例的实验id是不同的
|
||||||
for (Experiment exp: experimentList) {
|
for (Experiment exp: experimentList) {
|
||||||
List<ExperimentIns> experimentInsList = this.experimentInsService.getByExperimentId(exp.getId());
|
List<ExperimentIns> experimentInsList = this.experimentInsService.getByExperimentId(exp.getId());
|
||||||
for (ExperimentIns experimentIns: experimentInsList) {
|
|
||||||
if (!(StringUtils.equals(experimentIns.getStatus(),"Succeeded") || StringUtils.equals(experimentIns.getStatus(),"Failed"))) {
|
|
||||||
String status = this.experimentInsService.queryStatusFromArgo(experimentIns.getArgoInsNs(), experimentIns.getArgoInsName());
|
|
||||||
experimentIns.setStatus(status);
|
|
||||||
this.experimentInsService.update(experimentIns);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
exp.setExperimentInsList(experimentInsList);
|
exp.setExperimentInsList(experimentInsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return new PageImpl<>(experimentList);
|
return new PageImpl<>(experimentList);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -250,6 +224,8 @@ public class ExperimentServiceImpl implements ExperimentService {
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
List<ExperimentIns> experimentIns = experimentInsService.queryByExperimentId(id);
|
||||||
|
experiment.setExperimentInsList(experimentIns);
|
||||||
return experiment;
|
return experiment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ public class ExperimentInsController {
|
||||||
*/
|
*/
|
||||||
@DeleteMapping
|
@DeleteMapping
|
||||||
@ApiOperation("删除实验实例")
|
@ApiOperation("删除实验实例")
|
||||||
public ResponseEntity<Boolean> deleteById(Integer id) {
|
public ResponseEntity<String> deleteById(Integer id) {
|
||||||
return ResponseEntity.ok(this.experimentInsService.removeById(id));
|
return ResponseEntity.ok(this.experimentInsService.removeById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ spring:
|
||||||
# redis 配置
|
# redis 配置
|
||||||
redis:
|
redis:
|
||||||
# 地址
|
# 地址
|
||||||
host: 172.20.32.150
|
host: 127.0.0.1
|
||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 6379
|
port: 6379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
|
|
@ -135,6 +135,6 @@ argo:
|
||||||
url: http://172.20.32.181:31000
|
url: http://172.20.32.181:31000
|
||||||
convert: /api/v1/workflow/convert
|
convert: /api/v1/workflow/convert
|
||||||
workflowRun: /api/v1/workflow/run
|
workflowRun: /api/v1/workflow/run
|
||||||
workflowStatus: /api/v1/workflow/status
|
workflowStatus: /api/v1/workflow/getWorkflow
|
||||||
workflowTermination: /api/v1/workflow/terminate
|
workflowTermination: /api/v1/workflow/terminate
|
||||||
workflowLog: /api/v1/workflow/getWorkflowLog
|
workflowLog: /api/v1/workflow/getWorkflowLog
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue