|
|
@ -359,7 +359,7 @@ public abstract class AbstractCommandExecutor { |
|
|
|
} |
|
|
|
} |
|
|
|
logOutputIsSuccess = true; |
|
|
|
logOutputIsSuccess = true; |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
logger.error("Parse var pool error", e); |
|
|
|
logOutputIsSuccess = true; |
|
|
|
logOutputIsSuccess = true; |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -369,17 +369,16 @@ public abstract class AbstractCommandExecutor { |
|
|
|
ExecutorService parseProcessOutputExecutorService = newDaemonSingleThreadExecutor(threadLoggerInfoName); |
|
|
|
ExecutorService parseProcessOutputExecutorService = newDaemonSingleThreadExecutor(threadLoggerInfoName); |
|
|
|
parseProcessOutputExecutorService.submit(() -> { |
|
|
|
parseProcessOutputExecutorService.submit(() -> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
long lastFlushTime = System.currentTimeMillis(); |
|
|
|
while (!logBuffer.isEmpty() || !logOutputIsSuccess) { |
|
|
|
while (logBuffer.size() > 0 || !logOutputIsSuccess) { |
|
|
|
if (!logBuffer.isEmpty()) { |
|
|
|
if (logBuffer.size() > 0) { |
|
|
|
logHandler.accept(logBuffer); |
|
|
|
lastFlushTime = flush(lastFlushTime); |
|
|
|
logBuffer.clear(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
Thread.sleep(TaskConstants.DEFAULT_LOG_FLUSH_INTERVAL); |
|
|
|
Thread.sleep(TaskConstants.DEFAULT_LOG_FLUSH_INTERVAL); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
Thread.currentThread().interrupt(); |
|
|
|
logger.error("Output task log error", e); |
|
|
|
logger.error(e.getMessage(), e); |
|
|
|
|
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
clear(); |
|
|
|
clear(); |
|
|
|
} |
|
|
|
} |
|
|
@ -438,28 +437,6 @@ public abstract class AbstractCommandExecutor { |
|
|
|
return processId; |
|
|
|
return processId; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* when log buffer siz or flush time reach condition , then flush |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param lastFlushTime last flush time |
|
|
|
|
|
|
|
* @return last flush time |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private long flush(long lastFlushTime) { |
|
|
|
|
|
|
|
long now = System.currentTimeMillis(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
* when log buffer siz or flush time reach condition , then flush |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
if (logBuffer.size() >= TaskConstants.DEFAULT_LOG_ROWS_NUM |
|
|
|
|
|
|
|
|| now - lastFlushTime > TaskConstants.DEFAULT_LOG_FLUSH_INTERVAL) { |
|
|
|
|
|
|
|
lastFlushTime = now; |
|
|
|
|
|
|
|
logHandler.accept(logBuffer); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logBuffer.clear(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return lastFlushTime; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected abstract String buildCommandFilePath(); |
|
|
|
protected abstract String buildCommandFilePath(); |
|
|
|
|
|
|
|
|
|
|
|
protected abstract void createCommandFileIfNotExists(String execCommand, String commandFile) throws IOException; |
|
|
|
protected abstract void createCommandFileIfNotExists(String execCommand, String commandFile) throws IOException; |
|
|
|