You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dolphinscheduler.apache.org by "zhongjiajie (via GitHub)" <gi...@apache.org> on 2023/03/01 12:28:33 UTC
[GitHub] [dolphinscheduler] zhongjiajie commented on a diff in pull request #13654: [Improvement-13653][Remote Logging] Support api-server to get task log from remote target
zhongjiajie commented on code in PR #13654:
URL: https://github.com/apache/dolphinscheduler/pull/13654#discussion_r1121643096
##########
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:
does object storage support read by byte themself?
--
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: commits-unsubscribe@dolphinscheduler.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org