rickchengx commented on code in PR #13654:
URL:
https://github.com/apache/dolphinscheduler/pull/13654#discussion_r1122628866
##########
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/impl/LoggerServiceImpl.java:
##########
@@ -202,19 +207,33 @@ private String queryLog(TaskInstance taskInstance, int
skipLineNum, int limit) {
log.info("Query task instance log, taskInstanceId:{},
taskInstanceName:{}, host:{}, logPath:{}, port:{}",
taskInstance.getId(), taskInstance.getName(), host.getIp(),
taskInstance.getLogPath(), host.getPort());
- StringBuilder log = new StringBuilder();
+ StringBuilder sb = new StringBuilder();
if (skipLineNum == 0) {
String head = String.format(LOG_HEAD_FORMAT,
taskInstance.getLogPath(),
host,
Constants.SYSTEM_LINE_SEPARATOR);
- log.append(head);
+ sb.append(head);
}
- log.append(logClient
- .rollViewLog(host.getIp(), host.getPort(),
taskInstance.getLogPath(), skipLineNum, limit));
+ String logContent = logClient
+ .rollViewLog(host.getIp(), host.getPort(),
taskInstance.getLogPath(), skipLineNum, limit);
- return log.toString();
+ if (StringUtils.isEmpty(logContent) &&
RemoteLogUtils.isRemoteLoggingEnable()) {
+ // get task log from remote target
+ try {
+ RemoteLogUtils.getRemoteLog(taskInstance.getLogPath());
+ File logFile = new File(taskInstance.getLogPath());
+ logContent = FileUtils.readFileToString(logFile,
Charset.defaultCharset());
+ FileUtils.delete(logFile);
+ } catch (IOException e) {
+ log.error("Error while getting log from remote target", e);
+ }
+ }
+
+ sb.append(logContent);
Review Comment:
Hi, @zhongjiajie , thanks for your comment.
Do you mean reading the byte stream directly from the remote storage instead
of downloading it to the local file system first?
Since there are many types of remote storage, some types may support this
method, and some may not. Maybe it will be a feasible way to download and
process the local files uniformly. WDYT?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]