Unverified Commit f755d0b2 authored by gaoyan's avatar gaoyan Committed by GitHub

[Fix-#3372]Fix consle bug (#3410)

parent 1c45d744
...@@ -165,11 +165,6 @@ public class ConsoleContextHolder { ...@@ -165,11 +165,6 @@ public class ConsoleContextHolder {
*/ */
public ProcessStepEntity registerProcessStep(ProcessStepType type, String processName, String parentStepPid) public ProcessStepEntity registerProcessStep(ProcessStepType type, String processName, String parentStepPid)
throws RuntimeException { throws RuntimeException {
if (!logPross.containsKey(processName)) {
throw new BusException(StrFormatter.format("Process {} does not exist", type));
}
ProcessEntity process = logPross.get(processName);
process.setStatus(ProcessStatus.RUNNING);
ProcessStepEntity processStepEntity = ProcessStepEntity.builder() ProcessStepEntity processStepEntity = ProcessStepEntity.builder()
.key(UUID.fastUUID().toString()) .key(UUID.fastUUID().toString())
.status(ProcessStatus.RUNNING) .status(ProcessStatus.RUNNING)
...@@ -180,6 +175,12 @@ public class ConsoleContextHolder { ...@@ -180,6 +175,12 @@ public class ConsoleContextHolder {
.children(new CopyOnWriteArrayList<>()) .children(new CopyOnWriteArrayList<>())
.build(); .build();
if (!logPross.containsKey(processName)) {
log.error(StrFormatter.format("Process {} does not exist", type));
return processStepEntity;
}
ProcessEntity process = logPross.get(processName);
process.setStatus(ProcessStatus.RUNNING);
if (TextUtils.isEmpty(parentStepPid)) { if (TextUtils.isEmpty(parentStepPid)) {
// parentStep为空表示为顶级节点 // parentStep为空表示为顶级节点
process.getChildren().add(processStepEntity); process.getChildren().add(processStepEntity);
...@@ -202,10 +203,10 @@ public class ConsoleContextHolder { ...@@ -202,10 +203,10 @@ public class ConsoleContextHolder {
* @param e exception object, optional * @param e exception object, optional
*/ */
public void finishedProcess(String processName, ProcessStatus status, Throwable e) { public void finishedProcess(String processName, ProcessStatus status, Throwable e) {
if (!logPross.containsKey(processName)) { ProcessEntity process = logPross.remove(processName);
if (process == null) {
return; return;
} }
ProcessEntity process = logPross.get(processName);
process.setStatus(status); process.setStatus(status);
process.setEndTime(LocalDateTime.now()); process.setEndTime(LocalDateTime.now());
process.setTime( process.setTime(
...@@ -219,7 +220,6 @@ public class ConsoleContextHolder { ...@@ -219,7 +220,6 @@ public class ConsoleContextHolder {
} }
FileUtil.writeUtf8String(JSONObject.toJSONString(process), filePath); FileUtil.writeUtf8String(JSONObject.toJSONString(process), filePath);
appendLog(processName, null, StrFormatter.format("Process {} exit with status:{}", processName, status), true); appendLog(processName, null, StrFormatter.format("Process {} exit with status:{}", processName, status), true);
logPross.remove(processName);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment