[agent][executor]- bug - 11

This commit is contained in:
zeaslity
2023-02-26 15:04:40 +08:00
parent 245035d277
commit 5a679a1a8e

View File

@@ -34,15 +34,15 @@ public class CommandExecLogCache {
*/
private static final ArrayList<String> EmptyCommandLog = new ArrayList<>();
// 存储命令执行缓存日志
private static HashMap<String, ArrayList<String>> CachedCommandLogMap = new HashMap<>();
private static final HashMap<String, ArrayList<String>> CachedCommandLogMap = new HashMap<>();
/**
* 存储每一个任务对应的 日志读取BufferedReader
*/
private static HashMap<String, BufferedReader> CommandLogBufferedReaderMap = new HashMap<>();
private static final HashMap<String, BufferedReader> CommandLogBufferedReaderMap = new HashMap<>();
/**
* 存储每一个任务对应的 日志读取 InputStream Reader
*/
private static HashMap<String, InputStreamReader> CommandLogInputReaderMap = new HashMap<>();
private static final HashMap<String, InputStreamReader> CommandLogInputReaderMap = new HashMap<>();
@Resource
SimpleStreamSender simpleStreamSender;
@@ -132,8 +132,10 @@ public class CommandExecLogCache {
streamKey,
bufferedReader
);
CommandLogInputReaderMap.put(streamKey,
inputStreamReader);
CommandLogInputReaderMap.put(
streamKey,
inputStreamReader
);
log.debug("开始获取bufferedReader中每一行的内容");
// !! 此处会阻塞
@@ -167,9 +169,7 @@ public class CommandExecLogCache {
inputStreamReader
);
try {
// 关闭command的输出流
process
.getInputStream()
@@ -181,6 +181,11 @@ public class CommandExecLogCache {
} catch (IOException e) {
throw new RuntimeException(e);
} finally {
CommandLogBufferedReaderMap.remove(streamKey);
CommandLogInputReaderMap.remove(streamKey);
}
@@ -203,8 +208,7 @@ public class CommandExecLogCache {
.writerWithDefaultPrettyPrinter()
.writeValueAsString(cachedCommandLog);
System.out.println("s = " + s);
System.out.println(s);
} catch (JsonProcessingException e) {
throw new RuntimeException(e);