修改:HPC job clone,重排队指令结果集处理逻辑新增
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package com.sdm.common.entity.resp.pbs.hpc;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CloneJobResp {
|
||||
private String jobId;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.sdm.common.entity.resp.pbs.hpc;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class JobRequeueResp {
|
||||
|
||||
private Boolean requeued;
|
||||
|
||||
private String jobId;
|
||||
|
||||
}
|
||||
@@ -522,4 +522,39 @@ public class HpcCommandResulParseUtil {
|
||||
}
|
||||
|
||||
|
||||
public static CloneJobResp parseJobCloneResult(String cmdOutput) {
|
||||
CloneJobResp cloneJobResp = new CloneJobResp();
|
||||
try {
|
||||
// 按逗号分割,然后按冒号分割
|
||||
String[] parts = cmdOutput.split(",");
|
||||
for (String part : parts) {
|
||||
if (part.trim().startsWith("ID:")) {
|
||||
String idStr = part.split(":")[1].trim();
|
||||
cloneJobResp.setJobId(idStr);
|
||||
return cloneJobResp;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
CoreLogger.error("parseJobCloneResult error:{}",cmdOutput);
|
||||
}
|
||||
return cloneJobResp;
|
||||
}
|
||||
|
||||
public static JobRequeueResp parseJobRequeue(String cmdOutput) {
|
||||
JobRequeueResp jobRequeueResp = new JobRequeueResp();
|
||||
if (StringUtils.isBlank(cmdOutput)) return jobRequeueResp;
|
||||
String line = cmdOutput.trim();
|
||||
// 正常返回格式:Requeue job #6
|
||||
Pattern p = Pattern.compile("Requeue job #?(\\d+)", Pattern.CASE_INSENSITIVE);
|
||||
Matcher m = p.matcher(line);
|
||||
if (m.find()) {
|
||||
jobRequeueResp.setRequeued(true);
|
||||
String requeuedJobId = m.group(1);
|
||||
jobRequeueResp.setJobId(requeuedJobId);
|
||||
return jobRequeueResp;
|
||||
}
|
||||
jobRequeueResp.setRequeued(false);
|
||||
return jobRequeueResp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -134,9 +134,10 @@ public class TaskServiceImpl implements TaskService {
|
||||
BeanUtils.copyProperties(req, cloneJobParam);
|
||||
String cloneJobCommand = HpcCommandBuilderUtil.buildHpcCommandStr(prefixStr, cloneJobParam, "");
|
||||
String result = hpcCommandExcuteUtil.excuteCmd(cloneJobCommand,hpcExcuteWay);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
CloneJobResp cloneJobResp = HpcCommandResulParseUtil.parseJobCloneResult(result);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("hpcCommand", cloneJobCommand);
|
||||
map.put("result", result);
|
||||
map.put("result", cloneJobResp);
|
||||
return SdmResponse.success(map);
|
||||
}
|
||||
|
||||
@@ -203,9 +204,10 @@ public class TaskServiceImpl implements TaskService {
|
||||
BeanUtils.copyProperties(req, jobRequeueParam);
|
||||
String requeueJobCommand = HpcCommandBuilderUtil.buildHpcCommandStr(prefixStr, jobRequeueParam, "");
|
||||
String result = hpcCommandExcuteUtil.excuteCmd(requeueJobCommand,hpcExcuteWay);
|
||||
Map<String, String> map = new HashMap<>();
|
||||
JobRequeueResp jobRequeueResp = HpcCommandResulParseUtil.parseJobRequeue(result);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("hpcCommand", requeueJobCommand);
|
||||
map.put("result", result);
|
||||
map.put("result", jobRequeueResp);
|
||||
return SdmResponse.success(map);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user