[server][ executor]- 优化部分代码 - 3
This commit is contained in:
@@ -212,7 +212,8 @@ public class CommandExecutor {
|
||||
// 关停任务执行的缓存日志收集 BufferedReader 否则无法终止
|
||||
commandExecLogCache.StopCollectExecLog(
|
||||
streamKey,
|
||||
process
|
||||
process,
|
||||
commandExecWaitTimeout
|
||||
);
|
||||
|
||||
// 执行到这里,说明整个任务流程结束(超时结束)
|
||||
|
||||
@@ -163,9 +163,9 @@ public class CommandExecLogCache {
|
||||
|
||||
// 对于即时执行完成的任务,需要在这里增加尾巴内容
|
||||
addCommandExecTailInfo(
|
||||
process,
|
||||
1,
|
||||
streamKey,
|
||||
false
|
||||
0
|
||||
);
|
||||
|
||||
log.debug(
|
||||
@@ -183,27 +183,19 @@ public class CommandExecLogCache {
|
||||
* @param process
|
||||
* @param streamKey
|
||||
*/
|
||||
private void addCommandExecTailInfo(Process process, String streamKey, boolean isKillProcess) {
|
||||
private void addCommandExecTailInfo(int timeOut, String streamKey, int exitValue) {
|
||||
|
||||
log.debug("开始添加任务日志的尾部信息!");
|
||||
|
||||
// 添加任务结束的一些信息
|
||||
String execTimeCostString = String.format(
|
||||
"execution time-cost is => [ %s ]",
|
||||
process
|
||||
.info()
|
||||
.totalCpuDuration()
|
||||
.get()
|
||||
timeOut
|
||||
);
|
||||
|
||||
// 是否需要强行关闭 process 杀死任务进程
|
||||
/*if (isKillProcess) {
|
||||
process.destroyForcibly();
|
||||
}*/
|
||||
|
||||
String execResultString = String.format(
|
||||
"execution result code is => [ %s ]",
|
||||
process.exitValue()
|
||||
exitValue
|
||||
);
|
||||
|
||||
ArrayList<String> commandExecCachedLog = CachedCommandLogMap.get(streamKey);
|
||||
@@ -222,7 +214,7 @@ public class CommandExecLogCache {
|
||||
* 对于一些没有中止的任务,必须要手动将读取的 InputStream流关闭
|
||||
* 否则部分任务的日志无法收集
|
||||
*/
|
||||
public void StopCollectExecLog(String streamKey, Process process) {
|
||||
public void StopCollectExecLog(String streamKey, Process process, int commandExecWaitTimeout) {
|
||||
|
||||
BufferedReader bufferedReader = CommandLogBufferedReaderMap.get(streamKey);
|
||||
|
||||
@@ -254,9 +246,9 @@ public class CommandExecLogCache {
|
||||
if (ObjectUtils.isNotEmpty(process) && process.isAlive()) {
|
||||
|
||||
addCommandExecTailInfo(
|
||||
process,
|
||||
commandExecWaitTimeout,
|
||||
streamKey,
|
||||
true
|
||||
process.exitValue()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user